From ac05391c228b1630614e6585124f183a90489414 Mon Sep 17 00:00:00 2001 From: seth Date: Thu, 8 Feb 2024 21:20:51 -0500 Subject: lib/nginx: init --- lib/nginx.nix | 13 +++++++++++++ systems/atlas/nginx.nix | 15 +++------------ 2 files changed, 16 insertions(+), 12 deletions(-) create mode 100644 lib/nginx.nix diff --git a/lib/nginx.nix b/lib/nginx.nix new file mode 100644 index 0000000..0328f79 --- /dev/null +++ b/lib/nginx.nix @@ -0,0 +1,13 @@ +{lib, ...}: { + mkProxy = endpoint: port: { + "${endpoint}" = { + proxyPass = "http://localhost:${toString port}"; + proxyWebsockets = true; + }; + }; + + toVHosts = domain: + lib.mapAttrs' ( + name: value: lib.nameValuePair "${name}.${domain}" value + ); +} diff --git a/systems/atlas/nginx.nix b/systems/atlas/nginx.nix index 29c76e8..001c4d5 100644 --- a/systems/atlas/nginx.nix +++ b/systems/atlas/nginx.nix @@ -1,21 +1,12 @@ { config, - lib, + inputs, ... }: let - mkProxy = endpoint: port: { - "${endpoint}" = { - proxyPass = "http://localhost:${toString port}"; - proxyWebsockets = true; - }; - }; - - toVHosts = lib.mapAttrs' ( - name: value: lib.nameValuePair "${name}.${config.networking.domain}" value - ); + inherit (inputs.self.lib.nginx) mkProxy toVHosts; in { services.nginx = { - virtualHosts = toVHosts { + virtualHosts = toVHosts config.networking.domain { miniflux = { locations = mkProxy "/" "7000"; }; -- cgit v1.2.3