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 diff --git a/pkgs/lib/misc.nix b/pkgs/lib/misc.nix index af6e8140b10..541edb1ed88 100644 --- a/pkgs/lib/misc.nix +++ b/pkgs/lib/misc.nix @@ -277,12 +277,6 @@ rec { setAttrMerge = name : default : attrs : f : setAttr attrs name (f (maybeAttr name default attrs)); - # 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; - - attrVals = nameList : attrSet : - map (x: builtins.getAttr x attrSet) nameList; - # Using f = a : b = b the result is similar to // # merge attributes with custom function handling the case that the attribute # exists in both sets