diff --git a/guix/download.scm b/guix/download.scm
index f0a7a2928e4a224a8a5c546496291858bc1aa33b..6e91607196d25b7a3c8352c23dad9e0159e3b2d6 100644
--- a/guix/download.scm
+++ b/guix/download.scm
@@ -239,6 +239,10 @@ (define need-gnutls?
         ((url ...)
          (any https? url)))))
 
+  (define mirror-file
+    ;; Copy the list of mirrors to a file to keep a single copy in the store.
+    (plain-file "mirrors" (object->string mirrors)))
+
   (define builder
     #~(begin
         #+(if need-gnutls?
@@ -253,8 +257,11 @@ (define builder
               #~#t)
 
         (use-modules (guix build download))
-        (url-fetch '#$url #$output
-                   #:mirrors '#$mirrors)))
+
+        (url-fetch (call-with-input-string (getenv "guix download url")
+                     read)
+                   #$output
+                   #:mirrors (call-with-input-file #$mirror-file read))))
 
   (let ((uri (and (string? url) (string->uri url))))
     (if (or (and (string? url) (not uri))
@@ -271,6 +278,13 @@ (define builder
                                         (guix build utils)
                                         (guix ftp-client))
 
+                            ;; Use environment variables and a fixed script
+                            ;; name so there's only one script in store for
+                            ;; all the downloads.
+                            #:script-name "download"
+                            #:env-vars
+                            `(("guix download url" . ,(object->string url)))
+
                             ;; Honor the user's proxy settings.
                             #:leaked-env-vars '("http_proxy" "https_proxy")