diff options
author | Alexander Bantyev <balsoft@balsoft.ru> | 2021-11-10 14:56:22 +0300 |
---|---|---|
committer | Alexander Bantyev <balsoft@balsoft.ru> | 2021-11-11 12:05:18 +0300 |
commit | 07bffe799853ef5e2757b9892e4e3dac89bfccbb (patch) | |
tree | dd018691cea9213888a7e45438f6c350bba95920 /tests/flakes.sh | |
parent | 52a3b2ee6367306a3f17fe9a2d0e2e4096852e05 (diff) |
Flakes: refetch the input when a follows disappears
When an input follows disappears, we can't just reuse the old lock
file entries since we may be missing some required ones. Refetch the
input when this happens.
Closes https://github.com/NixOS/nix/issues/5289
Diffstat (limited to 'tests/flakes.sh')
-rw-r--r-- | tests/flakes.sh | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/tests/flakes.sh b/tests/flakes.sh index 57d1b9aad..9e10322b9 100644 --- a/tests/flakes.sh +++ b/tests/flakes.sh @@ -707,10 +707,10 @@ cat > $flakeFollowsA/flake.nix <<EOF B = { url = "path:./flakeB"; inputs.foobar.follows = "D"; + inputs.nonFlake.follows = "D"; }; D.url = "path:./flakeD"; - foobar.url = "path:./flakeE"; }; outputs = { ... }: {}; } @@ -720,7 +720,8 @@ cat > $flakeFollowsB/flake.nix <<EOF { description = "Flake B"; inputs = { - foobar.url = "path:./../flakeE"; + foobar.url = "path:$flakeFollowsA/flakeE"; + nonFlake.url = "path:$nonFlakeDir"; C = { url = "path:./flakeC"; inputs.foobar.follows = "foobar"; @@ -734,7 +735,7 @@ cat > $flakeFollowsC/flake.nix <<EOF { description = "Flake C"; inputs = { - foobar.url = "path:./../../flakeE"; + foobar.url = "path:$flakeFollowsA/flakeE"; }; outputs = { ... }: {}; } @@ -765,6 +766,27 @@ nix flake lock $flakeFollowsA [[ $(jq -c .nodes.B.inputs.foobar $flakeFollowsA/flake.lock) = '["D"]' ]] [[ $(jq -c .nodes.C.inputs.foobar $flakeFollowsA/flake.lock) = '["B","foobar"]' ]] +# Ensure removing follows from flake.nix removes them from the lockfile + +cat > $flakeFollowsA/flake.nix <<EOF +{ + description = "Flake A"; + inputs = { + B = { + url = "path:./flakeB"; + inputs.nonFlake.follows = "D"; + }; + D.url = "path:./flakeD"; + }; + outputs = { ... }: {}; +} +EOF + +nix flake lock $flakeFollowsA + +[[ $(jq -c .nodes.B.inputs.foobar $flakeFollowsA/flake.lock) = '"foobar"' ]] +jq -r -c '.nodes | keys | .[]' $flakeFollowsA/flake.lock | grep "^foobar$" + # Ensure a relative path is not allowed to go outside the store path cat > $flakeFollowsA/flake.nix <<EOF { |