my-env: Use sed to substitute $initialPath.

initialPath is now added to the top of the modified setup.sh. It's not
very nice altogether to patch setup.sh in this way, as it is prone to
break on setup.sh changes, but it should (hopefully finally, but
unfortunately only temporarily) fix the issue ewemoa (in #nixos) had
with myEnvFun.

In the long term, if people want to have roughly similar functionality,
nix-shell provides a better way for that, so maybe we might either
remove myEnvFun or replace it with a smaller implementation using
nix-shell.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
This commit is contained in:
aszlig 2014-11-25 14:05:21 +01:00
parent 7d9fb8625e
commit 6f683e4ba3
No known key found for this signature in database
GPG Key ID: D0EBD0EC8C2DC961

View File

@ -72,20 +72,21 @@ mkDerivation {
phases = [ "buildPhase" "fixupPhase" ];
setupNew = substituteAll {
src = ../../stdenv/generic/setup.sh;
initialPath= (import ../../stdenv/common-path.nix) { inherit pkgs; };
inherit gcc;
};
buildPhase = ''
buildPhase = let
initialPath = import ../../stdenv/common-path.nix { inherit pkgs; };
in ''
set -x
mkdir -p "$out/dev-envs" "$out/nix-support" "$out/bin"
s="$out/nix-support/setup-new-modified"
cp "$setupNew" "$s"
# shut some warning up.., do not use set -e
sed -e 's@set -e@@' \
-e 's@assertEnvExists\s\+NIX_STORE@:@' \
-e 's@trap.*@@' \
-i "$s"
-e '1i initialPath="${toString initialPath}"' \
"$setupNew" > "$s"
cat >> "$out/dev-envs/''${name/env-/}" << EOF
nativeBuildInputs="$nativeBuildInputs"
propagatedBuildInputs="$propagatedBuildInputs2"