diff --git a/flake.lock b/flake.lock index 0f3b3eb9..1c95e54a 100644 --- a/flake.lock +++ b/flake.lock @@ -81,7 +81,7 @@ "utils": "utils_2" }, "locked": { - "narHash": "sha256-IvKVn4U3Ts2aw8JoKvBCte6Z77JynuNob8LClmsopFo=", + "narHash": "sha256-t14TKUtw83dZ2mbqjRpeUvdAx4zpe/ySr5KhPhB1JMU=", "path": "./lib", "type": "path" }, diff --git a/lib/devos/mkSuites.nix b/lib/devos/mkSuites.nix index cb736793..66a36ea1 100644 --- a/lib/devos/mkSuites.nix +++ b/lib/devos/mkSuites.nix @@ -8,13 +8,9 @@ let inherit (args) users profiles userProfiles; }; - allProfiles = - let defaults = lib.collect (x: x ? default) profiles; - in map (x: x.default) defaults; + allProfiles = lib.collectProfiles profiles; - allUsers = - let defaults = lib.collect (x: x ? default) users; - in map (x: x.default) defaults; + allUsers = lib.collectProfiles users; createSuites = _: suites: lib.mapAttrs (_: v: os.profileMap v) suites // { inherit allProfiles allUsers; diff --git a/lib/flake.nix b/lib/flake.nix index 8e6063ce..15d87197 100644 --- a/lib/flake.nix +++ b/lib/flake.nix @@ -50,7 +50,7 @@ pathsToImportedAttrs concatAttrs filterPackages; - inherit (lists) pathsIn; + inherit (lists) pathsIn collectProfiles; inherit (strings) rgxToString; inherit modules; } diff --git a/lib/lists.nix b/lib/lists.nix index 18620412..c20a4d7b 100644 --- a/lib/lists.nix +++ b/lib/lists.nix @@ -1,5 +1,16 @@ { lib }: { + collectProfiles = set: + let + collectNestedProfiles = set: + lib.mapAttrsToList (n: v: + if builtins.isAttrs v then + [ v.default or null ] ++ collectNestedProfiles v + else null + ) set; + in + builtins.filter (x: x != null) (lib.flatten (collectNestedProfiles set)); + pathsIn = dir: let fullPath = name: "${toString dir}/${name}";