1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-24 22:11:15 +02:00

Merge pull request #13170 from MattSturgeon/fix/call-flake/rel-path

Use correct parent `outPath` for relative path inputs
This commit is contained in:
Robert Hensing 2025-05-19 14:13:54 +02:00 committed by GitHub
commit f18af849fe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 117 additions and 15 deletions

View file

@ -37,11 +37,20 @@ cat > "$flake3Dir/flake.nix" <<EOF
url = "$nonFlakeDir/README.md";
flake = false;
};
nonFlakeFile3 = {
url = "$nonFlakeDir?dir=README.md";
flake = false;
};
relativeNonFlakeFile = {
url = ./config.nix;
flake = false;
};
};
description = "Fnord";
outputs = inputs: rec {
inherit inputs;
packages.$system.xyzzy = inputs.flake2.packages.$system.bar;
packages.$system.sth = inputs.flake1.packages.$system.foo;
packages.$system.fnord =
@ -88,6 +97,43 @@ mv "$flake2Dir.tmp" "$flake2Dir"
mv "$nonFlakeDir.tmp" "$nonFlakeDir"
nix build -o "$TEST_ROOT/result" flake3#xyzzy flake3#fnord
# Check non-flake inputs have a sourceInfo and an outPath
#
# This may look redundant, but the other checks below happen in a command
# substitution subshell, so failures there will not exit this shell
nix eval --raw flake3#inputs.nonFlake.outPath
nix eval --raw flake3#inputs.nonFlake.sourceInfo.outPath
nix eval --raw flake3#inputs.nonFlakeFile.outPath
nix eval --raw flake3#inputs.nonFlakeFile.sourceInfo.outPath
nix eval --raw flake3#inputs.nonFlakeFile2.outPath
nix eval --raw flake3#inputs.nonFlakeFile2.sourceInfo.outPath
nix eval --raw flake3#inputs.nonFlakeFile3.outPath
nix eval --raw flake3#inputs.nonFlakeFile3.sourceInfo.outPath
nix eval --raw flake3#inputs.relativeNonFlakeFile.outPath
nix eval --raw flake3#inputs.relativeNonFlakeFile.sourceInfo.outPath
# Check non-flake file inputs have the expected outPaths
[[
$(nix eval --raw flake3#inputs.nonFlake.outPath) \
= $(nix eval --raw flake3#inputs.nonFlake.sourceInfo.outPath)
]]
[[
$(nix eval --raw flake3#inputs.nonFlakeFile.outPath) \
= $(nix eval --raw flake3#inputs.nonFlakeFile.sourceInfo.outPath)
]]
[[
$(nix eval --raw flake3#inputs.nonFlakeFile2.outPath) \
= $(nix eval --raw flake3#inputs.nonFlakeFile2.sourceInfo.outPath)
]]
[[
$(nix eval --raw flake3#inputs.nonFlakeFile3.outPath) \
= $(nix eval --raw flake3#inputs.nonFlakeFile3.sourceInfo.outPath)/README.md
]]
[[
$(nix eval --raw flake3#inputs.relativeNonFlakeFile.outPath) \
= $(nix eval --raw flake3#inputs.relativeNonFlakeFile.sourceInfo.outPath)/config.nix
]]
# Make branch "removeXyzzy" where flake3 doesn't have xyzzy anymore
git -C "$flake3Dir" checkout -b removeXyzzy
rm "$flake3Dir/flake.nix"

View file

@ -131,3 +131,46 @@ EOF
# would fail:
nix eval .#ok
)
# https://github.com/NixOS/nix/issues/13164
mkdir -p "$TEST_ROOT/issue-13164/nested-flake1/nested-flake2"
(
cd "$TEST_ROOT/issue-13164"
git init
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
cat >flake.nix <<EOF
{
inputs.nestedFlake1.url = "path:./nested-flake1";
outputs = { self, nestedFlake1 }: {
inherit nestedFlake1;
};
}
EOF
cat >nested-flake1/flake.nix <<EOF
{
inputs.nestedFlake2.url = "path:./nested-flake2";
outputs = { self, nestedFlake2 }: {
name = "nestedFlake1";
inherit nestedFlake2;
};
}
EOF
cat >nested-flake1/nested-flake2/flake.nix <<EOF
{
outputs = { self }: {
name = "nestedFlake2";
};
}
EOF
git add .
git commit -m "Initial commit"
# I don't understand why two calls are necessary to reproduce the issue.
nix eval --json .#nestedFlake1.nestedFlake2 --no-eval-cache
nix eval --json .#nestedFlake1.nestedFlake2 --no-eval-cache
)