From c9c282cea04ec5a3ee7bd17e6ad8846600220feb Mon Sep 17 00:00:00 2001 From: David Thompson Date: Fri, 30 Oct 2015 21:02:51 -0400 Subject: 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. --- guix/scripts/environment.scm | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'guix') 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))) -- cgit v1.2.3