diff options
author | tomberek <tomberek@users.noreply.github.com> | 2023-08-25 10:33:05 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-25 10:33:05 -0400 |
commit | b563ef38cca8f247a21b86c157feabcf94d66c09 (patch) | |
tree | 00b71e8dbcb7f431558affebf3c2eed29ad1d5d3 /tests | |
parent | dd9f816b29560af728928ea74898203f3efa3fd8 (diff) | |
parent | 75243c96937b472665b94729df81f8296b262085 (diff) |
Merge pull request #8819 from VertexA115/fix/deep-follow-paths
Fix follow path checking at depths greater than 2
Diffstat (limited to 'tests')
-rw-r--r-- | tests/flakes/follow-paths.sh | 86 |
1 files changed, 84 insertions, 2 deletions
diff --git a/tests/flakes/follow-paths.sh b/tests/flakes/follow-paths.sh index fe9b51c65..dc97027ac 100644 --- a/tests/flakes/follow-paths.sh +++ b/tests/flakes/follow-paths.sh @@ -146,5 +146,87 @@ EOF git -C $flakeFollowsA add flake.nix -nix flake lock $flakeFollowsA 2>&1 | grep "warning: input 'B' has an override for a non-existent input 'invalid'" -nix flake lock $flakeFollowsA 2>&1 | grep "warning: input 'B' has an override for a non-existent input 'invalid2'" +nix flake lock "$flakeFollowsA" 2>&1 | grep "warning: input 'B' has an override for a non-existent input 'invalid'" +nix flake lock "$flakeFollowsA" 2>&1 | grep "warning: input 'B' has an override for a non-existent input 'invalid2'" + +# Now test follow path overloading +# This tests a lockfile checking regression https://github.com/NixOS/nix/pull/8819 +# +# We construct the following graph, where p->q means p has input q. +# A double edge means that the edge gets overridden using `follows`. +# +# A +# / \ +# / \ +# v v +# B ==> C --- follows declared in A +# \\ / +# \\/ --- follows declared in B +# v +# D +# +# The message was +# error: input 'B/D' follows a non-existent input 'B/C/D' +# +# Note that for `B` to resolve its follow for `D`, it needs `C/D`, for which it needs to resolve the follow on `C` first. +flakeFollowsOverloadA="$TEST_ROOT/follows/overload/flakeA" +flakeFollowsOverloadB="$TEST_ROOT/follows/overload/flakeA/flakeB" +flakeFollowsOverloadC="$TEST_ROOT/follows/overload/flakeA/flakeB/flakeC" +flakeFollowsOverloadD="$TEST_ROOT/follows/overload/flakeA/flakeB/flakeC/flakeD" + +# Test following path flakerefs. +createGitRepo "$flakeFollowsOverloadA" +mkdir -p "$flakeFollowsOverloadB" +mkdir -p "$flakeFollowsOverloadC" +mkdir -p "$flakeFollowsOverloadD" + +cat > "$flakeFollowsOverloadD/flake.nix" <<EOF +{ + description = "Flake D"; + inputs = {}; + outputs = { ... }: {}; +} +EOF + +cat > "$flakeFollowsOverloadC/flake.nix" <<EOF +{ + description = "Flake C"; + inputs.D.url = "path:./flakeD"; + outputs = { ... }: {}; +} +EOF + +cat > "$flakeFollowsOverloadB/flake.nix" <<EOF +{ + description = "Flake B"; + inputs = { + C = { + url = "path:./flakeC"; + }; + D.follows = "C/D"; + }; + outputs = { ... }: {}; +} +EOF + +# input B/D should be able to be found... +cat > "$flakeFollowsOverloadA/flake.nix" <<EOF +{ + description = "Flake A"; + inputs = { + B = { + url = "path:./flakeB"; + inputs.C.follows = "C"; + }; + C.url = "path:./flakeB/flakeC"; + }; + outputs = { ... }: {}; +} +EOF + +git -C "$flakeFollowsOverloadA" add flake.nix flakeB/flake.nix \ + flakeB/flakeC/flake.nix flakeB/flakeC/flakeD/flake.nix + +nix flake metadata "$flakeFollowsOverloadA" +nix flake update "$flakeFollowsOverloadA" +nix flake lock "$flakeFollowsOverloadA" |