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

tests/functional/flakes/non-flake-inputs: Test non-flake inputs having sourceInfo

This commit is contained in:
Matt Sturgeon 2025-05-18 00:18:46 +01:00
parent eaee0b4740
commit 72232bc28a
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299

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"