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