refactor(nixos): model route protocols explicitly

This commit was merged in pull request #128.
This commit is contained in:
2026-10-05 00:08:36 -04:00
parent a7db0b745c
commit c3a6271582
5 changed files with 49 additions and 29 deletions

View File

@@ -71,12 +71,12 @@ let
if item.homepage.href != null then
item.homepage.href
else if (item.composite.route or null) != null then
if item.composite.route.port != null then
if item.composite.route.protocol == "https" then
"https://${item.composite.route.domain}"
else if item.composite.route.http.port != null then
else if item.composite.route.protocol == "http" then
"http://${item.composite.route.domain}"
else
throw "${mkRegistryPath "homepage" item.host item.entry} needs href or a matching TCP route entry"
throw "${mkRegistryPath "homepage" item.host item.entry} needs href or a matching HTTP route entry"
else
throw "${mkRegistryPath "homepage" item.host item.entry} needs href or a matching route entry";

View File

@@ -11,7 +11,9 @@ let
lib.mapAttrsToList (
host: routes:
lib.concatLists (
lib.mapAttrsToList (entry: route: map (mkUdpStream host entry) route.udp.ports) routes
lib.mapAttrsToList (
entry: route: lib.optionals (route.protocol == "udp") (map (mkUdpStream host entry) route.ports)
) routes
)
) registry.route
);
@@ -75,7 +77,7 @@ let
lib.mapAttrsToList (
host: routes:
lib.mapAttrsToList (entry: _route: mkVirtualHost host entry "https") (
lib.filterAttrs (_entry: route: route.port != null) routes
lib.filterAttrs (_entry: route: route.protocol == "https") routes
)
) registry.route
);
@@ -89,7 +91,7 @@ let
or (throw "no matching entry in registry.address for ${mkRegistryPath "route" host entry}");
compositeEntry = registry.join host entry;
inherit (compositeEntry) route;
port = if isHttp then route.http.port else route.port;
inherit (route) port;
in
{
inherit host entry;
@@ -108,7 +110,7 @@ let
lib.mapAttrsToList (
host: routes:
lib.mapAttrsToList (entry: _route: mkVirtualHost host entry "http") (
lib.filterAttrs (_entry: route: route.http.port != null) routes
lib.filterAttrs (_entry: route: route.protocol == "http") routes
)
) registry.route
);