bscpkgs/bsc/garlic/nix-setup.nix

29 lines
438 B
Nix
Raw Normal View History

2020-08-11 12:05:43 +02:00
{
stdenv
}:
2020-09-02 17:07:09 +02:00
{
program
}:
2020-08-11 12:05:43 +02:00
stdenv.mkDerivation {
2020-09-02 17:07:09 +02:00
name = "nixsetup";
2020-08-11 12:05:43 +02:00
preferLocalBuild = true;
phases = [ "installPhase" ];
dontPatchShebangs = true;
installPhase = ''
2020-09-02 17:07:09 +02:00
cat > $out <<EOF
2020-08-11 12:05:43 +02: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
exec nix-setup \$0
fi
2020-09-02 17:07:09 +02:00
exec ${program}
2020-08-11 12:05:43 +02:00
EOF
2020-09-02 17:07:09 +02:00
chmod +x $out
2020-08-11 12:05:43 +02:00
'';
}