diff options
Diffstat (limited to 'parts')
| -rw-r--r-- | parts/deploy.nix | 2 | ||||
| -rw-r--r-- | parts/lib/default.nix | 2 | ||||
| -rw-r--r-- | parts/lib/utils/default.nix | 4 | ||||
| -rw-r--r-- | parts/lib/utils/deploy.nix (renamed from parts/lib/utils.nix) | 18 | ||||
| -rw-r--r-- | parts/lib/utils/nginx.nix | 22 |
5 files changed, 38 insertions, 10 deletions
diff --git a/parts/deploy.nix b/parts/deploy.nix index 725c322..43eb08a 100644 --- a/parts/deploy.nix +++ b/parts/deploy.nix @@ -14,6 +14,6 @@ in { flake.deploy = { remoteBuild = true; fastConnection = true; - nodes = self.lib.utils.mkDeployNodes targets'; + nodes = self.lib.utils.deploy.mkDeployNodes targets'; }; } diff --git a/parts/lib/default.nix b/parts/lib/default.nix index bdc485c..5f99521 100644 --- a/parts/lib/default.nix +++ b/parts/lib/default.nix @@ -1,6 +1,6 @@ {withSystem, ...} @ args: { flake.lib = { configs = import ./configs.nix args; - utils = import ./utils.nix ({inherit withSystem;} // args); + utils = import ./utils ({inherit withSystem;} // args); }; } diff --git a/parts/lib/utils/default.nix b/parts/lib/utils/default.nix new file mode 100644 index 0000000..cbb6eb9 --- /dev/null +++ b/parts/lib/utils/default.nix @@ -0,0 +1,4 @@ +args: { + deploy = import ./deploy.nix args; + nginx = import ./nginx.nix args; +} diff --git a/parts/lib/utils.nix b/parts/lib/utils/deploy.nix index 7e3109f..aaa01f1 100644 --- a/parts/lib/utils.nix +++ b/parts/lib/utils/deploy.nix @@ -1,9 +1,13 @@ {inputs, ...}: let - deployPkgs = pkgs: - import pkgs.path { + inherit (builtins) mapAttrs; + inherit (inputs) deploy-rs; +in { + mkDeployNodes = mapAttrs (_: system: let + inherit (system) pkgs; + deployPkgs = import pkgs.path { inherit (pkgs) system; overlays = [ - inputs.deploy-rs.overlay + deploy-rs.overlay (_: prev: { deploy-rs = { inherit (pkgs) deploy-rs; @@ -12,16 +16,14 @@ }) ]; }; -in { - mkDeployNodes = builtins.mapAttrs (_: system: let - inherit (deployPkgs system.pkgs) deploy-rs; + type = - if system.pkgs.stdenv.isLinux + if pkgs.stdenv.isLinux then "nixos" else "darwin"; in { sshUser = "root"; hostname = system.config.networking.hostName; - profiles.system.path = deploy-rs.lib.activate.${type} system; + profiles.system.path = deployPkgs.deploy-rs.lib.activate.${type} system; }); } diff --git a/parts/lib/utils/nginx.nix b/parts/lib/utils/nginx.nix new file mode 100644 index 0000000..57be4fb --- /dev/null +++ b/parts/lib/utils/nginx.nix @@ -0,0 +1,22 @@ +{lib, ...}: let + inherit (builtins) mapAttrs; + inherit (lib) recursiveUpdate; +in { + mkProxy = endpoint: port: { + "${endpoint}" = { + proxyPass = "http://localhost:${toString port}"; + proxyWebsockets = true; + }; + }; + + mkVHosts = let + commonSettings = { + enableACME = true; + # workaround for https://github.com/NixOS/nixpkgs/issues/210807 + acmeRoot = null; + + addSSL = true; + }; + in + mapAttrs (_: recursiveUpdate commonSettings); +} |
