From dffcc184d7ab8a39085015181e7e693b0de5433a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 12 Feb 2025 14:53:04 +0100 Subject: [PATCH 1/2] lockFlake(): When refetching a locked flake, use the locked ref Otherwise we may accidentally update a lock when we shouldn't. Fixes #12445. (cherry picked from commit 5c552b62fc1b45e614b86bb93c7b6ef4f14bff18) # Conflicts: # src/libflake/flake/flake.cc --- src/libflake/flake/flake.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/libflake/flake/flake.cc b/src/libflake/flake/flake.cc index 06260c67a5d..5827668a2c5 100644 --- a/src/libflake/flake/flake.cc +++ b/src/libflake/flake/flake.cc @@ -554,12 +554,18 @@ 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()) { +<<<<<<< HEAD return readFlake(state, *input.ref, *input.ref, *input.ref, *resolvedPath, inputPath); } else { return getFlake(state, *input.ref, useRegistries, flakeCache, inputPath); +======= + return readFlake(state, ref, ref, ref, *resolvedPath, inputAttrPath); + } else { + return getFlake(state, ref, useRegistries, flakeCache, inputAttrPath); +>>>>>>> 5c552b62f (lockFlake(): When refetching a locked flake, use the locked ref) } }; @@ -640,7 +646,7 @@ LockedFlake lockFlake( } if (mustRefetch) { - auto inputFlake = getInputFlake(); + auto inputFlake = getInputFlake(oldLock->lockedRef); nodePaths.emplace(childNode, inputFlake.path.parent()); computeLocks(inputFlake.inputs, childNode, inputPath, oldLock, followsPrefix, inputFlake.path, false); @@ -668,7 +674,7 @@ LockedFlake lockFlake( auto ref = (input2.ref && explicitCliOverrides.contains(inputPath)) ? *input2.ref : *input.ref; if (input.isFlake) { - auto inputFlake = getInputFlake(); + auto inputFlake = getInputFlake(*input.ref); auto childNode = make_ref( inputFlake.lockedRef, From 0ff190107f2de65247b8f2c2f7c7995737c72e16 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 12 Feb 2025 16:54:48 +0100 Subject: [PATCH 2/2] Resolve merge conflict --- src/libflake/flake/flake.cc | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/libflake/flake/flake.cc b/src/libflake/flake/flake.cc index 5827668a2c5..507bef769b1 100644 --- a/src/libflake/flake/flake.cc +++ b/src/libflake/flake/flake.cc @@ -557,15 +557,9 @@ LockedFlake lockFlake( auto getInputFlake = [&](const FlakeRef & ref) { if (auto resolvedPath = resolveRelativePath()) { -<<<<<<< HEAD - return readFlake(state, *input.ref, *input.ref, *input.ref, *resolvedPath, inputPath); + return readFlake(state, ref, ref, ref, *resolvedPath, inputPath); } else { - return getFlake(state, *input.ref, useRegistries, flakeCache, inputPath); -======= - return readFlake(state, ref, ref, ref, *resolvedPath, inputAttrPath); - } else { - return getFlake(state, ref, useRegistries, flakeCache, inputAttrPath); ->>>>>>> 5c552b62f (lockFlake(): When refetching a locked flake, use the locked ref) + return getFlake(state, ref, useRegistries, flakeCache, inputPath); } };