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
}
commitb63ec6452156ee46e8e5bbf360e122b4083dfa77
authorMathijs Kwik <mathijs@bluescreen303.nl>
dateWed 6 Jun 2018, 22:38 (8 years ago)
parentb1cf86b
lib/attrsets.nix+3−2
@@ -384,11 +384,12 @@ rec {
384384 recursiveUpdateUntil = pred: lhs: rhs:
385385 let f = attrPath:
386386 zipAttrsWith (n: values:
387+ let here = attrPath ++ [n]; in
387388 if tail values == []
388− || pred attrPath (head (tail values)) (head values) then
389+ || pred here (head (tail values)) (head values) then
389390 head values
390391 else
391− f (attrPath ++ [n]) values
392+ f here values
392393 );
393394 in f [] [rhs lhs];
394395