bscpkgs/garlic/stages/exec.nix
2020-11-17 16:09:38 +01:00

37 lines
535 B
Nix

{
stdenv
, garlicTools
}:
{
nextStage
, env ? ""
, pre ? ""
, argv ? []
, post ? ""
}:
with builtins;
with garlicTools;
let
argvString = concatStringsSep " " (map (e: toString e) argv);
execMethod = if (post == "") then "exec " else "";
in
stdenv.mkDerivation {
name = "exec";
preferLocalBuild = true;
phases = [ "installPhase" ];
installPhase = ''
cat > $out <<EOF
#!/bin/sh
${env}
''+pre+''
${execMethod}${stageProgram nextStage} ${argvString}
''+post+''
EOF
chmod +x $out
'';
}