forked from lix-project/lix
Fix follow path checking at depths greater than 2
We need to recurse into the input tree to handle follows paths that trarverse multiple inputs that may or may not be follow paths themselves.
This commit is contained in:
parent
5542c1f87e
commit
1ef8008ca7
2 changed files with 64 additions and 1 deletions
|
@ -345,7 +345,7 @@ void LockFile::check()
|
|||
|
||||
for (auto & [inputPath, input] : inputs) {
|
||||
if (auto follows = std::get_if<1>(&input)) {
|
||||
if (!follows->empty() && !get(inputs, *follows))
|
||||
if (!follows->empty() && !findInput(*follows))
|
||||
throw Error("input '%s' follows a non-existent input '%s'",
|
||||
printInputPath(inputPath),
|
||||
printInputPath(*follows));
|
||||
|
|
|
@ -148,3 +148,66 @@ 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'"
|
||||
|
||||
# Now test follow path overloading
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue