GNU bug report logs - #34486
[PATCH 0/1] Add '--inherit' to 'guix environment'

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guix-patches; Reported by: Ludovic Courtès <ludo@HIDDEN>; Keywords: patch; dated Fri, 15 Feb 2019 10:44:01 UTC; Maintainer for guix-patches is guix-patches@HIDDEN.

Message received at 34486 <at> debbugs.gnu.org:


Received: (at 34486) by debbugs.gnu.org; 15 Feb 2019 14:55:01 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Feb 15 09:55:01 2019
Received: from localhost ([127.0.0.1]:48725 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1guetI-00007b-Se
	for submit <at> debbugs.gnu.org; Fri, 15 Feb 2019 09:55:01 -0500
Received: from sender-of-o51.zoho.com ([135.84.80.216]:21051)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rekado@HIDDEN>) id 1guetG-00007Q-Qt
 for 34486 <at> debbugs.gnu.org; Fri, 15 Feb 2019 09:54:59 -0500
ARC-Seal: i=1; a=rsa-sha256; t=1550242478; cv=none; d=zoho.com; s=zohoarc; 
 b=CkVI7E6pEq73rEMncJXJLX9GkvV0SB05rT8mPiGeApeLafSBBgXuz3XydwjX7in1nHn7Z5ewH9osc5cNP7Iv8L+uF+5Q8DeeX1gaBXERnWSihuyUog0HvhVKSGSeEEtDty6SfvbR909bEMpIQr4/5WPMMGIm3wDYGKk4OMLNf1s=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com;
 s=zohoarc; t=1550242478;
 h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To:ARC-Authentication-Results;
 bh=gmJqFKOAbXJBGZ51vkYq5gta4hgQHrra3OhWqutAp/o=; 
 b=nC2VL6HYekb18C16Tu0WTb9HJJZ504LVzBYSOK89a9zuLAQEpN0O5YOorCbJoyn4jSUc/bUnYdEJ5ytt4MEw+0n6wn5U3Gk4vyNMHt1PPtHDNTK/AtRJzgow+2w97mcRv4jwppVrxK10eC9mNRvvomImVJEobNxzpznG7ejGZno=
ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass  header.i=elephly.net;
 spf=pass  smtp.mailfrom=rekado@HIDDEN;
 dmarc=pass header.from=<rekado@HIDDEN> header.from=<rekado@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1550242478; 
 s=zoho; d=elephly.net; i=rekado@HIDDEN;
 h=References:From:To:Cc:Subject:In-reply-to:Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding;
 l=1014; bh=gmJqFKOAbXJBGZ51vkYq5gta4hgQHrra3OhWqutAp/o=;
 b=QbcDrEzz8bv59jZVqntevIY7fZua31Ua0pwKGcxfrxqZUy8r09L/5W+Bqt0irYxd
 r/BcNRM9oISFzFXVnS+EoiMkvOptbOi09SgTKHROorZ3/hj1dpY+4B3msKKkBKQtxaY
 rE4nVeKP6nJxp9Ivlnm48s4cm/cKuLsgGymAYTSU=
Received: from localhost (141.80.238.36 [141.80.238.36]) by mx.zohomail.com
 with SMTPS id 1550242476140369.51977886377824;
 Fri, 15 Feb 2019 06:54:36 -0800 (PST)
