hydra: web: 'static-web-site-service-type' handles lists of sites.

* hydra/modules/sysadmin/web.scm (static-web-site-mcron-jobs): Expect a
list of <static-web-site-configuration> records.
(static-web-site-activation): Likewise.
(static-web-site-accounts): Define using 'const'.
* hydra/website.scm (website-services): Adjust accordingly, using one
'static-web-site-service-type' instance for all of guix.gnu.org.
* hydra/bayfront.scm <services>: Adjust hpc.guix.info instance
accordingly.
This commit is contained in:
Ludovic Courtès 2021-12-22 12:10:26 +01:00
parent 4cf3743e0d
commit 7b1b28271c
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
3 changed files with 75 additions and 74 deletions

View File

@ -916,7 +916,7 @@ access_log /var/log/nginx/bordeaux.access.log;"))
;; Runnning hpc.guix.info.
(service static-web-site-service-type
guix-hpc-web-site)
(list guix-hpc-web-site))
;; hpcguix-web as it can be seen at
;; <https://hpc.guix.info/browse>.

View File

@ -160,8 +160,8 @@ that's built with Haunt or similar."
(directory static-web-site-configuration-directory
(default "/srv/www")))
(define (static-web-site-mcron-jobs config)
(define update
(define (static-web-site-mcron-jobs sites)
(define (update config)
(build-program (static-web-site-configuration-git-url config)
(static-web-site-configuration-directory config)
#:max-duration (static-web-site-configuration-period config)
@ -176,36 +176,40 @@ that's built with Haunt or similar."
(basename
(static-web-site-configuration-directory config)))))
;; Add an offset to spread web site updates over the period to avoid I/O
;; load peaks when there are several such jobs.
(let* ((period (static-web-site-configuration-period config))
(offset (hash config period)))
(list #~(job (lambda (now)
(let ((elapsed (modulo now #$period)))
(+ now (- #$period elapsed) #$offset)))
#$update
#:user "static-web-site"))))
(map (lambda (config)
;; Add an offset to spread web site updates over the period to avoid I/O
;; load peaks when there are several such jobs.
(let* ((period (static-web-site-configuration-period config))
(offset (hash config period)))
#~(job (lambda (now)
(let ((elapsed (modulo now #$period)))
(+ now (- #$period elapsed) #$offset)))
#$(update config)
#:user "static-web-site")))
sites))
(define (static-web-site-activation config)
(define (static-web-site-activation sites)
(with-imported-modules '((guix build utils))
#~(begin
(use-modules (guix build utils))
(let ((directory (dirname
#$(static-web-site-configuration-directory config))))
(mkdir-p directory)
(chown directory
(passwd:uid (getpw "static-web-site"))
(group:gid (getgr "static-web-site")))))))
(for-each (lambda (directory)
(let ((directory (dirname directory)))
(mkdir-p directory)
(chown directory
(passwd:uid (getpw "static-web-site"))
(group:gid (getgr "static-web-site")))))
'#$(map static-web-site-configuration-directory
sites)))))
(define (static-web-site-accounts config)
(list (user-account
(name "static-web-site")
(group "static-web-site")
(system? #t))
(user-group
(name "static-web-site")
(system? #t))))
(define static-web-site-accounts
(const (list (user-account
(name "static-web-site")
(group "static-web-site")
(system? #t))
(user-group
(name "static-web-site")
(system? #t)))))
(define static-web-site-service-type
(service-type (name 'static-web-site)

View File

@ -3,65 +3,62 @@
(list
;; Runnning guix.gnu.org.
(service static-web-site-service-type
(static-web-site-configuration
(git-url
"https://git.savannah.gnu.org/git/guix/guix-artwork.git")
(directory "/srv/guix.gnu.org")
(build-file "website/.guix.scm")))
(list (static-web-site-configuration
(git-url
"https://git.savannah.gnu.org/git/guix/guix-artwork.git")
(directory "/srv/guix.gnu.org")
(build-file "website/.guix.scm"))
;; Manual for the latest stable release.
(service static-web-site-service-type
(static-web-site-configuration
(git-url "https://git.savannah.gnu.org/git/guix.git")
(git-ref '(branch . "version-1.3.0"))
(period (* 24 3600)) ;check once per day
(directory "/srv/guix-manual")
(build-file "doc/build.scm")
(environment-variables
'(("GUIX_MANUAL_VERSION" . "1.3.0")
("GUIX_WEB_SITE_URL" . "/")))))
;; Manual for the latest stable release.
(static-web-site-configuration
(git-url "https://git.savannah.gnu.org/git/guix.git")
(git-ref '(branch . "version-1.3.0"))
(period (* 24 3600)) ;check once per day
(directory "/srv/guix-manual")
(build-file "doc/build.scm")
(environment-variables
'(("GUIX_MANUAL_VERSION" . "1.3.0")
("GUIX_WEB_SITE_URL" . "/"))))
;; Manual for 'master'.
(service static-web-site-service-type
(static-web-site-configuration
(git-url "https://git.savannah.gnu.org/git/guix.git")
(directory "/srv/guix-manual-devel")
;; Manual for 'master'.
(static-web-site-configuration
(git-url "https://git.savannah.gnu.org/git/guix.git")
(directory "/srv/guix-manual-devel")
;; XXX: Use a different cache directory to work around
;; the fact that (guix git) would use a same-named
;; checkout directory for 'master' and for the branch
;; above. Since both mcron jobs run at the same time,
;; they would end up using one branch or the other, in
;; a non-deterministic way.
(cache-directory "guix-master-manual")
;; XXX: Use a different cache directory to work around
;; the fact that (guix git) would use a same-named
;; checkout directory for 'master' and for the branch
;; above. Since both mcron jobs run at the same time,
;; they would end up using one branch or the other, in
;; a non-deterministic way.
(cache-directory "guix-master-manual")
(build-file "doc/build.scm")
(environment-variables
'(("GUIX_WEB_SITE_URL" . "/")))))
(build-file "doc/build.scm")
(environment-variables
'(("GUIX_WEB_SITE_URL" . "/"))))
;; Cookbook for 'master'.
(service static-web-site-service-type
(static-web-site-configuration
(git-url "https://git.savannah.gnu.org/git/guix.git")
(directory "/srv/guix-cookbook")
;; Cookbook for 'master'.
(static-web-site-configuration
(git-url "https://git.savannah.gnu.org/git/guix.git")
(directory "/srv/guix-cookbook")
;; XXX: Use a different cache directory (see above).
(cache-directory "guix-cookbook-master")
;; XXX: Use a different cache directory (see above).
(cache-directory "guix-cookbook-master")
(build-file "doc/build.scm")
(environment-variables
'(("GUIX_MANUAL" . "guix-cookbook")
("GUIX_WEB_SITE_URL" . "/")))))
(build-file "doc/build.scm")
(environment-variables
'(("GUIX_MANUAL" . "guix-cookbook")
("GUIX_WEB_SITE_URL" . "/"))))))
;; TODO: Add the manuals of Cuirass and GWL.
;; The bootstrappable.org web site.
(service static-web-site-service-type
(static-web-site-configuration
(git-url
"https://git.savannah.gnu.org/git/guix/bootstrappable.git")
(period (* 24 3600)) ;check once per day
(directory "/srv/bootstrappable.org")))
(list (static-web-site-configuration
(git-url
"https://git.savannah.gnu.org/git/guix/bootstrappable.git")
(period (* 24 3600)) ;check once per day
(directory "/srv/bootstrappable.org"))))
;; GWL web site.
(service gwl-web-service-type)))