From fa7b5dd6e754e397c60b236f57c64cd7f219cc70 Mon Sep 17 00:00:00 2001 From: isabel Date: Tue, 7 Jul 2026 21:31:19 +0100 Subject: [PATCH] flake: cleanup eval speeds --- modules/flake/checks/port-collector.nix | 14 +++++--------- modules/flake/lib/helpers.nix | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/modules/flake/checks/port-collector.nix b/modules/flake/checks/port-collector.nix index e8f2183a..222cb303 100644 --- a/modules/flake/checks/port-collector.nix +++ b/modules/flake/checks/port-collector.nix @@ -6,18 +6,14 @@ self, }: let - inherit (lib.attrsets) foldlAttrs; - inherit (lib.lists) filter length; + inherit (lib.attrsets) attrNames; + inherit (lib.lists) filter length groupBy; inherit (lib.strings) concatMapStringsSep concatStringsSep; + services = self.nixosConfigurations.amaterasu.config.garden.services; + # build {"3000" = ["pds" "kittr"]; "0" = [ ... ]; ...} in a single pass. - portsToServices = foldlAttrs ( - acc: name: srv: - let - port = toString (srv.port or 0); - in - acc // { ${port} = (acc.${port} or [ ]) ++ [ name ]; } - ) { } self.nixosConfigurations.amaterasu.config.garden.services; + portsToServices = groupBy (name: toString (services.${name}.port or 0)) (attrNames services); # "0" is the catch all for services that don't bind a port; we will drop it # before checking for collisions. diff --git a/modules/flake/lib/helpers.nix b/modules/flake/lib/helpers.nix index 4182215e..b963b2ac 100644 --- a/modules/flake/lib/helpers.nix +++ b/modules/flake/lib/helpers.nix @@ -122,7 +122,7 @@ let } ``` */ - mkPubs = host: keys: lib.foldl' (acc: key: acc // mkPub host key) { } keys; + mkPubs = host: keys: lib.attrsets.mergeAttrsList (map (mkPub host) keys); in { inherit -- 2.51.2