diff options
| author | Mathieu Othacehe <m.othacehe@gmail.com> | 2017-12-12 16:06:47 +0100 |
|---|---|---|
| committer | Mathieu Othacehe <m.othacehe@gmail.com> | 2017-12-15 12:15:15 +0100 |
| commit | 5a72ddf176d53a7f4df922985d9d7fd4cfa160f5 (patch) | |
| tree | df7a61a6eb598dde8a0a71fff9aa0e858dd08b7f | |
| parent | d65854bdda4ad5464fcd8fe6289eedc13ea82ba1 (diff) | |
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.
| -rw-r--r-- | doc/guix.texi | 8 | ||||
| -rw-r--r-- | guix/scripts/system.scm | 28 |
2 files changed, 30 insertions, 6 deletions
diff --git a/doc/guix.texi b/doc/guix.texi index 7625f30fbb9..64f73b38a46 100644 --- a/doc/guix.texi +++ b/doc/guix.texi | |||
| @@ -18744,6 +18744,14 @@ Build Options}). In addition, @var{options} can contain one of the | |||
| 18744 | following: | 18744 | following: |
| 18745 | 18745 | ||
| 18746 | @table @option | 18746 | @table @option |
| 18747 | @item --expression=@var{expr} | ||
| 18748 | @itemx -e @var{expr} | ||
| 18749 | Consider the operating-system @var{expr} evaluates to. | ||
| 18750 | This is an alternative to specifying a file which evaluates to an | ||
| 18751 | operating system. | ||
| 18752 | This is used to generate the GuixSD installer @pxref{Building the | ||
| 18753 | Installation Image}). | ||
| 18754 | |||
| 18747 | @item --system=@var{system} | 18755 | @item --system=@var{system} |
| 18748 | @itemx -s @var{system} | 18756 | @itemx -s @var{system} |
| 18749 | Attempt to build for @var{system} instead of the host system type. | 18757 | 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 cbf7e6cd035..36aed3331f1 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm | |||
| @@ -858,6 +858,9 @@ Some ACTIONS support additional ARGS.\n")) | |||
| 858 | (display (G_ " | 858 | (display (G_ " |
| 859 | -d, --derivation return the derivation of the given system")) | 859 | -d, --derivation return the derivation of the given system")) |
| 860 | (display (G_ " | 860 | (display (G_ " |
| 861 | -e, --expression=EXPR consider the operating-system EXPR evaluates to | ||
| 862 | instead of reading FILE, when applicable")) | ||
| 863 | (display (G_ " | ||
| 861 | --on-error=STRATEGY | 864 | --on-error=STRATEGY |
| 862 | apply STRATEGY when an error occurs while reading FILE")) | 865 | apply STRATEGY when an error occurs while reading FILE")) |
| 863 | (display (G_ " | 866 | (display (G_ " |
| @@ -895,6 +898,9 @@ Some ACTIONS support additional ARGS.\n")) | |||
| 895 | (option '(#\V "version") #f #f | 898 | (option '(#\V "version") #f #f |
| 896 | (lambda args | 899 | (lambda args |
| 897 | (show-version-and-exit "guix system"))) | 900 | (show-version-and-exit "guix system"))) |
| 901 | (option '(#\e "expression") #t #f | ||
| 902 | (lambda (opt name arg result) | ||
| 903 | (alist-cons 'expression arg result))) | ||
| 898 | (option '(#\d "derivation") #f #f | 904 | (option '(#\d "derivation") #f #f |
| 899 | (lambda (opt name arg result) | 905 | (lambda (opt name arg result) |
| 900 | (alist-cons 'derivations-only? #t result))) | 906 | (alist-cons 'derivations-only? #t result))) |
| @@ -964,11 +970,19 @@ resulting from command-line parsing." | |||
| 964 | (let* ((file (match args | 970 | (let* ((file (match args |
| 965 | (() #f) | 971 | (() #f) |
| 966 | ((x . _) x))) | 972 | ((x . _) x))) |
| 973 | (expr (assoc-ref opts 'expression)) | ||
| 967 | (system (assoc-ref opts 'system)) | 974 | (system (assoc-ref opts 'system)) |
| 968 | (os (if file | 975 | (os (cond |
| 969 | (load* file %user-module | 976 | ((and expr file) |
| 970 | #:on-error (assoc-ref opts 'on-error)) | 977 | (leave |
| 971 | (leave (G_ "no configuration file specified~%")))) | 978 | (G_ "both file and expression cannot be specified~%"))) |
| 979 | (expr | ||
| 980 | (read/eval expr)) | ||
| 981 | (file | ||
| 982 | (load* file %user-module | ||
| 983 | #:on-error (assoc-ref opts 'on-error))) | ||
| 984 | (else | ||
| 985 | (leave (G_ "no configuration specified~%"))))) | ||
| 972 | 986 | ||
| 973 | (dry? (assoc-ref opts 'dry-run?)) | 987 | (dry? (assoc-ref opts 'dry-run?)) |
| 974 | (bootloader? (assoc-ref opts 'install-bootloader?)) | 988 | (bootloader? (assoc-ref opts 'install-bootloader?)) |
| @@ -1079,7 +1093,8 @@ argument list and OPTS is the option alist." | |||
| 1079 | ;; Extract the plain arguments from OPTS. | 1093 | ;; Extract the plain arguments from OPTS. |
| 1080 | (let* ((args (reverse (filter-map (match-pair 'argument) opts))) | 1094 | (let* ((args (reverse (filter-map (match-pair 'argument) opts))) |
| 1081 | (count (length args)) | 1095 | (count (length args)) |
| 1082 | (action (assoc-ref opts 'action))) | 1096 | (action (assoc-ref opts 'action)) |
| 1097 | (expr (assoc-ref opts 'expression))) | ||
| 1083 | (define (fail) | 1098 | (define (fail) |
| 1084 | (leave (G_ "wrong number of arguments for action '~a'~%") | 1099 | (leave (G_ "wrong number of arguments for action '~a'~%") |
| 1085 | action)) | 1100 | action)) |
| @@ -1093,7 +1108,8 @@ argument list and OPTS is the option alist." | |||
| 1093 | 1108 | ||
| 1094 | (case action | 1109 | (case action |
| 1095 | ((build container vm vm-image disk-image reconfigure) | 1110 | ((build container vm vm-image disk-image reconfigure) |
| 1096 | (unless (= count 1) | 1111 | (unless (or (= count 1) |
| 1112 | (and expr (= count 0))) | ||
| 1097 | (fail))) | 1113 | (fail))) |
| 1098 | ((init) | 1114 | ((init) |
| 1099 | (unless (= count 2) | 1115 | (unless (= count 2) |
