diff --git a/guix/scripts/substitute-binary.scm b/guix/scripts/substitute-binary.scm
index 7a286426a1c6192a0dcc11429cab0bedfc5839dd..a2d0cab727c25d147c04d132463020462f5af766 100755
--- a/guix/scripts/substitute-binary.scm
+++ b/guix/scripts/substitute-binary.scm
@@ -625,20 +625,19 @@ (define (find-daemon-option option)
   (assoc-ref (daemon-options) option))
 
 (define %cache-url
-  (or (getenv "GUIX_BINARY_SUBSTITUTE_URL")
-      (match (and=> (find-daemon-option "substitute-urls")
-                    string-tokenize)
-        ((url)
-         url)
-        ((head tail ..1)
-         ;; Currently we don't handle multiple substitute URLs.
-         (warning (_ "these substitute URLs will not be used:~{ ~a~}~%")
-                  tail)
-         head)
-        (#f
-         ;; This can only happen when this script is not invoked by the
-         ;; daemon.
-         "http://hydra.gnu.org"))))
+  (match (and=> (find-daemon-option "substitute-urls")
+                string-tokenize)
+    ((url)
+     url)
+    ((head tail ..1)
+     ;; Currently we don't handle multiple substitute URLs.
+     (warning (_ "these substitute URLs will not be used:~{ ~a~}~%")
+              tail)
+     head)
+    (#f
+     ;; This can only happen when this script is not invoked by the
+     ;; daemon.
+     "http://hydra.gnu.org")))
 
 (define (guix-substitute-binary . args)
   "Implement the build daemon's substituter protocol."
diff --git a/test-env.in b/test-env.in
index 302118bb6f2c989f1b849abfd8a702d5e3f325f0..792830c29b910d196a7061ea1aa591fa3230bb10 100644
--- a/test-env.in
+++ b/test-env.in
@@ -81,7 +81,8 @@ then
     # Launch the daemon without chroot support because is may be
     # unavailable, for instance if we're not running as root.
     "@abs_top_builddir@/pre-inst-env"				\
-	"@abs_top_builddir@/guix-daemon" --disable-chroot &
+	"@abs_top_builddir@/guix-daemon" --disable-chroot	\
+	--substitute-urls="$GUIX_BINARY_SUBSTITUTE_URL" &
 
     daemon_pid=$!
     trap "kill $daemon_pid ; rm -rf $NIX_STATE_DIR" EXIT
diff --git a/tests/substitute-binary.scm b/tests/substitute-binary.scm
index 8bde7f6aaf415a90c53a38f1c383b9548f8c373a..163cd745936e71312d6f511e6f2b1e27351af585 100644
--- a/tests/substitute-binary.scm
+++ b/tests/substitute-binary.scm
@@ -166,6 +166,9 @@ (define (call-with-narinfo narinfo thunk)
 (define-syntax-rule (with-narinfo narinfo body ...)
   (call-with-narinfo narinfo (lambda () body ...)))
 
+;; Transmit these options to 'guix substitute-binary'.
+(set! (@@ (guix scripts substitute-binary) %cache-url)
+      (getenv "GUIX_BINARY_SUBSTITUTE_URL"))
 
 (test-equal "query narinfo without signature"
   ""                                              ; not substitutable