exec: add pre and post code to allow cleanup tasks
This commit is contained in:
parent
33f6ae7e55
commit
e1e34ddf75
@ -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
|
||||||
'';
|
'';
|
||||||
|
Loading…
Reference in New Issue
Block a user