exec: add pre and post code to allow cleanup tasks

This commit is contained in:
Rodrigo Arias Mallo 2020-11-17 16:09:38 +01:00
parent 33f6ae7e55
commit e1e34ddf75

View File

@ -6,7 +6,9 @@
{
nextStage
, env ? ""
, pre ? ""
, argv ? []
, post ? ""
}:
with builtins;
@ -14,6 +16,7 @@ with garlicTools;
let
argvString = concatStringsSep " " (map (e: toString e) argv);
execMethod = if (post == "") then "exec " else "";
in
stdenv.mkDerivation {
name = "exec";
@ -24,7 +27,9 @@ stdenv.mkDerivation {
#!/bin/sh
${env}
exec ${stageProgram nextStage} ${argvString}
''+pre+''
${execMethod}${stageProgram nextStage} ${argvString}
''+post+''
EOF
chmod +x $out
'';