forked from pub-solar/os
add and use lib.collectProfiles
this function collects profiles recursively
This commit is contained in:
parent
60bfb24af1
commit
2cab5b5d2b
|
@ -81,7 +81,7 @@
|
|||
"utils": "utils_2"
|
||||
},
|
||||
"locked": {
|
||||
"narHash": "sha256-IvKVn4U3Ts2aw8JoKvBCte6Z77JynuNob8LClmsopFo=",
|
||||
"narHash": "sha256-t14TKUtw83dZ2mbqjRpeUvdAx4zpe/ySr5KhPhB1JMU=",
|
||||
"path": "./lib",
|
||||
"type": "path"
|
||||
},
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
pathsToImportedAttrs
|
||||
concatAttrs
|
||||
filterPackages;
|
||||
inherit (lists) pathsIn;
|
||||
inherit (lists) pathsIn collectProfiles;
|
||||
inherit (strings) rgxToString;
|
||||
inherit modules;
|
||||
}
|
||||
|
|
|
@ -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}";
|
||||
|
|
Loading…
Reference in a new issue