From 6e7f252ea6568d4b151e4a7003cb4cffae26e493 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 3 Apr 2020 14:06:29 +0200 Subject: [PATCH] Make --override-input sticky When we do something like 'nix flake update --override-input nixpkgs ...', the override is now kept on subsequent calls. (If you don't want this behaviour, you can use --no-write-lock-file.) --- src/libexpr/flake/flake.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libexpr/flake/flake.cc b/src/libexpr/flake/flake.cc index 313f3bdbd..f23c53a82 100644 --- a/src/libexpr/flake/flake.cc +++ b/src/libexpr/flake/flake.cc @@ -458,8 +458,15 @@ LockedFlake lockFlake( if (input.isFlake) { auto inputFlake = getFlake(state, input.ref, {}, lockFlags.useRegistries, flakeCache); + /* Note: in case of an --override-input, we use + the *original* ref (input2.ref) for the + "original" field, rather than the + override. This ensures that the override isn't + nuked the next time we update the lock + file. That is, overrides are sticky unless you + use --no-write-lock-file. */ auto childNode = std::make_shared( - inputFlake.lockedRef, inputFlake.originalRef, inputFlake.sourceInfo->info); + inputFlake.lockedRef, input2.ref, inputFlake.sourceInfo->info); node->inputs.insert_or_assign(id, childNode);