From ad79097f4ecf27bf2b8f7664b7af3f79e95f5d09 Mon Sep 17 00:00:00 2001 From: alexion Date: Mon, 5 Oct 2026 00:06:22 -0400 Subject: [PATCH] refactor(nixos): simplify route protocol checks --- configs/nixos/registry/route.nix | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/configs/nixos/registry/route.nix b/configs/nixos/registry/route.nix index 3cfae5e..653ae31 100644 --- a/configs/nixos/registry/route.nix +++ b/configs/nixos/registry/route.nix @@ -16,25 +16,17 @@ { assertion = entries: - lib.all ( - entry: - let - route = entry.value; - in - !lib.elem route.protocol [ - "http" - "https" - ] - || (route.port != null && route.ports == [ ]) - ) entries; + lib.all (entry: entry.value.port != null && entry.value.ports == [ ]) ( + lib.filter (entry: entry.value.protocol != "udp") entries + ); message = "HTTP and HTTPS routes must set port and not ports."; } { assertion = entries: - lib.all ( - entry: entry.value.protocol != "udp" || (entry.value.port == null && entry.value.ports != [ ]) - ) entries; + lib.all (entry: entry.value.port == null && entry.value.ports != [ ]) ( + lib.filter (entry: entry.value.protocol == "udp") entries + ); message = "UDP routes must set ports and not port."; } ];