bscpkgs/garlic/stages/exec.nix

38 lines
566 B
Nix
Raw Normal View History

2020-10-09 21:55:37 +08:00
{
stdenv
, garlicTools
}:
{
nextStage
, env ? ""
, pre ? ""
2020-10-09 21:55:37 +08:00
, argv ? []
, post ? ""
2020-12-02 18:57:40 +08:00
, nixPrefix ? ""
2020-10-09 21:55:37 +08:00
}:
with builtins;
with garlicTools;
let
argvString = concatStringsSep " " (map (e: toString e) argv);
execMethod = if (post == "") then "exec " else "";
2020-10-09 21:55:37 +08:00
in
stdenv.mkDerivation {
name = "exec";
preferLocalBuild = true;
phases = [ "installPhase" ];
installPhase = ''
cat > $out <<'EOF'
2020-10-09 21:55:37 +08:00
#!/bin/sh
${env}
''+pre+''
2020-12-02 18:57:40 +08:00
${execMethod}${nixPrefix}${stageProgram nextStage} ${argvString}
''+post+''
2020-10-09 21:55:37 +08:00
EOF
chmod +x $out
'';
}