From e1e34ddf75ddba903e65917bc24ddb1842c5044d Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Tue, 17 Nov 2020 16:09:38 +0100 Subject: [PATCH] exec: add pre and post code to allow cleanup tasks --- garlic/stages/exec.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/garlic/stages/exec.nix b/garlic/stages/exec.nix index eb49e96..0ed199f 100644 --- a/garlic/stages/exec.nix +++ b/garlic/stages/exec.nix @@ -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 '';