[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#29409] [PATCH v2 3/4] scripts: system: Add --expression option.
From: |
m . othacehe |
Subject: |
[bug#29409] [PATCH v2 3/4] scripts: system: Add --expression option. |
Date: |
Wed, 13 Dec 2017 12:02:16 +0100 |
From: Mathieu Othacehe <address@hidden>
* guix/scripts/system.scm (show-help): Add expression option.
(%options): Ditto.
(process-action): Read operating-system from expression or file.
* Makefile.am (release): Use expression instead of file to produce
disk-images.
* doc/guix.texi (Building the Installation Image): Adapt disk-image command to
use an expression.
(Invoking guix system): Introduce the expression option.
---
Makefile.am | 2 +-
doc/guix.texi | 10 +++++++++-
guix/scripts/system.scm | 24 +++++++++++++++++++-----
3 files changed, 29 insertions(+), 7 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 85b9ab3..dff1e5e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -648,7 +648,7 @@ release: dist
guix system disk-image
\
--file-system-type=iso9660
\
--system=$$system
\
- gnu/system/install.scm` ;
\
+ -e "(@ (gnu system install) installation-os)"` ;
\
if [ ! -f "$$image" ] ; then
\
echo "failed to produced GuixSD installation image for $$system"
>&2 ; \
exit 1 ;
\
diff --git a/doc/guix.texi b/doc/guix.texi
index 92ac45b..9bdfdf7 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -8356,7 +8356,7 @@ The installation image described above was built using
the @command{guix
system} command, specifically:
@example
-guix system disk-image gnu/system/install.scm
+guix system disk-image -e "(@@ (gnu system install) installation-os)"
@end example
Have a look at @file{gnu/system/install.scm} in the source tree,
@@ -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..f710db9 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?))
@@ -1093,7 +1107,7 @@ 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) (= count 0))
(fail)))
((init)
(unless (= count 2)
--
2.7.4
[bug#29409] [PATCH v2 1/4] vm: Adapt qemu command to ARM., Ludovic Courtès, 2017/12/15