aboutsummaryrefslogtreecommitdiff
path: root/guix-data-service/web/nar/controller.scm
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2019-12-28 23:50:52 +0000
committerChristopher Baines <mail@cbaines.net>2019-12-29 16:04:45 +0000
commitda3a29449645376f64b48c3d87c8f13def1db94c (patch)
tree0afb3e8722c17456516d8f4fd3449d3a582d11d7 /guix-data-service/web/nar/controller.scm
parent67af7e17f0967b418b92caa295b9707ee4bc1d89 (diff)
downloaddata-service-da3a29449645376f64b48c3d87c8f13def1db94c.tar
data-service-da3a29449645376f64b48c3d87c8f13def1db94c.tar.gz
Serve nar files for the derivation source files
Diffstat (limited to 'guix-data-service/web/nar/controller.scm')
-rw-r--r--guix-data-service/web/nar/controller.scm73
1 files changed, 46 insertions, 27 deletions
diff --git a/guix-data-service/web/nar/controller.scm b/guix-data-service/web/nar/controller.scm
index 53419e0..781a01b 100644
--- a/guix-data-service/web/nar/controller.scm
+++ b/guix-data-service/web/nar/controller.scm
@@ -70,11 +70,16 @@
(('GET "substitutes")
(render-html
#:sxml (view-substitutes (%narinfo-signing-public-key))))
- (('GET "nar" derivation)
+ (('GET "nar" file-name)
(render-nar request
mime-types
conn
- (string-append "/gnu/store/" derivation)))
+ (string-append "/gnu/store/" file-name)))
+ (('GET "nar" "lzip" file-name)
+ (render-lzip-nar request
+ mime-types
+ conn
+ (string-append "/gnu/store/" file-name)))
(('GET (? .narinfo-suffix path))
(let* ((hash (string-drop-right
path
@@ -126,31 +131,45 @@
(define (render-nar request
mime-types
conn
- derivation-file-name)
- (let ((derivation-text
- (select-serialized-derivation-by-file-name
- conn
- derivation-file-name)))
- (if derivation-text
- (let ((derivation-bytevector
- (string->bytevector derivation-text
- "ISO-8859-1")))
- (list (build-response
- #:code 200
- #:headers '((content-type . (application/x-nix-archive
- (charset . "ISO-8859-1")))))
- (lambda (port)
- (write-file-tree
- derivation-file-name
- port
- #:file-type+size
- (lambda (file)
- (values 'regular
- (bytevector-length derivation-bytevector)))
- #:file-port
- (lambda (file)
- (open-bytevector-input-port derivation-bytevector))))))
- (not-found (request-uri request)))))
+ file-name)
+ (or
+ (and=> (select-serialized-derivation-by-file-name conn
+ file-name)
+ (lambda (derivation-text)
+ (let ((derivation-bytevector
+ (string->bytevector derivation-text
+ "ISO-8859-1")))
+ (list (build-response
+ #:code 200
+ #:headers '((content-type . (application/x-nix-archive
+ (charset . "ISO-8859-1")))))
+ (lambda (port)
+ (write-file-tree
+ file-name
+ port
+ #:file-type+size
+ (lambda (file)
+ (values 'regular
+ (bytevector-length derivation-bytevector)))
+ #:file-port
+ (lambda (file)
+ (open-bytevector-input-port derivation-bytevector))))))))
+ (not-found (request-uri request))))
+
+(define (render-lzip-nar request
+ mime-types
+ conn
+ file-name)
+ (or
+ (and=> (select-derivation-source-file-nar-data-by-file-name conn file-name)
+ (lambda (data)
+ (list (build-response
+ #:code 200
+ #:headers '((content-type . (application/x-nix-archive
+ (charset . "ISO-8859-1")))))
+ (lambda (port)
+ (put-bytevector port data)))))
+ (not-found (request-uri request))))
(define* (narinfo-string store-item
nar-bytevector