guix environment: Add --ad-hoc option.
* guix/scripts/environment.scm (%options): Add "ad-hoc" option. (show-help): Display help for "--ad-hoc". (packages+propagated-inputs): New procedure. (guix-environment): Create ad hoc environment when asked. * doc/guix.texi ("invoking guix environment"): Document it.
This commit is contained in:
parent
1ba4796d13
commit
a54bd6d72d
|
@ -2381,7 +2381,7 @@ the @code{#:haddock-flags} parameter. If the file @code{Setup.hs} is
|
||||||
not found, the build system looks for @code{Setup.lhs} instead.
|
not found, the build system looks for @code{Setup.lhs} instead.
|
||||||
|
|
||||||
Which Haskell compiler is used can be specified with the @code{#:haskell}
|
Which Haskell compiler is used can be specified with the @code{#:haskell}
|
||||||
parameter which defaults to @code{ghc}.
|
parameter which defaults to @code{ghc}.
|
||||||
@end defvr
|
@end defvr
|
||||||
|
|
||||||
Lastly, for packages that do not need anything as sophisticated, a
|
Lastly, for packages that do not need anything as sophisticated, a
|
||||||
|
@ -3932,6 +3932,21 @@ evaluates to.
|
||||||
@item -E @var{command}
|
@item -E @var{command}
|
||||||
Execute @var{command} in the new environment.
|
Execute @var{command} in the new environment.
|
||||||
|
|
||||||
|
@item --ad-hoc
|
||||||
|
Include all specified packages in the resulting environment, as if an
|
||||||
|
@i{ad hoc} package were defined with them as inputs. This option is
|
||||||
|
useful for quickly creating an environment without having to write a
|
||||||
|
package expression to contain the desired inputs.
|
||||||
|
|
||||||
|
For instance, the command:
|
||||||
|
|
||||||
|
@example
|
||||||
|
guix environment --ad-hoc guile guile-sdl -E guile
|
||||||
|
@end example
|
||||||
|
|
||||||
|
runs @command{guile} in an environment where Guile and Guile-SDL are
|
||||||
|
available.
|
||||||
|
|
||||||
@item --pure
|
@item --pure
|
||||||
Unset existing environment variables when building the new environment.
|
Unset existing environment variables when building the new environment.
|
||||||
This has the effect of creating an environment in which search paths
|
This has the effect of creating an environment in which search paths
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
;;; GNU Guix --- Functional package management for GNU
|
;;; GNU Guix --- Functional package management for GNU
|
||||||
;;; Copyright © 2014 David Thompson <davet@gnu.org>
|
;;; Copyright © 2014, 2015 David Thompson <davet@gnu.org>
|
||||||
;;; Copyright © 2015 Ludovic Courtès <ludo@gnu.org>
|
;;; Copyright © 2015 Ludovic Courtès <ludo@gnu.org>
|
||||||
;;;
|
;;;
|
||||||
;;; This file is part of GNU Guix.
|
;;; This file is part of GNU Guix.
|
||||||
|
@ -102,6 +102,9 @@ shell command in that environment.\n"))
|
||||||
FILE evaluates to"))
|
FILE evaluates to"))
|
||||||
(display (_ "
|
(display (_ "
|
||||||
-E, --exec=COMMAND execute COMMAND in new environment"))
|
-E, --exec=COMMAND execute COMMAND in new environment"))
|
||||||
|
(display (_ "
|
||||||
|
--ad-hoc include all specified packages in the environment instead
|
||||||
|
of only their inputs"))
|
||||||
(display (_ "
|
(display (_ "
|
||||||
--pure unset existing environment variables"))
|
--pure unset existing environment variables"))
|
||||||
(display (_ "
|
(display (_ "
|
||||||
|
@ -147,6 +150,9 @@ shell command in that environment.\n"))
|
||||||
(option '(#\e "expression") #t #f
|
(option '(#\e "expression") #t #f
|
||||||
(lambda (opt name arg result)
|
(lambda (opt name arg result)
|
||||||
(alist-cons 'expression arg result)))
|
(alist-cons 'expression arg result)))
|
||||||
|
(option '("ad-hoc") #f #f
|
||||||
|
(lambda (opt name arg result)
|
||||||
|
(alist-cons 'ad-hoc? #t result)))
|
||||||
(option '(#\n "dry-run") #f #f
|
(option '(#\n "dry-run") #f #f
|
||||||
(lambda (opt name arg result)
|
(lambda (opt name arg result)
|
||||||
(alist-cons 'dry-run? #t result)))
|
(alist-cons 'dry-run? #t result)))
|
||||||
|
@ -191,6 +197,18 @@ packages."
|
||||||
(delete-duplicates
|
(delete-duplicates
|
||||||
(append-map transitive-inputs packages)))
|
(append-map transitive-inputs packages)))
|
||||||
|
|
||||||
|
(define (packages+propagated-inputs packages)
|
||||||
|
"Return a list containing PACKAGES plus all of their propagated inputs."
|
||||||
|
(delete-duplicates
|
||||||
|
(append packages
|
||||||
|
(map (match-lambda
|
||||||
|
((or (_ (? package? package))
|
||||||
|
(_ (? package? package) _))
|
||||||
|
package)
|
||||||
|
(_ #f))
|
||||||
|
(append-map package-transitive-propagated-inputs
|
||||||
|
packages)))))
|
||||||
|
|
||||||
(define (build-inputs inputs opts)
|
(define (build-inputs inputs opts)
|
||||||
"Build the packages in INPUTS using the build options in OPTS."
|
"Build the packages in INPUTS using the build options in OPTS."
|
||||||
(let ((substitutes? (assoc-ref opts 'substitutes?))
|
(let ((substitutes? (assoc-ref opts 'substitutes?))
|
||||||
|
@ -218,9 +236,12 @@ packages."
|
||||||
(let* ((opts (parse-command-line args %options (list %default-options)
|
(let* ((opts (parse-command-line args %options (list %default-options)
|
||||||
#:argument-handler handle-argument))
|
#:argument-handler handle-argument))
|
||||||
(pure? (assoc-ref opts 'pure))
|
(pure? (assoc-ref opts 'pure))
|
||||||
|
(ad-hoc? (assoc-ref opts 'ad-hoc?))
|
||||||
(command (assoc-ref opts 'exec))
|
(command (assoc-ref opts 'exec))
|
||||||
(inputs (packages->transitive-inputs
|
(packages (pick-all (options/resolve-packages opts) 'package))
|
||||||
(pick-all (options/resolve-packages opts) 'package)))
|
(inputs (if ad-hoc?
|
||||||
|
(packages+propagated-inputs packages)
|
||||||
|
(packages->transitive-inputs packages)))
|
||||||
(drvs (run-with-store store
|
(drvs (run-with-store store
|
||||||
(mbegin %store-monad
|
(mbegin %store-monad
|
||||||
(set-guile-for-build (default-guile))
|
(set-guile-for-build (default-guile))
|
||||||
|
|
Loading…
Reference in New Issue