mirror of
https://github.com/NixOS/nix
synced 2025-07-07 18:31:49 +02:00
Merge remote-tracking branch 'origin/master' into lazy-trees
This commit is contained in:
commit
561440bd6d
32 changed files with 1282 additions and 433 deletions
|
@ -70,3 +70,54 @@ testNormalization () {
|
|||
}
|
||||
|
||||
testNormalization
|
||||
|
||||
# https://github.com/NixOS/nix/issues/6572
|
||||
issue_6572_independent_outputs() {
|
||||
nix build -f multiple-outputs.nix --json independent --no-link > $TEST_ROOT/independent.json
|
||||
|
||||
# Make sure that 'nix build' can build a derivation that depends on both outputs of another derivation.
|
||||
p=$(nix build -f multiple-outputs.nix use-independent --no-link --print-out-paths)
|
||||
nix-store --delete "$p" # Clean up for next test
|
||||
|
||||
# Make sure that 'nix build' tracks input-outputs correctly when a single output is already present.
|
||||
nix-store --delete "$(jq -r <$TEST_ROOT/independent.json .[0].outputs.first)"
|
||||
p=$(nix build -f multiple-outputs.nix use-independent --no-link --print-out-paths)
|
||||
cmp $p <<EOF
|
||||
first
|
||||
second
|
||||
EOF
|
||||
nix-store --delete "$p" # Clean up for next test
|
||||
|
||||
# Make sure that 'nix build' tracks input-outputs correctly when a single output is already present.
|
||||
nix-store --delete "$(jq -r <$TEST_ROOT/independent.json .[0].outputs.second)"
|
||||
p=$(nix build -f multiple-outputs.nix use-independent --no-link --print-out-paths)
|
||||
cmp $p <<EOF
|
||||
first
|
||||
second
|
||||
EOF
|
||||
nix-store --delete "$p" # Clean up for next test
|
||||
}
|
||||
issue_6572_independent_outputs
|
||||
|
||||
|
||||
# https://github.com/NixOS/nix/issues/6572
|
||||
issue_6572_dependent_outputs() {
|
||||
|
||||
nix build -f multiple-outputs.nix --json a --no-link > $TEST_ROOT/a.json
|
||||
|
||||
# # Make sure that 'nix build' can build a derivation that depends on both outputs of another derivation.
|
||||
p=$(nix build -f multiple-outputs.nix use-a --no-link --print-out-paths)
|
||||
nix-store --delete "$p" # Clean up for next test
|
||||
|
||||
# Make sure that 'nix build' tracks input-outputs correctly when a single output is already present.
|
||||
nix-store --delete "$(jq -r <$TEST_ROOT/a.json .[0].outputs.second)"
|
||||
p=$(nix build -f multiple-outputs.nix use-a --no-link --print-out-paths)
|
||||
cmp $p <<EOF
|
||||
first
|
||||
second
|
||||
EOF
|
||||
nix-store --delete "$p" # Clean up for next test
|
||||
}
|
||||
if isDaemonNewer "2.12pre0"; then
|
||||
issue_6572_dependent_outputs
|
||||
fi
|
||||
|
|
|
@ -28,6 +28,10 @@ cat <<EOF > bar/flake.nix
|
|||
};
|
||||
}
|
||||
EOF
|
||||
mkdir -p err
|
||||
cat <<EOF > err/flake.nix
|
||||
throw "error"
|
||||
EOF
|
||||
|
||||
# Test the completion of a subcommand
|
||||
[[ "$(NIX_GET_COMPLETIONS=1 nix buil)" == $'normal\nbuild\t' ]]
|
||||
|
@ -60,3 +64,5 @@ NIX_GET_COMPLETIONS=3 nix build --option allow-import-from | grep -- "allow-impo
|
|||
# Attr path completions
|
||||
[[ "$(NIX_GET_COMPLETIONS=2 nix eval ./foo\#sam)" == $'attrs\n./foo#sampleOutput\t' ]]
|
||||
[[ "$(NIX_GET_COMPLETIONS=4 nix eval --file ./foo/flake.nix outp)" == $'attrs\noutputs\t' ]]
|
||||
[[ "$(NIX_GET_COMPLETIONS=4 nix eval --file ./err/flake.nix outp 2>&1)" == $'attrs' ]]
|
||||
[[ "$(NIX_GET_COMPLETIONS=2 nix eval ./err\# 2>&1)" == $'attrs' ]]
|
||||
|
|
|
@ -2,7 +2,7 @@ source common.sh
|
|||
|
||||
requireDaemonNewerThan "2.8pre20220311"
|
||||
|
||||
enableFeatures "ca-derivations ca-references impure-derivations"
|
||||
enableFeatures "ca-derivations impure-derivations"
|
||||
restartDaemon
|
||||
|
||||
set -o pipefail
|
||||
|
|
|
@ -31,6 +31,15 @@ rec {
|
|||
helloString = "Hello, world!";
|
||||
};
|
||||
|
||||
use-a = mkDerivation {
|
||||
name = "use-a";
|
||||
inherit (a) first second;
|
||||
builder = builtins.toFile "builder.sh"
|
||||
''
|
||||
cat $first/file $second/file >$out
|
||||
'';
|
||||
};
|
||||
|
||||
b = mkDerivation {
|
||||
defaultOutput = assert a.second.helloString == "Hello, world!"; a;
|
||||
firstOutput = assert a.outputName == "first"; a.first.first;
|
||||
|
@ -87,4 +96,25 @@ rec {
|
|||
buildCommand = "mkdir $a $b $c";
|
||||
};
|
||||
|
||||
independent = mkDerivation {
|
||||
name = "multiple-outputs-independent";
|
||||
outputs = [ "first" "second" ];
|
||||
builder = builtins.toFile "builder.sh"
|
||||
''
|
||||
mkdir $first $second
|
||||
test -z $all
|
||||
echo "first" > $first/file
|
||||
echo "second" > $second/file
|
||||
'';
|
||||
};
|
||||
|
||||
use-independent = mkDerivation {
|
||||
name = "use-independent";
|
||||
inherit (a) first second;
|
||||
builder = builtins.toFile "builder.sh"
|
||||
''
|
||||
cat $first/file $second/file >$out
|
||||
'';
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
echo "$input" > $out
|
|
@ -6,14 +6,23 @@ let
|
|||
|
||||
dependent = mkDerivation {
|
||||
name = "dependent";
|
||||
builder = ./readfile-context.builder.sh;
|
||||
input = "${input}/hello";
|
||||
buildCommand = ''
|
||||
mkdir -p $out
|
||||
echo -n "$input1" > "$out/file1"
|
||||
echo -n "$input2" > "$out/file2"
|
||||
'';
|
||||
input1 = "${input}/hello";
|
||||
input2 = "hello";
|
||||
};
|
||||
|
||||
readDependent = mkDerivation {
|
||||
name = "read-dependent";
|
||||
builder = ./readfile-context.builder.sh;
|
||||
input = builtins.readFile dependent;
|
||||
# Will evaluate correctly because file2 doesn't have any references,
|
||||
# even though the `dependent` derivation does.
|
||||
name = builtins.readFile (dependent + "/file2");
|
||||
buildCommand = ''
|
||||
echo "$input" > "$out"
|
||||
'';
|
||||
input = builtins.readFile (dependent + "/file1");
|
||||
};
|
||||
|
||||
in readDependent
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue