mapAttrsRecursiveCond
lib.attrsets.mapAttrsRecursiveCond
Docs pulled from | This Revision | about 3 hours ago
Like mapAttrsRecursive
, but it takes an additional predicate that tells it whether to recurse into an attribute set.
If the predicate returns false, mapAttrsRecursiveCond
does not recurse, but instead applies the mapping function.
If the predicate returns true, it does recurse, and does not apply the mapping function.
Map over an leaf attributes defined by a condition
Map derivations to their name
attribute.
Derivatons are identified as attribute sets that contain { type = "derivation"; }
.
mapAttrsRecursiveCond
(as: !(as ? "type" && as.type == "derivation"))
(x: x.name)
attrs
Type
mapAttrsRecursiveCond :: (AttrSet -> Bool) -> ([String] -> a -> b) -> AttrSet -> AttrSet
Noogle detected
Implementation
The following is the current implementation of this function.
mapAttrsRecursiveCond =
cond:
f:
set:
let
recurse = path:
mapAttrs
(name: value:
if isAttrs value && cond value
then recurse (path ++ [ name ]) value
else f (path ++ [ name ]) value);
in
recurse [ ] set;