aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2021-12-02 13:17:50 +0100
committerGitHub <noreply@github.com>2021-12-02 13:17:50 +0100
commit2ff71b021379a2c9bbdcb789a93cdc585b3520ca (patch)
tree02afc101b0e6fabc5bc039f0df475b43a2ba18bc
parent77b3e4b4ee49c5860c62553930fe1dd81004a7d9 (diff)
parent8cbf862e6f6e8250d59491fdb88dfc11a805a970 (diff)
Merge pull request #5713 from tweag/balsoft/another-follows-bugfix
Flakes: computeLocks: pass correct LockParent when reusing oldLock
-rw-r--r--src/libexpr/flake/flake.cc7
-rw-r--r--tests/flakes.sh12
2 files changed, 18 insertions, 1 deletions
diff --git a/src/libexpr/flake/flake.cc b/src/libexpr/flake/flake.cc
index 06136579e..33d253eee 100644
--- a/src/libexpr/flake/flake.cc
+++ b/src/libexpr/flake/flake.cc
@@ -480,11 +480,16 @@ LockedFlake lockFlake(
}
}
+ LockParent newParent {
+ .path = inputPath,
+ .absolute = false
+ };
+
computeLocks(
mustRefetch
? getFlake(state, oldLock->lockedRef, false, flakeCache).inputs
: fakeInputs,
- childNode, inputPath, oldLock, parent, parentPath);
+ childNode, inputPath, oldLock, newParent, parentPath);
} else {
/* We need to create a new lock file entry. So fetch
diff --git a/tests/flakes.sh b/tests/flakes.sh
index 9e10322b9..20966ab2a 100644
--- a/tests/flakes.sh
+++ b/tests/flakes.sh
@@ -722,6 +722,7 @@ cat > $flakeFollowsB/flake.nix <<EOF
inputs = {
foobar.url = "path:$flakeFollowsA/flakeE";
nonFlake.url = "path:$nonFlakeDir";
+ goodoo.follows = "C/goodoo";
C = {
url = "path:./flakeC";
inputs.foobar.follows = "foobar";
@@ -736,6 +737,7 @@ cat > $flakeFollowsC/flake.nix <<EOF
description = "Flake C";
inputs = {
foobar.url = "path:$flakeFollowsA/flakeE";
+ goodoo.follows = "foobar";
};
outputs = { ... }: {};
}
@@ -760,8 +762,18 @@ EOF
git -C $flakeFollowsA add flake.nix flakeB/flake.nix \
flakeB/flakeC/flake.nix flakeD/flake.nix flakeE/flake.nix
+nix flake update $flakeFollowsA
+
+oldLock="$(cat "$flakeFollowsA/flake.lock")"
+
+# Ensure that locking twice doesn't change anything
+
nix flake lock $flakeFollowsA
+newLock="$(cat "$flakeFollowsA/flake.lock")"
+
+diff <(echo "$newLock") <(echo "$oldLock")
+
[[ $(jq -c .nodes.B.inputs.C $flakeFollowsA/flake.lock) = '"C"' ]]
[[ $(jq -c .nodes.B.inputs.foobar $flakeFollowsA/flake.lock) = '["D"]' ]]
[[ $(jq -c .nodes.C.inputs.foobar $flakeFollowsA/flake.lock) = '["B","foobar"]' ]]