aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGuillaume Girol <symphorien+git@xlumurb.eu>2023-08-23 12:00:00 +0000
committerGuillaume Girol <symphorien+git@xlumurb.eu>2023-08-24 11:37:24 +0200
commit925a444b925590df90e19d3c0071936f87d2b43d (patch)
tree085a36dc6f2972ad5ac676d95231ec29b027a8ea /tests
parent6459a1c7ad1ad1a88fae42f9737e969c6ae89679 (diff)
add nix-store --query --valid-derivers command
notably useful when nix-store --query --deriver returns a non-existing path. Co-authored-by: Felix Uhl <iFreilicht@users.noreply.github.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/check-refs.nix2
-rw-r--r--tests/dependencies.nix13
-rw-r--r--tests/dependencies.sh17
-rw-r--r--tests/dyn-drv/eval-outputOf.sh4
-rw-r--r--tests/export-graph.nix4
-rw-r--r--tests/remote-store.sh2
6 files changed, 36 insertions, 6 deletions
diff --git a/tests/check-refs.nix b/tests/check-refs.nix
index 99d69a226..89690e456 100644
--- a/tests/check-refs.nix
+++ b/tests/check-refs.nix
@@ -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;
diff --git a/tests/dependencies.nix b/tests/dependencies.nix
index 45aca1793..be1a7ae9a 100644
--- a/tests/dependencies.nix
+++ b/tests/dependencies.nix
@@ -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";
};
diff --git a/tests/dependencies.sh b/tests/dependencies.sh
index d5cd30396..b93dacac0 100644
--- a/tests/dependencies.sh
+++ b/tests/dependencies.sh
@@ -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")"
diff --git a/tests/dyn-drv/eval-outputOf.sh b/tests/dyn-drv/eval-outputOf.sh
index 99d917c06..9467feb8d 100644
--- a/tests/dyn-drv/eval-outputOf.sh
+++ b/tests/dyn-drv/eval-outputOf.sh
@@ -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
diff --git a/tests/export-graph.nix b/tests/export-graph.nix
index fdac9583d..64fe36bd1 100644
--- a/tests/export-graph.nix
+++ b/tests/export-graph.nix
@@ -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];
};
}
diff --git a/tests/remote-store.sh b/tests/remote-store.sh
index ea32a20d3..50e6f24b9 100644
--- a/tests/remote-store.sh
+++ b/tests/remote-store.sh
@@ -24,7 +24,7 @@ fi
import (
mkDerivation {
name = "foo";
- bla = import ./dependencies.nix;
+ bla = import ./dependencies.nix {};
buildCommand = "
echo \\\"hi\\\" > $out
";