bscpkgs/garlic/stages/exec.nix
Rodrigo Arias Mallo 130fe39c8e exec: Abort on error
We need exit on the first error, as otherwise we cannot track a bad
execution when no exec is done (when post is not empty).
2021-01-11 18:29:30 +01:00

38 lines
569 B
Nix

{
stdenv
, garlicTools
}:
{
nextStage
, env ? ""
, pre ? ""
, argv ? []
, post ? ""
, nixPrefix ? ""
}:
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 -e
${env}
''+pre+''
${execMethod}${nixPrefix}${stageProgram nextStage} ${argvString}
''+post+''
EOF
chmod +x $out
'';
}