References: <20190215104257.16275-1-ludo@HIDDEN>
User-agent: mu4e 1.0; emacs 26.1
From: Ricardo Wurmus <rekado@HIDDEN>
To: Ludovic =?utf-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
Subject: Re: [bug#34486] [PATCH 0/1] Add '--inherit' to 'guix environment'
In-reply-to: <20190215104257.16275-1-ludo@HIDDEN>
X-URL: https://elephly.net
X-PGP-Key: https://elephly.net/rekado.pubkey
X-PGP-Fingerprint: BCA6 89B6 3655 3801 C3C6  2150 197A 5888 235F ACAC
Date: Fri, 15 Feb 2019 15:54:33 +0100
Message-ID: <87va1lrtjq.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-ZohoMailClient: External
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 34486
Cc: 34486 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


Hi,

Ludovic Court=C3=A8s <ludo@HIDDEN> writes:

> This new option allows to specify additional variables to be inherited
> in a =E2=80=9Cpure=E2=80=9D (semi-pure?) environment.
>
> The main motivation was the use of the SLURM batch scheduler, which
> defines environment variables that you need to preserve so that things
> like =E2=80=98mpirun=E2=80=99 work correctly.

Looks good to me.  The same is needed for Grid Engine.  Previously I
would use =E2=80=9Cenv=E2=80=9D with an installed profile for the same effe=
ct:

--8<---------------cut here---------------start------------->8---
#!/bin/bash

profile=3D/path/to/.guix-profile
exec /bin/env - PATH=3D/opt/uge/bin/lx-amd64 \
                SGE_CELL=3Ddefault \
                SGE_ARCH=3Dlx-amd64 =E2=80=A6
                GUIX_LOCPATH=3D=E2=80=A6 \
                /bin/bash --init-file "$profile/etc/profile"
--8<---------------cut here---------------end--------------->8---

I guess the only thing that=E2=80=99s missing now is to activate an install=
ed
environment.

--
Ricardo





Information forwarded to guix-patches@HIDDEN:
bug#34486; Package guix-patches. Full text available.

Message received at 34486 <at> debbugs.gnu.org:


Received: (at 34486) by debbugs.gnu.org; 15 Feb 2019 14:34:37 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Feb 15 09:34:37 2019
Received: from localhost ([127.0.0.1]:48698 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1gueZY-0007yU-P3
	for submit <at> debbugs.gnu.org; Fri, 15 Feb 2019 09:34:36 -0500
Received: from mail-wr1-f54.google.com ([209.85.221.54]:38794)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dthompson2@HIDDEN>) id 1gueZV-0007yG-JA
 for 34486 <at> debbugs.gnu.org; Fri, 15 Feb 2019 09:34:34 -0500
Received: by mail-wr1-f54.google.com with SMTP id v13so10567608wrw.5
 for <34486 <at> debbugs.gnu.org>; Fri, 15 Feb 2019 06:34:33 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=worcester-edu.20150623.gappssmtp.com; s=20150623;
 h=mime-version:references:in-reply-to:from:date:message-id:subject:to
 :cc:content-transfer-encoding;
 bh=hLTSqA94hz2Le3euc5NiJHvKgkMdkHeT77H2IwtY4zI=;
 b=tfnoi6tMeA9FpL7hJ8+zmVXa2sz+fzeGPRumGQTXBND1pINCUDFF+0wsAzd949ioF3
 XOVeOv9jwCnutXf0Yv9GijlfaXabxejodPqzeb6NnGz6uv0uJERqofGEmI7ywUJ1jDls
 SOmZMywx+xXH0yRSG5afET5wtDBtsw1/p8l7mvoUzxBYhrhjeGSOcQquedDJX8z6QrNE
 +oIeMnvztO1vkHfFOJWtZm5FbAI2PMiCKWSacA6PibcywQ/ix8RA7/2cHh6pJw2RtvZl
 f7+0F/GfSNRGkCwAdcG4BLPAaXrLXqWW03ExtzRmQGJo7WkM///n3rfBuySlLTiPCHdp
 uniA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:references:in-reply-to:from:date
 :message-id:subject:to:cc:content-transfer-encoding;
 bh=hLTSqA94hz2Le3euc5NiJHvKgkMdkHeT77H2IwtY4zI=;
 b=Ugyi82cZqqoK4yILQ0PYvp8RyvPf5wt3tBFRX0FN13vIY4sPdMutt+tG4Q1eVE7+h9
 3NEi2IpOB55Zwq/ms97gAk40B0ZAZB2u7rPaBkleWX1V6BlYgvS6YX6BOorgVIiYqcyI
 ITbqq2wUIKZEqmRMCRQFXWrRIQ/3qxNs+WZ1PpXPz5DSnOrFkKvehcYPejQzWAem2OF9
 hvaikHnadGzMe+l9ajS/hBr9HI2M0soOJLQUiqfkEzFwaCsmrpg+otNp0whzTo3Vcqhx
 F0hiwq5kNF3bOAsaGTdO7FSukj8rXhIghrCuLsB8kFUImRZYzVIJ6NY6q95RaLMSyllf
 JH9g==
X-Gm-Message-State: AHQUAuYhqErWUUCAHUKahmcRTby9JelMz4qs3oVE1yE2bMFvum2zsQnb
 gm1xNoubXuCdO7tJP+m1quUNLtKFnINnl4UlowTIxw==
X-Google-Smtp-Source: AHgI3IZzJqJARtW+eKrvUr+fnFuv4LVUKz2mS9YItzdJH/2SbgwbSo9dZgGzxjBauVqT8Q2vZzBu7IIZogA6OAVDfmc=
X-Received: by 2002:adf:b784:: with SMTP id s4mr6967940wre.155.1550241267591; 
 Fri, 15 Feb 2019 06:34:27 -0800 (PST)
MIME-Version: 1.0
References: <20190215104257.16275-1-ludo@HIDDEN>
 <20190215104928.16509-1-ludo@HIDDEN>
In-Reply-To: <20190215104928.16509-1-ludo@HIDDEN>
From: "Thompson, David" <dthompson2@HIDDEN>
Date: Fri, 15 Feb 2019 09:34:16 -0500
Message-ID: <CAJ=Rwfa_90sHgjn8-pzboMZNYgyP86N60UvLNGPynWh-5JPzdw@HIDDEN>
Subject: Re: [bug#34486] [PATCH 1/1] environment: Add '--inherit'.
To: =?UTF-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 34486
Cc: 34486 <at> debbugs.gnu.org,
 =?UTF-8?Q?Ludovic_Court=C3=A8s?= <ludovic.courtes@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hi Ludo,

On Fri, Feb 15, 2019 at 6:07 AM Ludovic Court=C3=A8s <ludo@HIDDEN> wrote:
>
> From: Ludovic Court=C3=A8s <ludovic.courtes@HIDDEN>
>
> * guix/scripts/environment.scm (purify-environment): Add 'white-list'
> parameter and honor it.
> (create-environment): Add #:white-list parameter and honor it.
> (launch-environment): Likewise.
> (launch-environment/fork): Likewise.
> (show-help, %options): Add '--inherit'.
> (guix-environment): Define 'white-list' and pass it to
> 'launch-environment/fork'.
> * tests/guix-environment.sh: Test '--inherit'.
> * doc/guix.texi (Invoking guix environment): Document it.

Seems like a good addition to me!

- Dave




Information forwarded to guix-patches@HIDDEN:
bug#34486; Package guix-patches. Full text available.

Message received at 34486 <at> debbugs.gnu.org:


Received: (at 34486) by debbugs.gnu.org; 15 Feb 2019 10:49:41 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Feb 15 05:49:41 2019
Received: from localhost ([127.0.0.1]:48618 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1gub3t-0008LR-1z
	for submit <at> debbugs.gnu.org; Fri, 15 Feb 2019 05:49:41 -0500
Received: from hera.aquilenet.fr ([185.233.100.1]:39650)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1gub3p-0008LH-30
 for 34486 <at> debbugs.gnu.org; Fri, 15 Feb 2019 05:49:38 -0500
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 6608AFFD3;
 Fri, 15 Feb 2019 11:49:35 +0100 (CET)
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id kdmAbMDyecer; Fri, 15 Feb 2019 11:49:33 +0100 (CET)
Received: from gnu.org (unknown [147.99.110.178])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id A9AB7FFCF;
 Fri, 15 Feb 2019 11:49:33 +0100 (CET)
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@HIDDEN>
To: 34486 <at> debbugs.gnu.org
Subject: [PATCH 1/1] environment: Add '--inherit'.
Date: Fri, 15 Feb 2019 11:49:28 +0100
Message-Id: <20190215104928.16509-1-ludo@HIDDEN>
X-Mailer: git-send-email 2.20.1
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 34486
Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludovic.courtes@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

From: Ludovic Courtès <ludovic.courtes@HIDDEN>

* guix/scripts/environment.scm (purify-environment): Add 'white-list'
parameter and honor it.
(create-environment): Add #:white-list parameter and honor it.
(launch-environment): Likewise.
(launch-environment/fork): Likewise.
(show-help, %options): Add '--inherit'.
(guix-environment): Define 'white-list' and pass it to
'launch-environment/fork'.
* tests/guix-environment.sh: Test '--inherit'.
* doc/guix.texi (Invoking guix environment): Document it.
---
 doc/guix.texi                | 21 ++++++++++++--
 guix/scripts/environment.scm | 53 +++++++++++++++++++++++++-----------
 tests/guix-environment.sh    | 15 +++++++++-
 3 files changed, 69 insertions(+), 20 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 1ac077d98a..68d39ed02f 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -4454,9 +4454,24 @@ default behavior.  Packages appearing after are interpreted as packages
 that will be added to the environment directly.
 
 @item --pure
-Unset existing environment variables when building the new environment.
-This has the effect of creating an environment in which search paths
-only contain package inputs.
+Unset existing environment variables when building the new environment, except
+those specified with @option{--inherit} (see below.)  This has the effect of
+creating an environment in which search paths only contain package inputs.
+
+@item --inherit=@var{regexp}
+When used alongside @option{--pure}, inherit all the environment variables
+matching @var{regexp}---in other words, put them on a ``white list'' of
+environment variables that must be preserved.
+
+@example
+guix environment --pure --inherit=^SLURM --ad-hoc openmpi @dots{} \
+  -- mpirun @dots{}
+@end example
+
+This example runs @command{mpirun} in a context where the only environment
+variables defined are @code{PATH}, environment variables whose name starts
+with @code{SLURM}, as well as the usual ``precious'' variables (@code{HOME},
+@code{USER}, etc.)
 
 @item --search-paths
 Display the environment variable definitions that make up the
diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm
index 3143ea9281..3966531efa 100644
--- a/guix/scripts/environment.scm
+++ b/guix/scripts/environment.scm
@@ -57,20 +57,27 @@
 (define %default-shell
   (or (getenv "SHELL") "/bin/sh"))
 
-(define (purify-environment)
-  "Unset almost all environment variables.  A small number of variables such
-as 'HOME' and 'USER' are left untouched."
+(define (purify-environment white-list)
+  "Unset all environment variables except those that match the regexps in
+WHITE-LIST and those listed in %PRECIOUS-VARIABLES.  A small number of
+variables such as 'HOME' and 'USER' are left untouched."
   (for-each unsetenv
-            (remove (cut member <> %precious-variables)
+            (remove (lambda (variable)
+                      (or (member variable %precious-variables)
+                          (find (cut regexp-exec <> variable)
+                                white-list)))
                     (match (get-environment-variables)
                       (((names . _) ...)
                        names)))))
 
-(define* (create-environment profile manifest #:key pure?)
-  "Set the environment variables specified by MANIFEST for PROFILE.  When PURE?
-is #t, unset the variables in the current environment.  Otherwise, augment
-existing environment variables with additional search paths."
-  (when pure? (purify-environment))
+(define* (create-environment profile manifest
+                             #:key pure? (white-list '()))
+  "Set the environment variables specified by MANIFEST for PROFILE.  When
+PURE?  is #t, unset the variables in the current environment except those that
+match the regexps in WHITE-LIST.  Otherwise, augment existing environment
+variables with additional search paths."
+  (when pure?
+    (purify-environment white-list))
   (for-each (match-lambda
               ((($ <search-path-specification> variable _ separator) . value)
                (let ((current (getenv variable)))
@@ -133,6 +140,8 @@ COMMAND or an interactive shell in that environment.\n"))
                          of only their inputs"))
   (display (G_ "
       --pure             unset existing environment variables"))
+  (display (G_ "
+      --inherit=REGEXP   inherit environment variables that match REGEXP"))
   (display (G_ "
       --search-paths     display needed environment variable definitions"))
   (display (G_ "
@@ -206,6 +215,11 @@ COMMAND or an interactive shell in that environment.\n"))
          (option '("pure") #f #f
                  (lambda (opt name arg result)
                    (alist-cons 'pure #t result)))
+         (option '("inherit") #t #f
+                 (lambda (opt name arg result)
+                   (alist-cons 'inherit-regexp
+                               (make-regexp* arg)
+                               result)))
          (option '(#\E "exec") #t #f ; deprecated
                  (lambda (opt name arg result)
                    (alist-cons 'exec (list %default-shell "-c" arg) result)))
@@ -397,25 +411,30 @@ and suitable for 'exit'."
 (define primitive-exit/status (compose primitive-exit status->exit-code))
 
 (define* (launch-environment command profile manifest
-                             #:key pure?)
+                             #:key pure? (white-list '()))
   "Run COMMAND in a new environment containing INPUTS, using the native search
 paths defined by the list PATHS.  When PURE?, pre-existing environment
-variables are cleared before setting the new ones."
+variables are cleared before setting the new ones, except those matching the
+regexps in WHITE-LIST."
   ;; Properly handle SIGINT, so pressing C-c in an interactive terminal
   ;; application works.
   (sigaction SIGINT SIG_DFL)
-  (create-environment profile manifest #:pure? pure?)
+  (create-environment profile manifest
+                      #:pure? pure? #:white-list white-list)
   (match command
     ((program . args)
      (apply execlp program program args))))
 
-(define* (launch-environment/fork command profile manifest #:key pure?)
+(define* (launch-environment/fork command profile manifest
+                                  #:key pure? (white-list '()))
   "Run COMMAND in a new process with an environment containing PROFILE, with
 the search paths specified by MANIFEST.  When PURE?, pre-existing environment
-variables are cleared before setting the new ones."
+variables are cleared before setting the new ones, except those matching the
+regexps in WHITE-LIST."
   (match (primitive-fork)
     (0 (launch-environment command profile manifest
-                           #:pure? pure?))
+                           #:pure? pure?
+                           #:white-list white-list))
     (pid (match (waitpid pid)
            ((_ . status) status)))))
 
@@ -672,7 +691,8 @@ message if any test fails."
                                ;; within the container.
                                '("/bin/sh")
                                (list %default-shell))))
-           (mappings   (pick-all opts 'file-system-mapping)))
+           (mappings   (pick-all opts 'file-system-mapping))
+           (white-list (pick-all opts 'inherit-regexp)))
 
       (when container? (assert-container-features))
 
@@ -741,4 +761,5 @@ message if any test fails."
                     (return
                      (exit/status
                       (launch-environment/fork command profile manifest
+                                               #:white-list white-list
                                                #:pure? pure?))))))))))))))
diff --git a/tests/guix-environment.sh b/tests/guix-environment.sh
index 30b21028aa..ccbe027c7b 100644
--- a/tests/guix-environment.sh
+++ b/tests/guix-environment.sh
@@ -1,5 +1,5 @@
 # GNU Guix --- Functional package management for GNU
-# Copyright © 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@HIDDEN>
+# Copyright © 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@HIDDEN>
 #
 # This file is part of GNU Guix.
 #
@@ -49,6 +49,19 @@ test -x `sed -r 's/^export PATH="(.*)"/\1/' "$tmpdir/a"`/guile
 
 cmp "$tmpdir/a" "$tmpdir/b"
 
+# Check '--inherit'.
+GUIX_TEST_ABC=1
+GUIX_TEST_DEF=2
+GUIX_TEST_XYZ=3
+export GUIX_TEST_ABC GUIX_TEST_DEF GUIX_TEST_XYZ
+guix environment --bootstrap --ad-hoc guile-bootstrap --pure	\
+     --inherit='^GUIX_TEST_A' --inherit='^GUIX_TEST_D'		\
+     -- "$SHELL" -c set > "$tmpdir/a"
+grep '^PATH=' "$tmpdir/a"
+grep '^GUIX_TEST_ABC=' "$tmpdir/a"
+grep '^GUIX_TEST_DEF=' "$tmpdir/a"
+if grep '^GUIX_TEST_XYZ=' "$tmpdir/a"; then false; else true; fi
+
 # Make sure the exit value is preserved.
 if guix environment --bootstrap --ad-hoc guile-bootstrap --pure \
         -- guile -c '(exit 42)'
-- 
2.20.1





Information forwarded to guix-patches@HIDDEN:
bug#34486; Package guix-patches. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 15 Feb 2019 10:43:24 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Feb 15 05:43:24 2019
Received: from localhost ([127.0.0.1]:48612 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1guaxo-0008Br-8c
	for submit <at> debbugs.gnu.org; Fri, 15 Feb 2019 05:43:24 -0500
Received: from eggs.gnu.org ([209.51.188.92]:49844)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1guaxm-0008Bf-Ma
 for submit <at> debbugs.gnu.org; Fri, 15 Feb 2019 05:43:22 -0500
Received: from lists.gnu.org ([209.51.188.17]:58541)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <ludo@HIDDEN>) id 1guaxe-0005F5-Rp
 for submit <at> debbugs.gnu.org; Fri, 15 Feb 2019 05:43:15 -0500
Received: from eggs.gnu.org ([209.51.188.92]:35967)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <ludo@HIDDEN>) id 1guaxe-0005Nw-3O
 for guix-patches@HIDDEN; Fri, 15 Feb 2019 05:43:14 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_40,URIBL_BLOCKED
 autolearn=disabled version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <ludo@HIDDEN>) id 1guaxd-0005AU-GW
 for guix-patches@HIDDEN; Fri, 15 Feb 2019 05:43:14 -0500
Received: from hera.aquilenet.fr ([2a0c:e300::1]:50364)
 by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <ludo@HIDDEN>)
 id 1guaxb-0004pv-EM; Fri, 15 Feb 2019 05:43:11 -0500
Received: from localhost (localhost [127.0.0.1])
 by hera.aquilenet.fr (Postfix) with ESMTP id 82AF7F61A;
 Fri, 15 Feb 2019 11:43:06 +0100 (CET)
X-Virus-Scanned: Debian amavisd-new at aquilenet.fr
Received: from hera.aquilenet.fr ([127.0.0.1])
 by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id FubWdbvj3IU8; Fri, 15 Feb 2019 11:43:03 +0100 (CET)
Received: from gnu.org (unknown [147.99.110.178])
 by hera.aquilenet.fr (Postfix) with ESMTPSA id 829E81B31;
 Fri, 15 Feb 2019 11:43:03 +0100 (CET)
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@HIDDEN>
To: guix-patches@HIDDEN
Subject: [PATCH 0/1] Add '--inherit' to 'guix environment'
Date: Fri, 15 Feb 2019 11:42:57 +0100
Message-Id: <20190215104257.16275-1-ludo@HIDDEN>
X-Mailer: git-send-email 2.20.1
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
 recognized.
X-Received-From: 2a0c:e300::1
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: submit
Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hello,

This new option allows to specify additional variables to be inherited
in a =E2=80=9Cpure=E2=80=9D (semi-pure?) environment.

The main motivation was the use of the SLURM batch scheduler, which
defines environment variables that you need to preserve so that things
like =E2=80=98mpirun=E2=80=99 work correctly.

Thoughts?

Ludo=E2=80=99.

Ludovic Court=C3=A8s (1):
  environment: Add '--inherit'.

 doc/guix.texi                | 21 ++++++++++++--
 guix/scripts/environment.scm | 53 +++++++++++++++++++++++++-----------
 tests/guix-environment.sh    | 15 +++++++++-
 3 files changed, 69 insertions(+), 20 deletions(-)

--=20
2.20.1





Acknowledgement sent to Ludovic Courtès <ludo@HIDDEN>:
New bug report received and forwarded. Copy sent to guix-patches@HIDDEN. Full text available.
Report forwarded to guix-patches@HIDDEN:
bug#34486; Package guix-patches. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 15 Feb 2019 15:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.