From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43530) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eP4oh-0003oE-3G for guix-patches@gnu.org; Wed, 13 Dec 2017 06:03:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eP4oZ-0006rw-9P for guix-patches@gnu.org; Wed, 13 Dec 2017 06:03:11 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:50791) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eP4oZ-0006rp-57 for guix-patches@gnu.org; Wed, 13 Dec 2017 06:03:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eP4oY-0001Zc-Ss for guix-patches@gnu.org; Wed, 13 Dec 2017 06:03:02 -0500 Subject: [bug#29409] [PATCH v2 3/4] scripts: system: Add --expression option. Resent-Message-ID: From: m.othacehe@gmail.com Date: Wed, 13 Dec 2017 12:02:16 +0100 Message-Id: <1513162937-13145-3-git-send-email-m.othacehe@gmail.com> In-Reply-To: <1513162937-13145-1-git-send-email-m.othacehe@gmail.com> References: <1513162937-13145-1-git-send-email-m.othacehe@gmail.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 29409@debbugs.gnu.org From: Mathieu Othacehe * 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 +@item --expression=@var{expr} +@itemx -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 --system=@var{system} @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