diff options
Diffstat (limited to 'lib/attrsets.nix')
-rw-r--r-- | lib/attrsets.nix | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/attrsets.nix b/lib/attrsets.nix index bf6c90bf1be60..107570627c66a 100644 --- a/lib/attrsets.nix +++ b/lib/attrsets.nix @@ -58,13 +58,17 @@ rec { attrPath: # The nested attribute set to check e: - let attr = head attrPath; + let + lenAttrPath = length attrPath; + hasAttrByPath' = n: s: let + attr = elemAt attrPath n; + in ( + if n == lenAttrPath then true + else if s ? ${attr} then hasAttrByPath' (n + 1) s.${attr} + else false + ); in - if attrPath == [] then true - else if e ? ${attr} - then hasAttrByPath (tail attrPath) e.${attr} - else false; - + hasAttrByPath' 0 e; /* Create a new attribute set with `value` set at the nested attribute location specified in `attrPath`. |