mirror of
https://github.com/NixOS/nix
synced 2025-07-08 11:03:54 +02:00
Merge remote-tracking branch 'origin/master' into p/flake-update
This commit is contained in:
commit
c451b48993
54 changed files with 1204 additions and 508 deletions
|
@ -2,7 +2,7 @@ with import ./config.nix;
|
|||
|
||||
rec {
|
||||
|
||||
dep = import ./dependencies.nix;
|
||||
dep = import ./dependencies.nix {};
|
||||
|
||||
makeTest = nr: args: mkDerivation ({
|
||||
name = "check-refs-" + toString nr;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
{ hashInvalidator ? "" }:
|
||||
with import ./config.nix;
|
||||
|
||||
let {
|
||||
|
@ -21,6 +22,17 @@ let {
|
|||
'';
|
||||
};
|
||||
|
||||
fod_input = mkDerivation {
|
||||
name = "fod-input";
|
||||
buildCommand = ''
|
||||
echo ${hashInvalidator}
|
||||
echo FOD > $out
|
||||
'';
|
||||
outputHashMode = "flat";
|
||||
outputHashAlgo = "sha256";
|
||||
outputHash = "1dq9p0hnm1y75q2x40fws5887bq1r840hzdxak0a9djbwvx0b16d";
|
||||
};
|
||||
|
||||
body = mkDerivation {
|
||||
name = "dependencies-top";
|
||||
builder = ./dependencies.builder0.sh + "/FOOBAR/../.";
|
||||
|
@ -29,6 +41,7 @@ let {
|
|||
input1_drv = input1;
|
||||
input2_drv = input2;
|
||||
input0_drv = input0;
|
||||
fod_input_drv = fod_input;
|
||||
meta.description = "Random test package";
|
||||
};
|
||||
|
||||
|
|
|
@ -53,3 +53,20 @@ nix-store -q --referrers-closure "$input2OutPath" | grep "$outPath"
|
|||
# Check that the derivers are set properly.
|
||||
test $(nix-store -q --deriver "$outPath") = "$drvPath"
|
||||
nix-store -q --deriver "$input2OutPath" | grepQuiet -- "-input-2.drv"
|
||||
|
||||
# --valid-derivers returns the currently single valid .drv file
|
||||
test "$(nix-store -q --valid-derivers "$outPath")" = "$drvPath"
|
||||
|
||||
# instantiate a different drv with the same output
|
||||
drvPath2=$(nix-instantiate dependencies.nix --argstr hashInvalidator yay)
|
||||
|
||||
# now --valid-derivers returns both
|
||||
test "$(nix-store -q --valid-derivers "$outPath" | sort)" = "$(sort <<< "$drvPath"$'\n'"$drvPath2")"
|
||||
|
||||
# check that nix-store --valid-derivers only returns existing drv
|
||||
nix-store --delete "$drvPath"
|
||||
test "$(nix-store -q --valid-derivers "$outPath")" = "$drvPath2"
|
||||
|
||||
# check that --valid-derivers returns nothing when there are no valid derivers
|
||||
nix-store --delete "$drvPath2"
|
||||
test -z "$(nix-store -q --valid-derivers "$outPath")"
|
||||
|
|
|
@ -6,4 +6,6 @@ out1=$(nix-build ./text-hashed-output.nix -A hello --no-out-link)
|
|||
|
||||
clearStore
|
||||
|
||||
expectStderr 1 nix-build ./text-hashed-output.nix -A wrapper --no-out-link | grepQuiet "Dependencies on the outputs of dynamic derivations are not yet supported"
|
||||
out2=$(nix-build ./text-hashed-output.nix -A wrapper --no-out-link)
|
||||
|
||||
diff -r $out1 $out2
|
||||
|
|
|
@ -13,14 +13,14 @@ nix --experimental-features 'nix-command' eval --impure --expr \
|
|||
# the future so it does work, but there are some design questions to
|
||||
# resolve first. Adding a test so we don't liberalise it by accident.
|
||||
expectStderr 1 nix --experimental-features 'nix-command dynamic-derivations' eval --impure --expr \
|
||||
'builtins.outputOf (import ../dependencies.nix) "out"' \
|
||||
'builtins.outputOf (import ../dependencies.nix {}) "out"' \
|
||||
| grepQuiet "value is a set while a string was expected"
|
||||
|
||||
# Test that "DrvDeep" string contexts are not supported at this time
|
||||
#
|
||||
# Like the above, this is a restriction we could relax later.
|
||||
expectStderr 1 nix --experimental-features 'nix-command dynamic-derivations' eval --impure --expr \
|
||||
'builtins.outputOf (import ../dependencies.nix).drvPath "out"' \
|
||||
'builtins.outputOf (import ../dependencies.nix {}).drvPath "out"' \
|
||||
| grepQuiet "has a context which refers to a complete source and binary closure. This is not supported at this time"
|
||||
|
||||
# Test using `builtins.outputOf` with static derivations
|
||||
|
|
|
@ -3,7 +3,8 @@ dyn-drv-tests := \
|
|||
$(d)/recursive-mod-json.sh \
|
||||
$(d)/build-built-drv.sh \
|
||||
$(d)/eval-outputOf.sh \
|
||||
$(d)/dep-built-drv.sh
|
||||
$(d)/dep-built-drv.sh \
|
||||
$(d)/old-daemon-error-hack.sh
|
||||
|
||||
install-tests-groups += dyn-drv
|
||||
|
||||
|
|
20
tests/dyn-drv/old-daemon-error-hack.nix
Normal file
20
tests/dyn-drv/old-daemon-error-hack.nix
Normal file
|
@ -0,0 +1,20 @@
|
|||
with import ./config.nix;
|
||||
|
||||
# A simple content-addressed derivation.
|
||||
# The derivation can be arbitrarily modified by passing a different `seed`,
|
||||
# but the output will always be the same
|
||||
rec {
|
||||
stub = mkDerivation {
|
||||
name = "stub";
|
||||
buildCommand = ''
|
||||
echo stub > $out
|
||||
'';
|
||||
};
|
||||
wrapper = mkDerivation {
|
||||
name = "has-dynamic-drv-dep";
|
||||
buildCommand = ''
|
||||
exit 1 # we're not building this derivation
|
||||
${builtins.outputOf stub.outPath "out"}
|
||||
'';
|
||||
};
|
||||
}
|
11
tests/dyn-drv/old-daemon-error-hack.sh
Normal file
11
tests/dyn-drv/old-daemon-error-hack.sh
Normal file
|
@ -0,0 +1,11 @@
|
|||
# Purposely bypassing our usual common for this subgroup
|
||||
source ../common.sh
|
||||
|
||||
# Need backend to support text-hashing too
|
||||
isDaemonNewer "2.18.0pre20230906" && skipTest "Daemon is too new"
|
||||
|
||||
enableFeatures "ca-derivations dynamic-derivations"
|
||||
|
||||
restartDaemon
|
||||
|
||||
expectStderr 1 nix-instantiate --read-write-mode ./old-daemon-error-hack.nix | grepQuiet "the daemon is too old to understand dependencies on dynamic derivations"
|
|
@ -17,13 +17,13 @@ rec {
|
|||
foo."bar.runtimeGraph" = mkDerivation {
|
||||
name = "dependencies";
|
||||
builder = builtins.toFile "build-graph-builder" "${printRefs}";
|
||||
exportReferencesGraph = ["refs" (import ./dependencies.nix)];
|
||||
exportReferencesGraph = ["refs" (import ./dependencies.nix {})];
|
||||
};
|
||||
|
||||
foo."bar.buildGraph" = mkDerivation {
|
||||
name = "dependencies";
|
||||
builder = builtins.toFile "build-graph-builder" "${printRefs}";
|
||||
exportReferencesGraph = ["refs" (import ./dependencies.nix).drvPath];
|
||||
exportReferencesGraph = ["refs" (import ./dependencies.nix {}).drvPath];
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
builtins.pathExists (builtins.toPath ./lib.nix)
|
||||
builtins.pathExists (./lib.nix)
|
||||
&& builtins.pathExists (builtins.toPath ./lib.nix)
|
||||
&& builtins.pathExists (builtins.toString ./lib.nix)
|
||||
&& !builtins.pathExists (builtins.toString ./lib.nix + "/")
|
||||
&& builtins.pathExists (builtins.toPath (builtins.toString ./lib.nix))
|
||||
&& !builtins.pathExists (builtins.toPath (builtins.toString ./bla.nix))
|
||||
&& builtins.pathExists ./lib.nix
|
||||
|
|
|
@ -24,7 +24,7 @@ fi
|
|||
import (
|
||||
mkDerivation {
|
||||
name = "foo";
|
||||
bla = import ./dependencies.nix;
|
||||
bla = import ./dependencies.nix {};
|
||||
buildCommand = "
|
||||
echo \\\"hi\\\" > $out
|
||||
";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue