mirror of
https://github.com/NixOS/nix.git
synced 2025-12-03 15:40:59 +01:00
Support fixed-output derivations depending on impure derivations
This commit is contained in:
parent
5cd72598fe
commit
18935e8b9f
4 changed files with 48 additions and 9 deletions
|
|
@ -7,6 +7,7 @@ rec {
|
|||
outputs = [ "out" "stuff" ];
|
||||
buildCommand =
|
||||
''
|
||||
echo impure
|
||||
x=$(< $TEST_ROOT/counter)
|
||||
mkdir $out $stuff
|
||||
echo $x > $out/n
|
||||
|
|
@ -23,6 +24,7 @@ rec {
|
|||
name = "impure-on-impure";
|
||||
buildCommand =
|
||||
''
|
||||
echo impure-on-impure
|
||||
x=$(< ${impure}/n)
|
||||
mkdir $out
|
||||
printf X$x > $out/n
|
||||
|
|
@ -43,4 +45,24 @@ rec {
|
|||
'';
|
||||
};
|
||||
|
||||
contentAddressed = mkDerivation {
|
||||
name = "content-addressed";
|
||||
buildCommand =
|
||||
''
|
||||
echo content-addressed
|
||||
x=$(< ${impureOnImpure}/n)
|
||||
printf ''${x:0:1} > $out
|
||||
'';
|
||||
outputHashAlgo = "sha256";
|
||||
outputHashMode = "recursive";
|
||||
outputHash = "sha256-eBYxcgkuWuiqs4cKNgKwkb3vY/HR0vVsJnqe8itJGcQ=";
|
||||
};
|
||||
|
||||
inputAddressedAfterCA = mkDerivation {
|
||||
name = "input-addressed-after-ca";
|
||||
buildCommand =
|
||||
''
|
||||
cat ${contentAddressed} > $out
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,10 +21,10 @@ path2=$(nix build -L --no-link --json --file ./impure-derivations.nix impure | j
|
|||
[[ $(< $path2/n) = 1 ]]
|
||||
|
||||
# Test impure derivations that depend on impure derivations.
|
||||
path3=$(nix build -L --no-link --json --file ./impure-derivations.nix impureOnImpure -vvvvv | jq -r .[].outputs.out)
|
||||
path3=$(nix build -L --no-link --json --file ./impure-derivations.nix impureOnImpure | jq -r .[].outputs.out)
|
||||
[[ $(< $path3/n) = X2 ]]
|
||||
|
||||
path4=$(nix build -L --no-link --json --file ./impure-derivations.nix impureOnImpure -vvvvv | jq -r .[].outputs.out)
|
||||
path4=$(nix build -L --no-link --json --file ./impure-derivations.nix impureOnImpure | jq -r .[].outputs.out)
|
||||
[[ $(< $path4/n) = X3 ]]
|
||||
|
||||
# Test that (self-)references work.
|
||||
|
|
@ -37,3 +37,18 @@ nix build -L --no-link --json --file ./impure-derivations.nix inputAddressed 2>&
|
|||
drvPath=$(nix eval --json --file ./impure-derivations.nix impure.drvPath | jq -r .)
|
||||
[[ $(nix show-derivation $drvPath | jq ".[\"$drvPath\"].outputs.out.impure") = true ]]
|
||||
[[ $(nix show-derivation $drvPath | jq ".[\"$drvPath\"].outputs.stuff.impure") = true ]]
|
||||
|
||||
# Fixed-output derivations *can* depend on impure derivations.
|
||||
path5=$(nix build -L --no-link --json --file ./impure-derivations.nix contentAddressed | jq -r .[].outputs.out)
|
||||
[[ $(< $path5) = X ]]
|
||||
[[ $(< $TEST_ROOT/counter) = 5 ]]
|
||||
|
||||
# And they should not be rebuilt.
|
||||
path5=$(nix build -L --no-link --json --file ./impure-derivations.nix contentAddressed | jq -r .[].outputs.out)
|
||||
[[ $(< $path5) = X ]]
|
||||
[[ $(< $TEST_ROOT/counter) = 5 ]]
|
||||
|
||||
# Input-addressed derivations can depend on fixed-output derivations that depend on impure derivations.
|
||||
path6=$(nix build -L --no-link --json --file ./impure-derivations.nix inputAddressedAfterCA | jq -r .[].outputs.out)
|
||||
[[ $(< $path6) = X ]]
|
||||
[[ $(< $TEST_ROOT/counter) = 5 ]]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue