Skip to content

Commit 5c552b6

Browse files
committed
lockFlake(): When refetching a locked flake, use the locked ref
Otherwise we may accidentally update a lock when we shouldn't. Fixes #12445.
1 parent ca7e686 commit 5c552b6

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/libflake/flake/flake.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -625,12 +625,12 @@ LockedFlake lockFlake(
625625

626626
/* Get the input flake, resolve 'path:./...'
627627
flakerefs relative to the parent flake. */
628-
auto getInputFlake = [&]()
628+
auto getInputFlake = [&](const FlakeRef & ref)
629629
{
630630
if (auto resolvedPath = resolveRelativePath()) {
631-
return readFlake(state, *input.ref, *input.ref, *input.ref, *resolvedPath, inputAttrPath);
631+
return readFlake(state, ref, ref, ref, *resolvedPath, inputAttrPath);
632632
} else {
633-
return getFlake(state, *input.ref, useRegistries, flakeCache, inputAttrPath);
633+
return getFlake(state, ref, useRegistries, flakeCache, inputAttrPath);
634634
}
635635
};
636636

@@ -711,7 +711,7 @@ LockedFlake lockFlake(
711711
}
712712

713713
if (mustRefetch) {
714-
auto inputFlake = getInputFlake();
714+
auto inputFlake = getInputFlake(oldLock->lockedRef);
715715
nodePaths.emplace(childNode, inputFlake.path.parent());
716716
computeLocks(inputFlake.inputs, childNode, inputAttrPath, oldLock, followsPrefix,
717717
inputFlake.path, false);
@@ -739,7 +739,7 @@ LockedFlake lockFlake(
739739
auto ref = (input2.ref && explicitCliOverrides.contains(inputAttrPath)) ? *input2.ref : *input.ref;
740740

741741
if (input.isFlake) {
742-
auto inputFlake = getInputFlake();
742+
auto inputFlake = getInputFlake(*input.ref);
743743

744744
auto childNode = make_ref<LockedNode>(
745745
inputFlake.lockedRef,

0 commit comments

Comments
 (0)