From: David Thompson <dthompson2@worcester.edu>
To: guix-devel@gnu.org
Subject: [PATCH 2/2] environment: Add --inclusive option.
Date: Wed, 18 Mar 2015 20:11:46 -0400 [thread overview]
Message-ID: <87lhitzvzx.fsf@fsf.org> (raw)
In-Reply-To: <87r3slzw5i.fsf@fsf.org>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: 0002-environment-Add-inclusive-option.patch --]
[-- Type: text/x-diff, Size: 4175 bytes --]
From 3d97dbcf1907a67ed25fd90c09eb88d1b136d31a Mon Sep 17 00:00:00 2001
From: David Thompson <dthompson2@worcester.edu>
Date: Wed, 18 Mar 2015 20:01:12 -0400
Subject: [PATCH 2/2] environment: Add --inclusive option.
* guix/scripts/environment.scm (show-help): Add help.
(%default-options): Add 'inclusive?'.
(%options): Add 'inclusive' option.
(packages->transitive-inputs): Add 'inclusive?' argument.
(guix-environment): Use 'inclusive' option.
---
doc/guix.texi | 6 ++++++
guix/scripts/environment.scm | 20 +++++++++++++++-----
2 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index ae2f786..d552faf 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -3366,6 +3366,12 @@ evaluates to.
@item -E @var{command}
Execute @var{command} in the new environment.
+@item --inclusive
+@item -i
+Include @var{packages}@dots{} in the new environment in addition to
+their inputs. Useful for creating an environment from arbitrary
+packages without building another package object to house them.
+
@item --pure
Unset existing environment variables when building the new environment.
This has the effect of creating an environment in which search paths
diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm
index 80ae924..9788496 100644
--- a/guix/scripts/environment.scm
+++ b/guix/scripts/environment.scm
@@ -103,6 +103,8 @@ shell command in that environment.\n"))
(display (_ "
-E, --exec=COMMAND execute COMMAND in new environment"))
(display (_ "
+ -i, --inclusive include PACKAGE... in new environment"))
+ (display (_ "
--pure unset existing environment variables"))
(display (_ "
--search-paths display needed environment variable definitions"))
@@ -119,6 +121,7 @@ shell command in that environment.\n"))
(define %default-options
;; Default to opening a new shell.
`((exec . ,(or (getenv "SHELL") "/bin/sh"))
+ (inclusive? . #f)
(substitutes? . #t)
(max-silent-time . 3600)
(verbosity . 0)))
@@ -147,6 +150,9 @@ shell command in that environment.\n"))
(option '(#\e "expression") #t #f
(lambda (opt name arg result)
(alist-cons 'expression arg result)))
+ (option '(#\i "inclusive") #f #f
+ (lambda (opt name arg result)
+ (alist-cons 'inclusive? #t result)))
(option '(#\n "dry-run") #f #f
(lambda (opt name arg result)
(alist-cons 'dry-run? #t result)))
@@ -178,8 +184,9 @@ packages."
(opt opt))
opts))
-(define (packages->transitive-inputs packages)
- "Return a list of the transitive inputs for all PACKAGES."
+(define (packages->transitive-inputs packages inclusive?)
+ "Return a list of the transitive inputs for all PACKAGES. If INCLUSIVE?,
+include PACKAGES in the result."
(define (transitive-inputs package)
(filter-map (match-lambda
((or (_ (? package? package))
@@ -188,8 +195,10 @@ packages."
(_ #f))
(bag-transitive-inputs
(package->bag package))))
+
(delete-duplicates
- (append-map transitive-inputs packages)))
+ (append (if inclusive? packages '())
+ (append-map transitive-inputs packages))))
;; TODO: Deduplicate these.
(define show-what-to-build*
@@ -225,9 +234,10 @@ packages."
(let* ((opts (parse-command-line args %options (list %default-options)
#:argument-handler handle-argument))
(pure? (assoc-ref opts 'pure))
+ (inclusive? (assoc-ref opts 'inclusive?))
(command (assoc-ref opts 'exec))
- (inputs (packages->transitive-inputs
- (pick-all (options/resolve-packages opts) 'package)))
+ (packages (pick-all (options/resolve-packages opts) 'package))
+ (inputs (packages->transitive-inputs packages inclusive?))
(drvs (run-with-store store
(mbegin %store-monad
(set-guile-for-build (default-guile))
--
2.1.4
[-- Attachment #2: Type: text/plain, Size: 136 bytes --]
--
David Thompson
Web Developer - Free Software Foundation - http://fsf.org
GPG Key: 0FF1D807
Support the FSF: https://fsf.org/donate
next prev parent reply other threads:[~2015-03-19 0:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-19 0:08 [PATCH 0/2] environment: Add --inclusive option David Thompson
2015-03-19 0:11 ` [PATCH 1/2] packages: Expose transitive-inputs David Thompson
2015-03-19 10:34 ` David Thompson
2015-03-19 0:11 ` David Thompson [this message]
2015-03-20 0:55 ` [PATCH 2/2] environment: Add --inclusive option David Thompson
2015-03-20 19:20 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87lhitzvzx.fsf@fsf.org \
--to=dthompson2@worcester.edu \
--cc=guix-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).