os/lib/lists.nix

20 lines
533 B
Nix
Raw Normal View History

{ lib }:
{
collectProfiles = set:
let
collectNestedProfiles = set:
2021-05-02 00:49:04 +00:00
lib.mapAttrsToList
(n: v:
if builtins.isAttrs v then
[ v.default or null ] ++ collectNestedProfiles v
else null
)
set;
in
2021-05-02 00:49:04 +00:00
builtins.filter (x: x != null) (lib.flatten (collectNestedProfiles set));
2021-05-02 00:49:04 +00:00
profileMap = list: map (profile: profile.default) (lib.flatten list);
unifyOverlays = channels: map (o: if builtins.isFunction (o null null) then o channels else o);
}