aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2023-09-06 22:57:37 -0400
committerJohn Ericson <John.Ericson@Obsidian.Systems>2023-09-07 10:39:37 -0400
commit80d7994f52ccefca2f2fbe4ee64741a6f49884ff (patch)
treed85b0de783e519dddfa964d5cb0494e93ec4cc61 /tests
parent7ad66cb3ef7615b51a35a099e232640d528c006c (diff)
Special-case error message to add extra information
The Derivation parser and old ATerm unfortunately leaves few ways to get nice errors when an old version of Nix encounters a new version of the format. The most likely scenario for this to occur is with a new client making a derivation that the old daemon it is communicating with cannot understand. The extensions we just created for dynamic derivation deps will add a version field, solving the problem going forward, but there is still the issue of what to do about old versions of Nix up to now. The solution here is to carefully catch the bad error from the daemon that is likely to indicate this problem, and add some extra context to it. There is another "Ugly backwards compatibility hack" in `remote-store.cc` that also works by transforming an error. Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/dyn-drv/local.mk3
-rw-r--r--tests/dyn-drv/old-daemon-error-hack.nix20
-rw-r--r--tests/dyn-drv/old-daemon-error-hack.sh11
3 files changed, 33 insertions, 1 deletions
diff --git a/tests/dyn-drv/local.mk b/tests/dyn-drv/local.mk
index 0ce7cd37d..6b435499b 100644
--- a/tests/dyn-drv/local.mk
+++ b/tests/dyn-drv/local.mk
@@ -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
diff --git a/tests/dyn-drv/old-daemon-error-hack.nix b/tests/dyn-drv/old-daemon-error-hack.nix
new file mode 100644
index 000000000..c9d4a62d4
--- /dev/null
+++ b/tests/dyn-drv/old-daemon-error-hack.nix
@@ -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"}
+ '';
+ };
+}
diff --git a/tests/dyn-drv/old-daemon-error-hack.sh b/tests/dyn-drv/old-daemon-error-hack.sh
new file mode 100644
index 000000000..43b049973
--- /dev/null
+++ b/tests/dyn-drv/old-daemon-error-hack.sh
@@ -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"