diff --git a/hydra/build-package-metadata.scm b/hydra/build-package-metadata.scm index 6fa2173..1ddb409 100755 --- a/hydra/build-package-metadata.scm +++ b/hydra/build-package-metadata.scm @@ -30,6 +30,7 @@ (guix utils) (guix gexp) ((guix build download) #:select (maybe-expand-mirrors)) + ((guix base32) #:select (bytevector->nix-base32-string)) ((guix base64) #:select (base64-encode)) ((guix describe) #:select (current-profile)) ((guix config) #:select (%guix-version)) @@ -73,6 +74,27 @@ superseded packages." ;;; Required by 'origin->json' for 'computed-origin-method' corner cases (define gexp-references (@@ (guix gexp) gexp-references)) +(define %content-addressed-mirrors + ;; List of content-addressed mirrors. + ;; XXX: somewhat duplicated from (guix download) + (let ((guix-publish + (lambda (host) + (lambda (file hash) + ;; Files served by 'guix publish'. + (string-append "https://" host "/file/" + file "/" (symbol->string + (content-hash-algorithm hash)) + "/" (bytevector->nix-base32-string + (content-hash-value hash))))))) + + (list (guix-publish "bordeaux.guix.gnu.org") + (guix-publish "ci.guix.gnu.org") + (lambda (file hash) + (string-append "https://tarballs.nixos.org/" + (symbol->string (content-hash-algorithm hash)) + "/" (bytevector->nix-base32-string + (content-hash-value hash))))))) + (define (origin->json origin) "Return a list of JSON representations (an alist) of ORIGIN." (define method @@ -81,10 +103,17 @@ superseded packages." (define uri (origin-uri origin)) - (define (resolve urls) - (map uri->string - (append-map (cut maybe-expand-mirrors <> %mirrors) - (map string->uri urls)))) + (define (resolve urls hash) + (append (map uri->string + (append-map (cut maybe-expand-mirrors <> %mirrors) + (map string->uri urls))) + (if hash + (let ((file (origin-actual-file-name origin)) + (hash (origin-hash origin))) + (map (lambda (make-url) + (make-url file hash)) + %content-addressed-mirrors)) + '()))) (if (eq? method (@@ (guix packages) computed-origin-method)) ;; Packages in gnu/packages/gnuzilla.scm and gnu/packages/linux.scm @@ -118,7 +147,8 @@ superseded packages." (resolve (match uri ((? string? url) (list url)) - ((urls ...) urls))))))) + ((urls ...) urls)) + (origin-hash origin)))))) ((eq? git-fetch method) `(("git_url" . ,(git-reference-url uri)))) ((eq? svn-fetch method)