From 5c552b62fc1b45e614b86bb93c7b6ef4f14bff18 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 12 Feb 2025 14:53:04 +0100 Subject: [PATCH] lockFlake(): When refetching a locked flake, use the locked ref Otherwise we may accidentally update a lock when we shouldn't. Fixes #12445. --- src/libflake/flake/flake.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libflake/flake/flake.cc b/src/libflake/flake/flake.cc index 717848ee17d..443ad9a2a9b 100644 --- a/src/libflake/flake/flake.cc +++ b/src/libflake/flake/flake.cc @@ -625,12 +625,12 @@ LockedFlake lockFlake( /* Get the input flake, resolve 'path:./...' flakerefs relative to the parent flake. */ - auto getInputFlake = [&]() + auto getInputFlake = [&](const FlakeRef & ref) { if (auto resolvedPath = resolveRelativePath()) { - return readFlake(state, *input.ref, *input.ref, *input.ref, *resolvedPath, inputAttrPath); + return readFlake(state, ref, ref, ref, *resolvedPath, inputAttrPath); } else { - return getFlake(state, *input.ref, useRegistries, flakeCache, inputAttrPath); + return getFlake(state, ref, useRegistries, flakeCache, inputAttrPath); } }; @@ -711,7 +711,7 @@ LockedFlake lockFlake( } if (mustRefetch) { - auto inputFlake = getInputFlake(); + auto inputFlake = getInputFlake(oldLock->lockedRef); nodePaths.emplace(childNode, inputFlake.path.parent()); computeLocks(inputFlake.inputs, childNode, inputAttrPath, oldLock, followsPrefix, inputFlake.path, false); @@ -739,7 +739,7 @@ LockedFlake lockFlake( auto ref = (input2.ref && explicitCliOverrides.contains(inputAttrPath)) ? *input2.ref : *input.ref; if (input.isFlake) { - auto inputFlake = getInputFlake(); + auto inputFlake = getInputFlake(*input.ref); auto childNode = make_ref( inputFlake.lockedRef,