bscpkgs/garlic/stages/nix-setup.nix

30 lines
451 B
Nix
Raw Normal View History

2020-08-11 18:05:43 +08:00
{
stdenv
}:
2020-09-02 23:07:09 +08:00
{
program
2020-09-22 23:39:26 +08:00
, nixsetup
2020-09-02 23:07:09 +08:00
}:
2020-08-11 18:05:43 +08:00
stdenv.mkDerivation {
2020-09-02 23:07:09 +08:00
name = "nixsetup";
2020-08-11 18:05:43 +08:00
preferLocalBuild = true;
phases = [ "installPhase" ];
dontPatchShebangs = true;
installPhase = ''
2020-09-02 23:07:09 +08:00
cat > $out <<EOF
2020-08-11 18:05:43 +08:00
#!/bin/sh
# We need to enter the nix namespace first, in order to have /nix
# available, so we use this hack:
if [ ! -e /nix ]; then
2020-09-22 23:39:26 +08:00
exec ${nixsetup} \$0
2020-08-11 18:05:43 +08:00
fi
2020-09-02 23:07:09 +08:00
exec ${program}
2020-08-11 18:05:43 +08:00
EOF
2020-09-02 23:07:09 +08:00
chmod +x $out
2020-08-11 18:05:43 +08:00
'';
}