hydra: build-package-metadata: Compress JSON files.
* hydra/build-package-metadata.scm (write-json): Use ‘call-with-gzip-output-port’. (main): Append “.gz” to JSON file names. * hydra/modules/sysadmin/nginx.scm (guix.gnu.org-other-locations): Add “gzip_static” and “gunzip” directives on /packages.json and /sources.json.
This commit is contained in:
parent
5b2c48e713
commit
1123fd81ce
|
@ -39,6 +39,7 @@
|
|||
(guix svn-download)
|
||||
(guix hg-download)
|
||||
(json)
|
||||
(zlib)
|
||||
(web uri)
|
||||
(ice-9 match)
|
||||
(ice-9 vlist)
|
||||
|
@ -239,11 +240,21 @@ superseded packages."
|
|||
(list->vector (map package->json (all-packages))))
|
||||
|
||||
(define (write-json json file)
|
||||
"Serialize JSON to FILE."
|
||||
(with-atomic-file-output file
|
||||
(lambda (port)
|
||||
(scm->json json port)
|
||||
(chmod port #o644))))
|
||||
"Serialize and compress JSON to FILE."
|
||||
(let ((pivot (string-append file ".tmp")))
|
||||
;; Note: 'with-atomic-file-output' doesn't work well with
|
||||
;; 'call-with-gzip-output-port' since the latter closes its underlying
|
||||
;; port.
|
||||
(call-with-output-file pivot
|
||||
(lambda (port)
|
||||
(chmod port #o644)
|
||||
(call-with-gzip-output-port port
|
||||
(lambda (port)
|
||||
(set-port-encoding! port "UTF-8")
|
||||
(scm->json json port))
|
||||
#:buffer-size (expt 2 16)
|
||||
#:level 9)))
|
||||
(rename-file pivot file)))
|
||||
|
||||
|
||||
;;;
|
||||
|
@ -258,7 +269,7 @@ superseded packages."
|
|||
(write-json (thunk)
|
||||
(string-append directory "/" file)))
|
||||
(list packages-json sources-json)
|
||||
'("packages.json" "sources.json")))
|
||||
'("packages.json.gz" "sources.json.gz")))
|
||||
((command . _)
|
||||
(leave (G_ "Usage: ~a DIRECTORY
|
||||
|
||||
|
|
|
@ -704,11 +704,13 @@ synonymous IETF language tags that should be mapped to the same $lang."
|
|||
(nginx-location-configuration
|
||||
(uri "= /packages.json")
|
||||
(body (list "if_modified_since exact;"
|
||||
"gzip_static always; gunzip on;\n"
|
||||
"root /srv/package-metadata;")))
|
||||
|
||||
(nginx-location-configuration
|
||||
(uri "= /sources.json")
|
||||
(body (list "if_modified_since exact;"
|
||||
"gzip_static always; gunzip on;\n"
|
||||
"root /srv/package-metadata;")))
|
||||
|
||||
(nginx-location-configuration ;certbot
|
||||
|
|
Loading…
Reference in New Issue