@@ -134,6 +134,7 @@ MODULES = \
guix/ipfs.scm \
guix/eris.scm \
guix/eris/fs-store.scm \
+ guix/eris/http.scm \
guix/platform.scm \
guix/platforms/arm.scm \
guix/platforms/mips.scm \
new file mode 100644
@@ -0,0 +1,40 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2022 pukkamustard <pukkamustard@posteo.net>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix eris http)
+ #:use-module (eris utils base32)
+ #:use-module (web uri)
+
+ #:use-module (srfi srfi-2)
+
+ #:export (make-blake2b-urn-query-ref))
+
+(define blake2b-uri-path-regexp
+ (make-regexp "^blake2b:" regexp/icase))
+
+(define (make-blake2b-urn-query-ref block-ref)
+ (lambda (query)
+ (and-let* ((_ query) ; ensure query is not false
+ (urn (string->uri query))
+ (_ (uri? urn))
+ (_ (eqv? (uri-scheme urn) 'urn))
+ (_ (regexp-exec blake2b-uri-path-regexp
+ (uri-path urn)))
+ (blake2b-ref (base32-decode
+ (string-drop (uri-path urn) 8))))
+ (block-ref blake2b-ref))))
@@ -53,6 +53,8 @@ (define-module (guix scripts publish)
#:use-module (guix config)
#:use-module (guix derivations)
#:use-module (guix eris)
+ #:use-module (guix eris fs-store)
+ #:use-module (guix eris http)
#:use-module (gcrypt hash)
#:use-module (guix pki)
#:use-module (gcrypt pk-crypto)
@@ -1083,6 +1085,14 @@ (define nar-path?
(let ((expected (split-and-decode-uri-path nar-path)))
(cut equal? expected <>)))
+ ;; Get ERIS blocks directly from the filesystem store.
+ (define eris-block-ref
+ (eris-fs-store-ref (%eris-block-store-directory)))
+
+ ;; Create a handler for resolving blake2b URN queries.
+ (define blake2b-urn-query-ref
+ (make-blake2b-urn-query-ref eris-block-ref))
+
(define (handle request body)
(format #t "~a ~a~%"
(request-method request)
@@ -1125,6 +1135,16 @@ (define (handle request body)
(("log" name)
(render-log-file store request name))
+ ;; /uri-res/N2R - RFC2169 URN resolution
+ (("uri-res" "N2R")
+ (let ((block (blake2b-urn-query-ref
+ (uri-query (request-uri request)))))
+ (if block
+ (values `((content-type . (application/octet-stream
+ (charset . "ISO-8859-1"))))
+ block)
+ (not-found request))))
+
;; Use different URLs depending on the compression type. This
;; guarantees that /nar URLs remain valid even when 'guix publish'
;; is restarted with different compression parameters.