2
0
Fork 0
mirror of git://git.savannah.gnu.org/guix/maintenance.git synced 2023-12-14 03:33:04 +01:00

hydra: web: Add mcron job to build /packages.json and /sources.json.

Previously, these two files were built as part of the web site's build
process.

* hydra/modules/sysadmin/web.scm (%package-metadata-directory)
(guix-web-site-mcron-jobs, guix-web-site-activation): New variables.
(guix-web-site-service-type): Add extensions using them.
* hydra/modules/sysadmin/nginx.scm (guix.gnu.org-other-locations): Add
locations for /packages.json and /sources.json.
This commit is contained in:
Ludovic Courtès 2023-01-04 22:02:18 +01:00
parent 318db3eedf
commit 5664984bdd
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
2 changed files with 43 additions and 2 deletions

View file

@ -1,5 +1,5 @@
;; Nginx configuration for ci.guix.gnu.org
;; Copyright © 2016-2022 Ludovic Courtès <ludo@gnu.org>
;; Copyright © 2016-2023 Ludovic Courtès <ludo@gnu.org>
;; Copyright © 2017, 2018, 2019, 2020, 2021 Ricardo Wurmus <rekado@elephly.net>
;; Copyright © 2020 Christopher Baines <mail@cbaines.net>
;; Copyright © 2020, 2021 Florian Pelz <pelzflorian@pelzflorian.de>
@ -701,6 +701,16 @@ synonymous IETF language tags that should be mapped to the same $lang."
(uri "~ (.html|.htm)$")
(body (list "try_files $uri /$lang/$uri /$lang/$uri/index.html =404;")))
(nginx-location-configuration
(uri "= /packages.json")
(body (list "if_modified_since on;"
"root /srv/package-metadata")))
(nginx-location-configuration
(uri "= /sources.json")
(body (list "if_modified_since on;"
"root /srv/package-metadata")))
(nginx-location-configuration ;certbot
(uri "/.well-known")
(body (list "root /var/www;")))))

View file

@ -1,6 +1,6 @@
;;; GNU Guix system administration tools.
;;;
;;; Copyright © 2019-2022 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2019-2023 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2020, 2021 Ricardo Wurmus <rekado@elephly.net>
;;;
;;; This program is free software: you can redistribute it and/or modify
@ -290,12 +290,43 @@ taken from a Git repository.")
(environment-variables '(("GUIX_MANUAL" . "guix-cookbook")
("GUIX_WEB_SITE_URL" . "/"))))))
(define %package-metadata-directory
;; Directory where to store 'packages.json' and 'sources.json'.
"/srv/package-metadata")
(define guix-web-site-mcron-jobs
;; Job that periodically builds 'packages.json' and 'sources.json'.
(let ((program (program-file "build-package-metadata"
#~(execl #$(file-append guix "/bin/guix")
"guix"
"time-machine" "--" "repl" "--"
#$(local-file
"../../build-package-metadata.scm")
#$%package-metadata-directory))))
(list #~(job "30 */6 * * *" #$program
#:user "static-web-site"))))
(define guix-web-site-activation
(with-imported-modules '((guix build utils))
#~(begin
(use-modules (guix build utils))
(let ((pw (getpwnam "static-web-site")))
(mkdir-p #$%package-metadata-directory)
(chown #$%package-metadata-directory
(passwd:uid pw) (passwd:gid pw))
(chmod #$%package-metadata-directory #o755)))))
(define guix-web-site-service-type
(service-type
(name 'guix-web-site)
(extensions
(list (service-extension static-web-site-service-type
(const guix-static-web-sites))
(service-extension activation-service-type
(const guix-web-site-activation))
(service-extension mcron-service-type
(const guix-web-site-mcron-jobs))
(service-extension nginx-service-type
(const (list guix.gnu.org-nginx-server)))))
(description