mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 15:03:28 +00:00
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 }
This commit is contained in:
parent
b1cf86b8bb
commit
b63ec64521
@ -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];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user