source ./common.sh requireGit flakeFollowsA=$TEST_ROOT/follows/flakeA flakeFollowsB=$TEST_ROOT/follows/flakeA/flakeB flakeFollowsC=$TEST_ROOT/follows/flakeA/flakeB/flakeC flakeFollowsD=$TEST_ROOT/follows/flakeA/flakeD flakeFollowsE=$TEST_ROOT/follows/flakeA/flakeE # Test following path flakerefs. createGitRepo $flakeFollowsA mkdir -p $flakeFollowsB mkdir -p $flakeFollowsC mkdir -p $flakeFollowsD mkdir -p $flakeFollowsE cat > $flakeFollowsA/flake.nix < $flakeFollowsB/flake.nix < $flakeFollowsC/flake.nix < $flakeFollowsD/flake.nix < $flakeFollowsE/flake.nix < $flakeFollowsA/flake.nix < $flakeFollowsA/flake.nix <&1 | grep 'points outside' # Non-existant follows should print a warning. cat >$flakeFollowsA/flake.nix <&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" < "$flakeFollowsOverloadC/flake.nix" < "$flakeFollowsOverloadB/flake.nix" < "$flakeFollowsOverloadA/flake.nix" < baz # The message was # error: follow cycle detected: [baz -> foo -> bar -> baz] flakeFollowCycle="$TEST_ROOT/follows/followCycle" # Test following path flakerefs. mkdir -p "$flakeFollowCycle" cat > $flakeFollowCycle/flake.nix <&1 && fail "nix flake lock should have failed." || true) echo $checkRes | grep -F "error: follow cycle detected: [baz -> foo -> bar -> baz]" # Test transitive input url locking # This tests the following lockfile issue: https://github.com/NixOS/nix/issues/9143 # # We construct the following graph, where p->q means p has input q. # # A -> B -> C # # And override B/C to flake D, first in A's flake.nix and then with --override-input. # # A -> B -> D flakeFollowsCustomUrlA="$TEST_ROOT/follows/custom-url/flakeA" flakeFollowsCustomUrlB="$TEST_ROOT/follows/custom-url/flakeA/flakeB" flakeFollowsCustomUrlC="$TEST_ROOT/follows/custom-url/flakeA/flakeB/flakeC" flakeFollowsCustomUrlD="$TEST_ROOT/follows/custom-url/flakeA/flakeB/flakeD" createGitRepo "$flakeFollowsCustomUrlA" mkdir -p "$flakeFollowsCustomUrlB" mkdir -p "$flakeFollowsCustomUrlC" mkdir -p "$flakeFollowsCustomUrlD" cat > "$flakeFollowsCustomUrlD/flake.nix" < "$flakeFollowsCustomUrlC/flake.nix" < "$flakeFollowsCustomUrlB/flake.nix" < "$flakeFollowsCustomUrlA/flake.nix" <