commit 72171021e3d450ed02a3c74bfad0baa8a74f1ba3
parent 17517dd34f30ce7aa4405788fb51eae3d9a7c469
Author: Daniel Barlow <dan@telent.net>
Date: Thu, 10 Oct 2024 18:26:14 +0100
support finish script in longrun
Diffstat:
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/pkgs/liminix-tools/services/default.nix b/pkgs/liminix-tools/services/default.nix
@@ -14,8 +14,9 @@ let
. ${serviceFns}
${commands}
'';
- cleanupScript = name : ''
+ cleanupScript = name : cmds : ''
#!/bin/sh
+ ${if cmds != null then cmds else ""}
if test -d ${prefix}/${name} ; then rm -rf ${prefix}/${name} ; fi
'';
service = {
@@ -51,6 +52,7 @@ let
longrun = {
name
, run
+ , finish ? null
, notification-fd ? null
, buildInputs ? []
, producer-for ? null
@@ -68,7 +70,7 @@ let
buildInputs = buildInputs ++ lib.optional (producer-for == null) logger;
serviceType = "longrun";
run = serviceScript run;
- finish = cleanupScript name;
+ finish = cleanupScript name finish;
producer-for = if producer-for != null then producer-for else "${name}-log";
});
@@ -82,7 +84,7 @@ let
up = writeScript "${name}-up" (serviceScript up);
down = writeScript
"${name}-down"
- "${serviceScript down}\n${cleanupScript name}";
+ "${serviceScript down}\n${cleanupScript name null}";
});
bundle = { contents ? []
, dependencies ? []