From 0ead9592dc3b6b8ac19b74cdc4980eef15ed78c5 Mon Sep 17 00:00:00 2001 From: seth Date: Thu, 24 Aug 2023 03:57:22 -0400 Subject: lib/mkProxy+mkVHosts: init --- parts/lib/default.nix | 2 +- parts/lib/utils.nix | 27 --------------------------- parts/lib/utils/default.nix | 4 ++++ parts/lib/utils/deploy.nix | 29 +++++++++++++++++++++++++++++ parts/lib/utils/nginx.nix | 22 ++++++++++++++++++++++ 5 files changed, 56 insertions(+), 28 deletions(-) delete mode 100644 parts/lib/utils.nix create mode 100644 parts/lib/utils/default.nix create mode 100644 parts/lib/utils/deploy.nix create mode 100644 parts/lib/utils/nginx.nix (limited to 'parts/lib') 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.nix b/parts/lib/utils.nix deleted file mode 100644 index 7e3109f..0000000 --- a/parts/lib/utils.nix +++ /dev/null @@ -1,27 +0,0 @@ -{inputs, ...}: let - deployPkgs = pkgs: - import pkgs.path { - inherit (pkgs) system; - overlays = [ - inputs.deploy-rs.overlay - (_: prev: { - deploy-rs = { - inherit (pkgs) deploy-rs; - inherit (prev.deploy-rs) lib; - }; - }) - ]; - }; -in { - mkDeployNodes = builtins.mapAttrs (_: system: let - inherit (deployPkgs system.pkgs) deploy-rs; - type = - if system.pkgs.stdenv.isLinux - then "nixos" - else "darwin"; - in { - sshUser = "root"; - hostname = system.config.networking.hostName; - profiles.system.path = deploy-rs.lib.activate.${type} system; - }); -} 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/deploy.nix b/parts/lib/utils/deploy.nix new file mode 100644 index 0000000..aaa01f1 --- /dev/null +++ b/parts/lib/utils/deploy.nix @@ -0,0 +1,29 @@ +{inputs, ...}: let + inherit (builtins) mapAttrs; + inherit (inputs) deploy-rs; +in { + mkDeployNodes = mapAttrs (_: system: let + inherit (system) pkgs; + deployPkgs = import pkgs.path { + inherit (pkgs) system; + overlays = [ + deploy-rs.overlay + (_: prev: { + deploy-rs = { + inherit (pkgs) deploy-rs; + inherit (prev.deploy-rs) lib; + }; + }) + ]; + }; + + type = + if pkgs.stdenv.isLinux + then "nixos" + else "darwin"; + in { + sshUser = "root"; + hostname = system.config.networking.hostName; + 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); +} -- cgit v1.2.3