aboutsummaryrefslogtreecommitdiff
path: root/guix/scripts
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2015-09-19 11:14:42 +0200
committerLudovic Courtès <ludo@gnu.org>2015-10-10 22:46:15 +0200
commitf3f427c2e930e2fb1a72ff8bb9b4a870edfbf007 (patch)
tree84d2c6c92a505f0387e0ca3e65d99bf5107956f6 /guix/scripts
parent23afe939a2282369900e0e7a33405cc613d7a405 (diff)
downloadgnu-guix-f3f427c2e930e2fb1a72ff8bb9b4a870edfbf007.tar
gnu-guix-f3f427c2e930e2fb1a72ff8bb9b4a870edfbf007.tar.gz
guix system: Add '--derivation'.
* guix/scripts/system.scm (perform-action): Add #:derivations-only? parameter and honor it. (show-help, %options): Add '--derivation'. (guix-system): Pass #:derivations-only? to 'perform-action'. * tests/guix-system.sh: Test it. * doc/guix.texi (Invoking guix system): Document it.
Diffstat (limited to 'guix/scripts')
-rw-r--r--guix/scripts/system.scm30
1 files changed, 23 insertions, 7 deletions
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 5e2d226dfe..71b92dacc7 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -300,7 +300,7 @@ it atomically, and then run OS's activation script."
(system-disk-image os #:disk-image-size image-size))))
(define* (perform-action action os
- #:key grub? dry-run?
+ #:key grub? dry-run? derivations-only?
use-substitutes? device target
image-size full-boot?
(mappings '()))
@@ -308,7 +308,13 @@ it atomically, and then run OS's activation script."
the target devices for GRUB; TARGET is the target root directory; IMAGE-SIZE
is the size of the image to be built, for the 'vm-image' and 'disk-image'
actions. FULL-BOOT? is used for the 'vm' action; it determines whether to
-boot directly to the kernel or to the bootloader."
+boot directly to the kernel or to the bootloader.
+
+When DERIVATIONS-ONLY? is true, print the derivation file name(s) without
+building anything."
+ (define println
+ (cut format #t "~a~%" <>))
+
(mlet* %store-monad
((sys (system-derivation-for-action os action
#:image-size image-size
@@ -322,14 +328,17 @@ boot directly to the kernel or to the bootloader."
(drvs -> (if (and grub? (memq action '(init reconfigure)))
(list sys grub grub.cfg)
(list sys)))
- (% (maybe-build drvs #:dry-run? dry-run?
- #:use-substitutes? use-substitutes?)))
+ (% (if derivations-only?
+ (return (for-each (compose println derivation-file-name)
+ drvs))
+ (maybe-build drvs #:dry-run? dry-run?
+ #:use-substitutes? use-substitutes?))))
- (if dry-run?
+ (if (or dry-run? derivations-only?)
(return #f)
(begin
- (for-each (cut format #t "~a~%" <>)
- (map derivation->output-path drvs))
+ (for-each (compose println derivation->output-path)
+ drvs)
;; Make sure GRUB is accessible.
(when grub?
@@ -383,6 +392,8 @@ Build the operating system declared in FILE according to ACTION.\n"))
(show-build-options-help)
(display (_ "
+ -d, --derivation return the derivation of the given system"))
+ (display (_ "
--on-error=STRATEGY
apply STRATEGY when an error occurs while reading FILE"))
(display (_ "
@@ -425,6 +436,9 @@ Build the operating system declared in FILE according to ACTION.\n"))
(option '(#\V "version") #f #f
(lambda args
(show-version-and-exit "guix system")))
+ (option '(#\d "derivation") #f #f
+ (lambda (opt name arg result)
+ (alist-cons 'derivations-only? #t result)))
(option '("on-error") #t #f
(lambda (opt name arg result)
(alist-cons 'on-error (string->symbol arg)
@@ -549,6 +563,8 @@ Build the operating system declared in FILE according to ACTION.\n"))
(set-guile-for-build (default-guile))
(perform-action action os
#:dry-run? dry?
+ #:derivations-only? (assoc-ref opts
+ 'derivations-only?)
#:use-substitutes? (assoc-ref opts 'substitutes?)
#:image-size (assoc-ref opts 'image-size)
#:full-boot? (assoc-ref opts 'full-boot?)