From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Thompson Subject: [PATCH 2/2] environment: Add --inclusive option. Date: Wed, 18 Mar 2015 20:11:46 -0400 Message-ID: <87lhitzvzx.fsf@fsf.org> References: <87r3slzw5i.fsf@fsf.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48401) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YYO3w-0000YR-GG for guix-devel@gnu.org; Wed, 18 Mar 2015 20:11:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YYO3v-0004V4-5C for guix-devel@gnu.org; Wed, 18 Mar 2015 20:11:48 -0400 Received: from mail.fsf.org ([208.118.235.13]:33670) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YYO3v-0004V0-2d for guix-devel@gnu.org; Wed, 18 Mar 2015 20:11:47 -0400 Received: from 209-6-40-86.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com ([209.6.40.86]:53512 helo=izanagi) by mail.fsf.org with esmtpsa (TLS-1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.69) (envelope-from ) id 1YYO3u-0000uA-QW for guix-devel@gnu.org; Wed, 18 Mar 2015 20:11:46 -0400 In-Reply-To: <87r3slzw5i.fsf@fsf.org> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: guix-devel@gnu.org --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0002-environment-Add-inclusive-option.patch >From 3d97dbcf1907a67ed25fd90c09eb88d1b136d31a Mon Sep 17 00:00:00 2001 From: David Thompson 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 --=-=-= Content-Type: text/plain -- David Thompson Web Developer - Free Software Foundation - http://fsf.org GPG Key: 0FF1D807 Support the FSF: https://fsf.org/donate --=-=-=--