diff options
| -rw-r--r-- | doc/guix.texi | 9 | ||||
| -rw-r--r-- | guix/scripts/environment.scm | 22 | ||||
| -rw-r--r-- | tests/guix-environment.sh | 9 |
3 files changed, 39 insertions, 1 deletions
diff --git a/doc/guix.texi b/doc/guix.texi index ee70994585b..fb2834942b2 100644 --- a/doc/guix.texi +++ b/doc/guix.texi | |||
| @@ -7231,6 +7231,15 @@ As an example, @var{file} might contain a definition like this | |||
| 7231 | @verbatiminclude environment-gdb.scm | 7231 | @verbatiminclude environment-gdb.scm |
| 7232 | @end example | 7232 | @end example |
| 7233 | 7233 | ||
| 7234 | @item --manifest=@var{file} | ||
| 7235 | @itemx -m @var{file} | ||
| 7236 | Create an environment for the packages contained in the manifest object | ||
| 7237 | returned by the Scheme code in @var{file}. | ||
| 7238 | |||
| 7239 | This is similar to the same-named option in @command{guix package} | ||
| 7240 | (@pxref{profile-manifest, @option{--manifest}}) and uses the same | ||
| 7241 | manifest files. | ||
| 7242 | |||
| 7234 | @item --ad-hoc | 7243 | @item --ad-hoc |
| 7235 | Include all specified packages in the resulting environment, as if an | 7244 | Include all specified packages in the resulting environment, as if an |
| 7236 | @i{ad hoc} package were defined with them as inputs. This option is | 7245 | @i{ad hoc} package were defined with them as inputs. This option is |
diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm index d2568e6a7da..67da6fc3bf0 100644 --- a/guix/scripts/environment.scm +++ b/guix/scripts/environment.scm | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | 1 | ;;; GNU Guix --- Functional package management for GNU |
| 2 | ;;; Copyright © 2014, 2015 David Thompson <davet@gnu.org> | 2 | ;;; Copyright © 2014, 2015, 2018 David Thompson <davet@gnu.org> |
| 3 | ;;; Copyright © 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org> | 3 | ;;; Copyright © 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org> |
| 4 | ;;; | 4 | ;;; |
| 5 | ;;; This file is part of GNU Guix. | 5 | ;;; This file is part of GNU Guix. |
| @@ -142,6 +142,8 @@ COMMAND or an interactive shell in that environment.\n")) | |||
| 142 | -l, --load=FILE create environment for the package that the code within | 142 | -l, --load=FILE create environment for the package that the code within |
| 143 | FILE evaluates to")) | 143 | FILE evaluates to")) |
| 144 | (display (G_ " | 144 | (display (G_ " |
| 145 | -m, --manifest=FILE create environment with the manifest from FILE")) | ||
| 146 | (display (G_ " | ||
| 145 | --ad-hoc include all specified packages in the environment instead | 147 | --ad-hoc include all specified packages in the environment instead |
| 146 | of only their inputs")) | 148 | of only their inputs")) |
| 147 | (display (G_ " | 149 | (display (G_ " |
| @@ -220,6 +222,11 @@ COMMAND or an interactive shell in that environment.\n")) | |||
| 220 | (alist-cons 'expression | 222 | (alist-cons 'expression |
| 221 | (tag-package-arg result arg) | 223 | (tag-package-arg result arg) |
| 222 | result))) | 224 | result))) |
| 225 | (option '(#\m "manifest") #t #f | ||
| 226 | (lambda (opt name arg result) | ||
| 227 | (alist-cons 'manifest | ||
| 228 | arg | ||
| 229 | result))) | ||
| 223 | (option '("ad-hoc") #f #f | 230 | (option '("ad-hoc") #f #f |
| 224 | (lambda (opt name arg result) | 231 | (lambda (opt name arg result) |
| 225 | (alist-cons 'ad-hoc? #t result))) | 232 | (alist-cons 'ad-hoc? #t result))) |
| @@ -286,6 +293,16 @@ packages." | |||
| 286 | (((? package-or-package+output?) ...) ; many packages | 293 | (((? package-or-package+output?) ...) ; many packages |
| 287 | (map (cut package->output <> mode) packages)))) | 294 | (map (cut package->output <> mode) packages)))) |
| 288 | 295 | ||
| 296 | (define (manifest->outputs manifest) | ||
| 297 | (map (lambda (entry) | ||
| 298 | (cons 'ad-hoc-package ; manifests are implicitly ad-hoc | ||
| 299 | (if (package? (manifest-entry-item entry)) | ||
| 300 | (list (manifest-entry-item entry) | ||
| 301 | (manifest-entry-output entry)) | ||
| 302 | ;; Direct store paths have no output. | ||
| 303 | (list (manifest-entry-item entry))))) | ||
| 304 | (manifest-entries manifest))) | ||
| 305 | |||
| 289 | (compact | 306 | (compact |
| 290 | (append-map (match-lambda | 307 | (append-map (match-lambda |
| 291 | (('package mode (? string? spec)) | 308 | (('package mode (? string? spec)) |
| @@ -299,6 +316,9 @@ packages." | |||
| 299 | ;; Add all the outputs of the package defined in FILE. | 316 | ;; Add all the outputs of the package defined in FILE. |
| 300 | (let ((module (make-user-module '()))) | 317 | (let ((module (make-user-module '()))) |
| 301 | (packages->outputs (load* file module) mode))) | 318 | (packages->outputs (load* file module) mode))) |
| 319 | (('manifest . file) | ||
| 320 | (let ((module (make-user-module '()))) | ||
| 321 | (manifest->outputs (load* file module)))) | ||
| 302 | (_ '(#f))) | 322 | (_ '(#f))) |
| 303 | opts))) | 323 | opts))) |
| 304 | 324 | ||
diff --git a/tests/guix-environment.sh b/tests/guix-environment.sh index bf5ca17fa54..b44aca099d3 100644 --- a/tests/guix-environment.sh +++ b/tests/guix-environment.sh | |||
| @@ -62,6 +62,15 @@ fi | |||
| 62 | guix environment --bootstrap --ad-hoc guile-bootstrap --pure \ | 62 | guix environment --bootstrap --ad-hoc guile-bootstrap --pure \ |
| 63 | -- "$SHELL" -c 'test -f "$GUIX_ENVIRONMENT/bin/guile"' | 63 | -- "$SHELL" -c 'test -f "$GUIX_ENVIRONMENT/bin/guile"' |
| 64 | 64 | ||
| 65 | # Make sure 'GUIX_ENVIRONMENT' points to the profile when building from a | ||
| 66 | # manifest. | ||
| 67 | echo "(use-modules (guix profiles) (gnu packages bootstrap)) | ||
| 68 | |||
| 69 | (packages->manifest (list %bootstrap-guile)) | ||
| 70 | " > $tmpdir/manifest.scm | ||
| 71 | guix environment --bootstrap --manifest=$tmpdir/manifest.scm --pure \ | ||
| 72 | -- "$SHELL" -c 'test -f "$GUIX_ENVIRONMENT/bin/guile"' | ||
| 73 | |||
| 65 | # Make sure '-r' works as expected. | 74 | # Make sure '-r' works as expected. |
| 66 | rm -f "$gcroot" | 75 | rm -f "$gcroot" |
| 67 | expected="`guix environment --bootstrap --ad-hoc guile-bootstrap \ | 76 | expected="`guix environment --bootstrap --ad-hoc guile-bootstrap \ |
