@ -3,9 +3,9 @@
let
inherit ( builtins ) head tail length ;
inherit ( lib . trivial ) an d;
inherit ( lib . trivial ) i d;
inherit ( lib . strings ) concatStringsSep sanitizeDerivationName ;
inherit ( lib . lists ) foldr foldl' concatMap concatLists elemAt ;
inherit ( lib . lists ) foldr foldl' concatMap concatLists elemAt all ;
in
rec {
@ -73,9 +73,9 @@ rec {
getAttrFromPath [ " z " " z " ] x
= > error : cannot find attribute ` z . z'
* /
getAttrFromPath = attrPath : set :
getAttrFromPath = attrPath :
let errorMsg = " c a n n o t f i n d a t t r i b u t e ` " + concatStringsSep " . " attrPath + " ' " ;
in attrByPath attrPath ( abort errorMsg ) set ;
in attrByPath attrPath ( abort errorMsg ) ;
/* R e t u r n t h e s p e c i f i e d a t t r i b u t e s f r o m a s e t .
@ -154,12 +154,12 @@ rec {
foldAttrs ( n : a : [ n ] ++ a ) [ ] [ { a = 2 ; } { a = 3 ; } ]
= > { a = [ 2 3 ] ; }
* /
foldAttrs = op : nul : list_of_attrs :
foldAttrs = op : nul :
foldr ( n : a :
foldr ( name : o :
o // { ${ name } = op n . ${ name } ( a . ${ name } or nul ) ; }
) a ( attrNames n )
) { } list_of_attrs ;
) { } ;
/* R e c u r s i v e l y c o l l e c t s e t s t h a t v e r i f y a g i v e n p r e d i c a t e n a m e d ` p r e d '
@ -295,14 +295,14 @@ rec {
* /
mapAttrsRecursiveCond = cond : f : set :
let
recurse = path : set :
recurse = path :
let
g =
name : value :
if isAttrs value && cond value
then recurse ( path ++ [ name ] ) value
else f ( path ++ [ name ] ) value ;
in mapAttrs g set ;
in mapAttrs g ;
in recurse [ ] set ;
@ -455,8 +455,8 @@ rec {
= > true
* /
matchAttrs = pattern : attrs : assert isAttrs pattern ;
foldr and true ( attrValues ( zipAttrsWithNames ( attrNames pattern ) ( n : values :
let pat = head values ; val = head ( tail values ) ; in
all id ( attrValues ( zipAttrsWithNames ( attrNames pattern ) ( n : values :
let pat = head values ; val = elemAt values 1 ; in
if length values == 1 then false
else if isAttrs pat then isAttrs val && matchAttrs pat val
else pat == val