From efbb5de1c50b8b9ff05713e7c3ab170a9652cc07 Mon Sep 17 00:00:00 2001 From: Jascha Geerds Date: Sat, 9 Aug 2014 22:56:07 +0200 Subject: [PATCH] Refactoring --- pkgs/top-level/python-packages.nix | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index d2fcaed4c43..46bed87a3b6 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -8168,14 +8168,26 @@ rec { patchPhase = '' substituteInPlace "virtualenvwrapper.sh" --replace "which" "${pkgs.which}/bin/which" substituteInPlace "virtualenvwrapper_lazy.sh" --replace "which" "${pkgs.which}/bin/which" + ''; + postInstall = '' # This might look like a dirty hack but we can't use the makeWrapper function because # the wrapped file were then called via "exec". The virtualenvwrapper shell scripts # aren't normal executables. Instead, the user has to evaluate them. + for file in "virtualenvwrapper.sh" "virtualenvwrapper_lazy.sh"; do - # Insert the required PATH & PYTHONPATH variables right on the top - sed -i "2iexport PATH=$PATH:\$PATH" "$file" - sed -i "3iexport PYTHONPATH=$PYTHONPATH:$(toPythonPath $out):\$PYTHONPATH" "$file" + local wrapper="$out/bin/$file" + local wrapped="$out/bin/.$file-wrapped" + mv "$wrapper" "$wrapped" + + cat > "$wrapper" <<- EOF + export PATH=$PATH:\$PATH + export PYTHONPATH=$PYTHONPATH:$(toPythonPath $out):\$PYTHONPATH + source "$wrapped" + EOF + + chmod -x "$wrapped" + chmod +x "$wrapper" done '';