guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/2] environment: Add --inclusive option.


From: David Thompson
Subject: [PATCH 2/2] environment: Add --inclusive option.
Date: Wed, 18 Mar 2015 20:11:46 -0400
User-agent: Notmuch/0.18.2 (http://notmuchmail.org) Emacs/24.4.1 (x86_64-pc-linux-gnu)

>From 3d97dbcf1907a67ed25fd90c09eb88d1b136d31a Mon Sep 17 00:00:00 2001
From: David Thompson <address@hidden>
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.
 
address@hidden --inclusive
address@hidden -i
+Include @address@hidden 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

-- 
David Thompson
Web Developer - Free Software Foundation - http://fsf.org
GPG Key: 0FF1D807
Support the FSF: https://fsf.org/donate

reply via email to

[Prev in Thread] Current Thread [Next in Thread]