refactor(nixos): simplify route protocol checks

This commit is contained in:
2026-10-05 00:06:22 -04:00
parent e6915e8abd
commit ad79097f4e

View File

@@ -16,25 +16,17 @@
{ {
assertion = assertion =
entries: entries:
lib.all ( lib.all (entry: entry.value.port != null && entry.value.ports == [ ]) (
entry: lib.filter (entry: entry.value.protocol != "udp") entries
let );
route = entry.value;
in
!lib.elem route.protocol [
"http"
"https"
]
|| (route.port != null && route.ports == [ ])
) entries;
message = "HTTP and HTTPS routes must set port and not ports."; message = "HTTP and HTTPS routes must set port and not ports.";
} }
{ {
assertion = assertion =
entries: entries:
lib.all ( lib.all (entry: entry.value.port == null && entry.value.ports != [ ]) (
entry: entry.value.protocol != "udp" || (entry.value.port == null && entry.value.ports != [ ]) lib.filter (entry: entry.value.protocol == "udp") entries
) entries; );
message = "UDP routes must set ports and not port."; message = "UDP routes must set ports and not port.";
} }
]; ];