33 lines
500 B
Nix
33 lines
500 B
Nix
{
|
|
stdenv
|
|
}:
|
|
|
|
{
|
|
program
|
|
, nixsetup
|
|
}:
|
|
|
|
stdenv.mkDerivation {
|
|
name = "nixsetup";
|
|
preferLocalBuild = true;
|
|
phases = [ "installPhase" ];
|
|
dontPatchShebangs = true;
|
|
installPhase = ''
|
|
cat > $out <<EOF
|
|
#!/bin/sh -ex
|
|
|
|
>&2 echo Running nixsetup stage
|
|
env
|
|
|
|
# We need to enter the nix namespace first, in order to have /nix
|
|
# available, so we use this hack:
|
|
if [ ! -e /nix ]; then
|
|
exec ${nixsetup} \$0
|
|
fi
|
|
|
|
exec ${program}
|
|
EOF
|
|
chmod +x $out
|
|
'';
|
|
}
|