diff options
Diffstat (limited to 'pkgs/lib/attrsets.nix')
-rw-r--r-- | pkgs/lib/attrsets.nix | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/pkgs/lib/attrsets.nix b/pkgs/lib/attrsets.nix index 201fb91bd00..a394ff5bd18 100644 --- a/pkgs/lib/attrsets.nix +++ b/pkgs/lib/attrsets.nix @@ -1,6 +1,9 @@ # Operations on attribute sets. -with { inherit (builtins) head tail; }; +with { + inherit (builtins) head tail; + inherit (import ./default.nix) fold; +}; rec { inherit (builtins) attrNames listToAttrs hasAttr isAttrs; @@ -18,5 +21,14 @@ rec { then getAttr (tail attrPath) default (builtins.getAttr attr e) else default; + # ordered by name + attrValues = attrs: attrVals (__attrNames attrs) attrs; + + attrVals = nameList : attrSet : + map (x: builtins.getAttr x attrSet) nameList; + + # iterates over a list of attributes collecting the attribute attr if it exists + catAttrs = attr : l : fold ( s : l : if (hasAttr attr s) then [(builtins.getAttr attr s)] ++ l else l) [] l; + } \ No newline at end of file |