diff options
author | Mathijs Kwik <mathijs@bluescreen303.nl> | 2018-06-06 22:38:40 +0200 |
---|---|---|
committer | Profpatsch <mail@profpatsch.de> | 2018-08-15 17:16:56 +0200 |
commit | b63ec6452156ee46e8e5bbf360e122b4083dfa77 (patch) | |
tree | 9d381f88ed8e37e49df0d19b72c3b6297021e76a /lib/attrsets.nix | |
parent | b1cf86b8bb9eded693cd8eb547c2bc9709d0becd (diff) | |
download | nixpkgs-b63ec6452156ee46e8e5bbf360e122b4083dfa77.tar nixpkgs-b63ec6452156ee46e8e5bbf360e122b4083dfa77.tar.gz nixpkgs-b63ec6452156ee46e8e5bbf360e122b4083dfa77.tar.bz2 nixpkgs-b63ec6452156ee46e8e5bbf360e122b4083dfa77.tar.lz nixpkgs-b63ec6452156ee46e8e5bbf360e122b4083dfa77.tar.xz nixpkgs-b63ec6452156ee46e8e5bbf360e122b4083dfa77.tar.zst nixpkgs-b63ec6452156ee46e8e5bbf360e122b4083dfa77.zip |
lib/recursiveUpdateUntil: fix code to match documentation
$ nix repl lib Welcome to Nix version 2.0.2. Type :? for help. Loading 'lib'... Added 350 variables. -- this is the exact example from the function's documentation: nix-repl> recursiveUpdateUntil (path: l: r: path == ["foo"]) { # first attribute set foo.bar = 1; foo.baz = 2; bar = 3; } { #second attribute set foo.bar = 1; foo.quz = 2; baz = 4; } { bar = 3; baz = 4; foo = { bar = 1; baz = 2; quz = 2; }; } -- although the documentation says: { foo.bar = 1; # 'foo.*' from the second set foo.quz = 2; # bar = 3; # 'bar' from the first set baz = 4; # 'baz' from the second set }
Diffstat (limited to 'lib/attrsets.nix')
-rw-r--r-- | lib/attrsets.nix | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/attrsets.nix b/lib/attrsets.nix index 0066fba362a..cda13ee43ee 100644 --- a/lib/attrsets.nix +++ b/lib/attrsets.nix @@ -384,11 +384,12 @@ rec { recursiveUpdateUntil = pred: lhs: rhs: let f = attrPath: zipAttrsWith (n: values: + let here = attrPath ++ [n]; in if tail values == [] - || pred attrPath (head (tail values)) (head values) then + || pred here (head (tail values)) (head values) then head values else - f (attrPath ++ [n]) values + f here values ); in f [] [rhs lhs]; |