civodul pushed a commit to branch master
in repository maintenance.

commit c46b77991a333fecaa1bdfaf32c9a0fd5526264e
Author: Ludovic Courtès <l...@gnu.org>
AuthorDate: Fri Apr 4 19:05:18 2025 +0200

    hydra: web: Keep a local copy of ‘guix-install.sh’.
    
    This provides a backup for when git.savannah.gnu.org is down, as
    proposed in
    <https://lists.gnu.org/archive/html/guix-devel/2025-01/msg00167.html>.
    
    * hydra/modules/sysadmin/web.scm (build-program): Adjust to accept FILE
    as an absolute file name.
    (guix-static-web-sites): Add /srv/guix-install.
    * hydra/modules/sysadmin/nginx.scm (guix.gnu.org-redirect-locations):
    Remove /install.sh.
    (guix.gnu.org-other-locations): Add /install.sh.
---
 hydra/modules/sysadmin/nginx.scm |  8 ++++++--
 hydra/modules/sysadmin/web.scm   | 26 +++++++++++++++++++++++---
 2 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/hydra/modules/sysadmin/nginx.scm b/hydra/modules/sysadmin/nginx.scm
index 0fffeb09..85c46853 100644
--- a/hydra/modules/sysadmin/nginx.scm
+++ b/hydra/modules/sysadmin/nginx.scm
@@ -148,8 +148,6 @@ synonymous IETF language tags that should be mapped to the 
same $lang."
     (uri "~ ^/([^/]+)/packages/.*")
     (body (list "return 301 https://packages.guix.gnu.org;";)))
 
-   ;; Short URL for the installation script
-   (redirect "/install.sh" 
"https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh";)
    ;; What follows is a list of redirects for URLs that used to be
    ;; available at gnu.org/s/guix--e.g.,
    ;; <http://gnu.org/s/guix/news/porting-guix-and-guixsd.html>.
@@ -782,6 +780,12 @@ synonymous IETF language tags that should be mapped to the 
same $lang."
     (uri "~ \\.pdf$")                             ;*.pdf at the top level
     (body (list "root /srv/guix-pdfs;")))
 
+   ;; Cached copy of the 'guix-install.sh' script.
+   (nginx-location-configuration
+    (uri "= /install.sh")
+    (body (list "expires 4h;"
+                "alias /srv/guix-install;")))
+
    (git-http-nginx-location-configuration
     (git-http-configuration))
 
diff --git a/hydra/modules/sysadmin/web.scm b/hydra/modules/sysadmin/web.scm
index 52ec89d1..603f70dd 100644
--- a/hydra/modules/sysadmin/web.scm
+++ b/hydra/modules/sysadmin/web.scm
@@ -103,12 +103,15 @@ that's built with Haunt or similar."
                        '())))
 
           (define obj
-            (let ((variables '#$environment-variables))
+            (let ((variables '#$environment-variables)
+                  (file #$file))
               (for-each (match-lambda
                           ((name . value)
                            (setenv name value)))
                         variables)
-              (primitive-load (string-append checkout "/" #$file))))
+              (primitive-load (if (string-prefix? "/" file)
+                                  file
+                                  (in-vicinity checkout file)))))
 
           (format #t "building web site from '~a'...~%" #$url)
 
@@ -302,7 +305,24 @@ taken from a Git repository.")
 
          (build-file "doc/build.scm")
          (environment-variables '(("GUIX_MANUAL" . "guix-cookbook")
-                                  ("GUIX_WEB_SITE_URL" . "/"))))))
+                                  ("GUIX_WEB_SITE_URL" . "/"))))
+
+        (static-web-site-configuration
+         (git-url "https://git.savannah.gnu.org/git/guix.git";)
+         (directory "/srv/guix-install")
+         (period (* 4 3600))
+
+         ;; XXX: Use a different cache directory (see above).
+         (cache-directory "guix-install-script")
+
+         (build-file (scheme-file "copy-guix-install"
+                                  ;; XXX: Use a quote because nested gexps
+                                  ;; don't quite work. (-:
+                                  '(computed-file "guix-install.sh"
+                                                  #~(copy-file
+                                                     #$(local-file
+                                                        "etc/guix-install.sh")
+                                                     #$output)))))))
 
 (define %package-metadata-directory
   ;; Directory where to store 'packages.json' and 'sources.json'.

Reply via email to