diff options
| author | Adam Washington <[email protected]> | 2021-09-10 15:23:15 +0000 |
|---|---|---|
| committer | Adam Washington <[email protected]> | 2021-09-10 15:24:27 +0000 |
| commit | 363e514bbcc5e8efbda09991f60c5ea63e4e4d57 (patch) | |
| tree | c32ac813e0b92143a04c91d8b94390967eda1217 | |
| parent | Initial Commit (diff) | |
| download | pia.nix-363e514bbcc5e8efbda09991f60c5ea63e4e4d57.tar.xz pia.nix-363e514bbcc5e8efbda09991f60c5ea63e4e4d57.zip | |
Make a real PIA module
| -rw-r--r-- | flake.lock | 27 | ||||
| -rw-r--r-- | flake.nix | 88 |
2 files changed, 62 insertions, 53 deletions
diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..bde0e9c --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1631135738, + "narHash": "sha256-igtPHjRUaP5+6C7GuQ05J8ZT6RQ9CKmXMUzHl5tXwdM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "276671abd104e83ba7cb0b26f44848489eb0306b", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-21.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} @@ -1,59 +1,41 @@ { - inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-21.05"; - home-manager.url = "github:rycee/home-manager/release-21.05"; - home-manager.inputs.nixpkgs.follows = "nixpkgs"; - }; - outputs = { self, nixpkgs, home-manager }: { - lib.enableSwaybar = { config, pkgs, ... }: - let - colors = config.colors; - background = "#${colors.base00}"; - brite_bg = "#${colors.base01}"; - dim = "#${colors.base04}"; - fg = "#${colors.base05}"; - brite = "#${colors.base07}"; - in { - wayland.windowManager.sway.config.bars = [{ - colors.background = background; - colors.statusline = fg; - colors.activeWorkspace.background = background; - colors.activeWorkspace.border = background; - colors.activeWorkspace.text = fg; - colors.focusedWorkspace.background = background; - colors.focusedWorkspace.border = background; - colors.focusedWorkspace.text = brite; - colors.inactiveWorkspace.background = background; - colors.inactiveWorkspace.border = background; - colors.inactiveWorkspace.text = dim; - colors.urgentWorkspace.background = fg; - colors.urgentWorkspace.border = background; - colors.urgentWorkspace.text = background; - fonts = { - names = [ config.font-name "Symbola"]; - style = "Condensed"; - size = config.font-size - 4.0; + inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-21.05"; }; + outputs = { self, nixpkgs }: { + nixosModule = { config }: { + options = { + services.pia.authUserPass = { + username = nixpkgs.lib.mkOption { + default = false; + type = nixpkgs.lib.types.bool; + }; + password = nixpkgs.lib.mkOption { + default = false; + type = nixpkgs.lib.types.bool; }; - position = "top"; - statusCommand = "${self.defaultPackage.x86_64-linux}/bin/swaybar"; - }]; - }; - - defaultPackage.x86_64-linux = - nixpkgs.legacyPackages.x86_64-linux.rustPlatform.buildRustPackage { - pname = "swaybar"; - version = "0.1.0"; - - src = ./.; - - cargoSha256 = "YiNaEyiKfiBIWzRXNIoqeWzoD/AGYNXYyy33Tj3a61g="; - - meta = with nixpkgs.lib; { - description = "My personal code for swaybar"; - homepage = "https://sr.ht/rprospero/swaybar"; - license = licenses.unlicense; - maintainers = [ maintainers.rprospero ]; }; }; + config = { + services.openvpn.servers = let + resources = nixpkgs.fetchzip { + name = "pia-vpn-config"; + url = "https://www.privateinternetaccess.com/openvpn/openvpn.zip"; + sha256 = "ZA8RS6eIjMVQfBt+9hYyhaq8LByy5oJaO9Ed+x8KtW8="; + stripRoot = false; + }; + servers = map (builtins.replaceStrings [ ".ovpn" "_" ] [ "" "-" ]) + (builtins.filter (name: !(isNull (builtins.match ".+ovpn$" name))) + (builtins.attrNames (builtins.readDir resources))); + make_server = (name: { + name = name; + value = { + autoStart = false; + authUserPass = config.services.pia.authUserPass; + config = "config ${resources}/${name}.ovpn"; + updateResolvConf = true; + }; + }); + in builtins.listToAttrs (map make_server servers); + }; + }; }; } |