guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to customize mirror list used in custom channels?


From: zimoun
Subject: Re: how to customize mirror list used in custom channels?
Date: Tue, 29 Nov 2022 20:02:45 +0100

Hi,

On Tue, 29 Nov 2022 at 09:41, Ludovic Courtès <ludo@gnu.org> wrote:

> The more I write, the closer I get to an actual implementation.  :-)
> If ‘url-fetch’ takes a #:mirrors, that should allow us to extend the set
> of mirrors quite conveniently, along the lines of:
>
>   (define (my-url-fetch . args)
>     (apply url-fetch (append args '(#:mirrors …))))

Well, the ’url-fetch’ defined in (guix build download) already takes
#:mirrors, no?

--8<---------------cut here---------------start------------->8---
(define* (url-fetch url file
                    #:key
                    (timeout 10) (verify-certificate? #t)
                    (mirrors '()) (content-addressed-mirrors '())
                    (disarchive-mirrors '())
                    (hashes '())
                    print-build-trace?)
--8<---------------cut here---------------end--------------->8---

So, I guess you are talking about ’url-fetch*’ from (guix download) and
exported as ’url-fetch’.  Right?  The one which put the bits in the
store. :-)

Does something like that would make sense?

--8<---------------cut here---------------start------------->8---
diff --git a/guix/download.scm b/guix/download.scm
index 2e9ecb43fc..2497ea0f75 100644
--- a/guix/download.scm
+++ b/guix/download.scm
@@ -499,6 +499,7 @@ (define %download-fallback-test
 (define* (url-fetch* url hash-algo hash
                      #:optional name
                      #:key (system (%current-system))
+                     (mirrors %mirrors)
                      (guile (default-guile))
                      executable?)
   "Return a fixed-output derivation that fetches data from URL (a string, or a
@@ -519,7 +520,8 @@ (define file-name
       (_
        (basename url))))
 
-  (let ((uri (and (string? url) (string->uri url))))
+  (let ((uri (and (string? url) (string->uri url)))
+        (mirror-file (plain-file "mirrors" (object->string mirrors))))
     (if (or (and (string? url) (not uri))
             (and uri (memq (uri-scheme uri) '(#f file))))
         (interned-file (if uri (uri-path uri) url)
@@ -540,7 +542,7 @@ (define file-name
                              #:hash-algo hash-algo
                              #:hash hash
                              #:executable? executable?
-                             #:mirrors %mirror-file
+                             #:mirrors mirror-file
                              #:content-addressed-mirrors
                              (match (%download-fallback-test)
                                ((or #f 'content-addressed-mirrors)
--8<---------------cut here---------------end--------------->8---

This change would a world rebuild, right?

Last, note that ’download-to-store’ uses %mirrors so it seems
straightforward here to add ’#:key (mirrors %mirrors)’, I guess.


Cheers,
simon



reply via email to

[Prev in Thread] Current Thread [Next in Thread]