summaryrefslogtreecommitdiff
path: root/guix
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2015-10-30 21:02:51 -0400
committerDavid Thompson <dthompson2@worcester.edu>2015-10-30 21:02:51 -0400
commitc9c282cea04ec5a3ee7bd17e6ad8846600220feb (patch)
tree7714b28669469994919ab41331e8a27d38af4368 /guix
parent4fca58a6c6f0a5c7d3ac2363557fabeb6524865d (diff)
scripts: environment: Allow lists of packages in expressions.
* guix/scripts/environment.scm (options/resolve-packages): Match against lists of packages when evaluating expressions. * tests/guix-environment.sh: Add test. * doc/guix.texi ("invoking guix environment"): Add docs.
Diffstat (limited to 'guix')
-rw-r--r--guix/scripts/environment.scm24
1 files changed, 15 insertions, 9 deletions
diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm
index 188838574f..f9ab9a483f 100644
--- a/guix/scripts/environment.scm
+++ b/guix/scripts/environment.scm
@@ -253,6 +253,18 @@ COMMAND or an interactive shell in that environment.\n"))
(define (options/resolve-packages opts)
"Return OPTS with package specification strings replaced by actual
packages."
+ (define (package->outputs package mode)
+ (map (lambda (output)
+ (list mode package output))
+ (package-outputs package)))
+
+ (define (packages->outputs packages mode)
+ (match packages
+ ((? package? package)
+ (package->outputs package mode))
+ (((? package? packages) ...)
+ (append-map (cut package->outputs <> mode) packages))))
+
(compact
(append-map (match-lambda
(('package mode (? string? spec))
@@ -261,17 +273,11 @@ packages."
(list (list mode package output))))
(('expression mode str)
;; Add all the outputs of the package STR evaluates to.
- (match (read/eval str)
- ((? package? package)
- (map (lambda (output)
- (list mode package output))
- (package-outputs package)))))
+ (packages->outputs (read/eval str) mode))
(('load mode file)
;; Add all the outputs of the package defined in FILE.
- (let ((package (load* file (make-user-module '()))))
- (map (lambda (output)
- (list mode package output))
- (package-outputs package))))
+ (let ((module (make-user-module '())))
+ (packages->outputs (load* file module) mode)))
(_ '(#f)))
opts)))