From 8bfe6de4ea0055846e316527c118c07e99891190 Mon Sep 17 00:00:00 2001 From: alexion Date: Thu, 10 Sep 2026 08:57:01 -0400 Subject: [PATCH] refactor(nixos): inline reverse proxy HTTP helpers --- .../nixos/modules/services/reverse-proxy.nix | 41 ++++++++----------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/configs/nixos/modules/services/reverse-proxy.nix b/configs/nixos/modules/services/reverse-proxy.nix index 916ca29..b5632e9 100644 --- a/configs/nixos/modules/services/reverse-proxy.nix +++ b/configs/nixos/modules/services/reverse-proxy.nix @@ -9,30 +9,34 @@ let mkRegistryPath = registryName: host: entry: "registry.${registryName}.${host}.${entry}"; - mkBackend = address: route: "http://${address}:${toString route.port}"; - - mkVirtualHost = host: entry: + mkUdpStream = host: entry: port: let compositeEntry = registry.join host entry; - route = compositeEntry.route; address = compositeEntry.address or (throw "no matching entry in registry.address for ${mkRegistryPath "route" host entry}"); in { - inherit host entry; - name = route.domain; - value = { - forceSSL = true; - enableACME = true; - locations."/".proxyPass = mkBackend address route; - }; + inherit host entry port address; }; generatedVirtualHostList = lib.concatLists ( lib.mapAttrsToList ( host: routes: - lib.mapAttrsToList (entry: _route: mkVirtualHost host entry) ( - lib.filterAttrs (_entry: route: route.port != null) routes - ) + lib.mapAttrsToList ( + entry: route: + let + compositeEntry = registry.join host entry; + address = compositeEntry.address or (throw "no matching entry in registry.address for ${mkRegistryPath "route" host entry}"); + in + { + inherit host entry; + name = route.domain; + value = { + forceSSL = true; + enableACME = true; + locations."/".proxyPass = "http://${address}:${toString route.port}"; + }; + } + ) (lib.filterAttrs (_entry: route: route.port != null) routes) ) registry.route ); @@ -62,15 +66,6 @@ let else lib.listToAttrs generatedVirtualHostList; - mkUdpStream = host: entry: port: - let - compositeEntry = registry.join host entry; - address = compositeEntry.address or (throw "no matching entry in registry.address for ${mkRegistryPath "route" host entry}"); - in - { - inherit host entry port address; - }; - generatedUdpStreams = lib.concatLists ( lib.mapAttrsToList ( host: routes: