diff options
author | Allen Nelson <anelson@narrativescience.com> | 2015-05-21 23:32:03 -0500 |
---|---|---|
committer | Allen Nelson <anelson@narrativescience.com> | 2015-05-24 10:21:33 -0500 |
commit | 06ff4af597a75a0854cbcb9c822b1fe38a466a98 (patch) | |
tree | 8e516303545c1362392d84c60497d01fec1ea665 /pkgs/development/python-modules/generic | |
parent | ee1f140d402c1647069ae996ccc176255c10bc23 (diff) |
Adding documentation to wrap.sh, added ability to retain any desired environment variables.
Diffstat (limited to 'pkgs/development/python-modules/generic')
-rw-r--r-- | pkgs/development/python-modules/generic/default.nix | 15 | ||||
-rw-r--r-- | pkgs/development/python-modules/generic/wrap.sh | 14 |
2 files changed, 25 insertions, 4 deletions
diff --git a/pkgs/development/python-modules/generic/default.nix b/pkgs/development/python-modules/generic/default.nix index b962e9f84727c..211c781b5d4ba 100644 --- a/pkgs/development/python-modules/generic/default.nix +++ b/pkgs/development/python-modules/generic/default.nix @@ -47,11 +47,24 @@ # Execute after shell hook , postShellHook ? "" +# Environment variables to set in wrapper scripts, in addition to +# PYTHONPATH and PATH. +, setEnvVars ? [] + , ... } @ attrs: # Keep extra attributes from `attrs`, e.g., `patchPhase', etc. -if disabled then throw "${name} not supported for interpreter ${python.executable}" else python.stdenv.mkDerivation (attrs // { +if disabled +then throw "${name} not supported for interpreter ${python.executable}" +else + +let + inherit (builtins) hasAttr; + inherit (lib) mapAttrs concatStringsSep optionals hasSuffix; +in + +python.stdenv.mkDerivation (attrs // { inherit doCheck; name = namePrefix + name; diff --git a/pkgs/development/python-modules/generic/wrap.sh b/pkgs/development/python-modules/generic/wrap.sh index 45f86df4dcffb..f9a65c6a33f3e 100644 --- a/pkgs/development/python-modules/generic/wrap.sh +++ b/pkgs/development/python-modules/generic/wrap.sh @@ -41,9 +41,17 @@ wrapPythonProgramsIn() { # wrapProgram creates the executable shell script described # above. The script will set PYTHONPATH and PATH variables.! # (see pkgs/build-support/setup-hooks/make-wrapper.sh) - wrapProgram $f \ - --prefix PYTHONPATH ':' $program_PYTHONPATH \ - --prefix PATH ':' $program_PATH + local wrap_args="$f \ + --prefix PYTHONPATH ':' $program_PYTHONPATH \ + --prefix PATH ':' $program_PATH" + + # Add any additional environment variables to propagate. + for env_var in $setEnvVars; do + # Look up the value of this variable + local value=$(eval "echo \$$env_var") + wrap_args="$wrap_args --set $env_var $value" + done + wrapProgram $wrap_args fi fi done |