guix-commits
[Top][All Lists]
Advanced

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

01/02: scripts: system: Add --expression option.


From: Mathieu Othacehe
Subject: 01/02: scripts: system: Add --expression option.
Date: Fri, 15 Dec 2017 10:34:15 -0500 (EST)

mothacehe pushed a commit to branch master
in repository guix.

commit 5a72ddf176d53a7f4df922985d9d7fd4cfa160f5
Author: Mathieu Othacehe <address@hidden>
Date:   Tue Dec 12 16:06:47 2017 +0100

    scripts: system: Add --expression option.
    
    * guix/scripts/system.scm (show-help): Add expression option.
    (%options): Ditto.
    (guix-system): Allow commands taking a file as an argument to use an
    expression instead.
    (process-action): Read operating-system from expression or file.
    * doc/guix.texi (Invoking guix system): Introduce the expression option.
---
 doc/guix.texi           |  8 ++++++++
 guix/scripts/system.scm | 28 ++++++++++++++++++++++------
 2 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 7625f30..64f73b3 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -18744,6 +18744,14 @@ Build Options}).  In addition, @var{options} can 
contain one of the
 following:
 
 @table @option
address@hidden address@hidden
address@hidden -e @var{expr}
+Consider the operating-system @var{expr} evaluates to.
+This is an alternative to specifying a file which evaluates to an
+operating system.
+This is used to generate the GuixSD installer @pxref{Building the
+Installation Image}).
+
 @item address@hidden
 @itemx -s @var{system}
 Attempt to build for @var{system} instead of the host system type.
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index cbf7e6c..36aed33 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -858,6 +858,9 @@ Some ACTIONS support additional ARGS.\n"))
   (display (G_ "
   -d, --derivation       return the derivation of the given system"))
   (display (G_ "
+  -e, --expression=EXPR  consider the operating-system EXPR evaluates to
+                         instead of reading FILE, when applicable"))
+  (display (G_ "
       --on-error=STRATEGY
                          apply STRATEGY when an error occurs while reading 
FILE"))
   (display (G_ "
@@ -895,6 +898,9 @@ Some ACTIONS support additional ARGS.\n"))
          (option '(#\V "version") #f #f
                  (lambda args
                    (show-version-and-exit "guix system")))
+         (option '(#\e "expression") #t #f
+                 (lambda (opt name arg result)
+                   (alist-cons 'expression arg result)))
          (option '(#\d "derivation") #f #f
                  (lambda (opt name arg result)
                    (alist-cons 'derivations-only? #t result)))
@@ -964,11 +970,19 @@ resulting from command-line parsing."
   (let* ((file        (match args
                         (() #f)
                         ((x . _) x)))
+         (expr        (assoc-ref opts 'expression))
          (system      (assoc-ref opts 'system))
-         (os          (if file
-                          (load* file %user-module
-                                 #:on-error (assoc-ref opts 'on-error))
-                          (leave (G_ "no configuration file specified~%"))))
+         (os          (cond
+                       ((and expr file)
+                        (leave
+                         (G_ "both file and expression cannot be 
specified~%")))
+                       (expr
+                        (read/eval expr))
+                       (file
+                        (load* file %user-module
+                                    #:on-error (assoc-ref opts 'on-error)))
+                       (else
+                        (leave (G_ "no configuration specified~%")))))
 
          (dry?        (assoc-ref opts 'dry-run?))
          (bootloader? (assoc-ref opts 'install-bootloader?))
@@ -1079,7 +1093,8 @@ argument list and OPTS is the option alist."
     ;; Extract the plain arguments from OPTS.
     (let* ((args   (reverse (filter-map (match-pair 'argument) opts)))
            (count  (length args))
-           (action (assoc-ref opts 'action)))
+           (action (assoc-ref opts 'action))
+           (expr   (assoc-ref opts 'expression)))
       (define (fail)
         (leave (G_ "wrong number of arguments for action '~a'~%")
                action))
@@ -1093,7 +1108,8 @@ argument list and OPTS is the option alist."
 
       (case action
         ((build container vm vm-image disk-image reconfigure)
-         (unless (= count 1)
+         (unless (or (= count 1)
+                     (and expr (= count 0)))
            (fail)))
         ((init)
          (unless (= count 2)



reply via email to

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