guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/01: hydra: web: Add an 'environment-variables' field.


From: Ludovic Courtès
Subject: 01/01: hydra: web: Add an 'environment-variables' field.
Date: Fri, 12 Jul 2019 09:11:26 -0400 (EDT)

civodul pushed a commit to branch master
in repository maintenance.

commit 0de0c4c06ac780806a6dc6d1714c8f351f9a2edc
Author: Ludovic Courtès <address@hidden>
Date:   Fri Jul 12 15:10:35 2019 +0200

    hydra: web: Add an 'environment-variables' field.
    
    * hydra/modules/sysadmin/web.scm (build-program): Add
     #:environment-variables parameter and honor it.
    (<static-web-site-configuration>)[environment-variables]: New field.
    (static-web-site-mcron-jobs): Pass #:environment-variables to
    'build-program'.
---
 hydra/modules/sysadmin/web.scm | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/hydra/modules/sysadmin/web.scm b/hydra/modules/sysadmin/web.scm
index 824002b..b63f160 100644
--- a/hydra/modules/sysadmin/web.scm
+++ b/hydra/modules/sysadmin/web.scm
@@ -43,10 +43,12 @@
                         #:key
                         (file "guix.scm")
                         (ref '(branch . "master"))
-                        (name "build-program"))
+                        (name "build-program")
+                        (environment-variables '()))
   "Return a program that pulls code from URL, builds it by loading FILE from
 that checkout (usually a 'guix.scm' file), and registers the result as
-ROOT (an indirect GC root) upon success.
+ROOT (an indirect GC root) upon success.  FILE is loaded in a content where
+ENVIRONMENT-VARIABLES, a list of key/value pairs, are defined.
 
 The typical use case is polling from the source repository of a web site
 that's built with Haunt or similar."
@@ -54,7 +56,7 @@ that's built with Haunt or similar."
     (with-extensions guix-extensions
       #~(begin
           (use-modules (guix) (guix git) (guix ui)
-                       (srfi srfi-11))
+                       (srfi srfi-11) (ice-9 match))
 
           (define (root-installed drv root)
             (mbegin %store-monad
@@ -68,7 +70,12 @@ that's built with Haunt or similar."
             (update-cached-checkout #$url #:ref '#$ref))
 
           (define obj
-            (primitive-load (string-append checkout "/" #$file)))
+            (let ((variables '#$environment-variables))
+              (for-each (match-lambda
+                          ((name . value)
+                           (setenv name value)))
+                        variables)
+              (primitive-load (string-append checkout "/" #$file))))
 
           (with-store store
             (run-with-store store
@@ -93,6 +100,8 @@ that's built with Haunt or similar."
                (default '(branch . "master")))
   (build-file  static-web-site-configuration-build-file
                (default "guix.scm"))
+  (environment-variables static-web-site-configuration-environment-variable
+                         (default '()))
   (directory   static-web-site-configuration-directory
                (default "/srv/www")))
 
@@ -102,6 +111,8 @@ that's built with Haunt or similar."
                    (static-web-site-configuration-directory config)
                    #:file (static-web-site-configuration-build-file config)
                    #:ref (static-web-site-configuration-git-ref config)
+                   #:environment-variables
+                   (static-web-site-configuration-environment-variable config)
                    #:name (string-append
                            "update-"
                            (basename



reply via email to

[Prev in Thread] Current Thread [Next in Thread]