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"
|
"utils": "utils_2"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"narHash": "sha256-IvKVn4U3Ts2aw8JoKvBCte6Z77JynuNob8LClmsopFo=",
|
"narHash": "sha256-t14TKUtw83dZ2mbqjRpeUvdAx4zpe/ySr5KhPhB1JMU=",
|
||||||
"path": "./lib",
|
"path": "./lib",
|
||||||
"type": "path"
|
"type": "path"
|
||||||
},
|
},
|
||||||
|
|
|
@ -8,13 +8,9 @@ let
|
||||||
inherit (args) users profiles userProfiles;
|
inherit (args) users profiles userProfiles;
|
||||||
};
|
};
|
||||||
|
|
||||||
allProfiles =
|
allProfiles = lib.collectProfiles profiles;
|
||||||
let defaults = lib.collect (x: x ? default) profiles;
|
|
||||||
in map (x: x.default) defaults;
|
|
||||||
|
|
||||||
allUsers =
|
allUsers = lib.collectProfiles users;
|
||||||
let defaults = lib.collect (x: x ? default) users;
|
|
||||||
in map (x: x.default) defaults;
|
|
||||||
|
|
||||||
createSuites = _: suites: lib.mapAttrs (_: v: os.profileMap v) suites // {
|
createSuites = _: suites: lib.mapAttrs (_: v: os.profileMap v) suites // {
|
||||||
inherit allProfiles allUsers;
|
inherit allProfiles allUsers;
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
pathsToImportedAttrs
|
pathsToImportedAttrs
|
||||||
concatAttrs
|
concatAttrs
|
||||||
filterPackages;
|
filterPackages;
|
||||||
inherit (lists) pathsIn;
|
inherit (lists) pathsIn collectProfiles;
|
||||||
inherit (strings) rgxToString;
|
inherit (strings) rgxToString;
|
||||||
inherit modules;
|
inherit modules;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,16 @@
|
||||||
{ lib }:
|
{ 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:
|
pathsIn = dir:
|
||||||
let
|
let
|
||||||
fullPath = name: "${toString dir}/${name}";
|
fullPath = name: "${toString dir}/${name}";
|
||||||
|
|
Loading…
Reference in a new issue