users/services: s6: exec into the run/finish commands

This commit is contained in:
Colin 2024-03-21 16:18:31 +00:00
parent 16ca71188f
commit 4fa7e6113d

View File

@ -73,35 +73,33 @@ let
serviceToFs'= { serviceToFs'= {
name, name,
type, type,
contents ? null, consumerFor ? null,
run ? null, contents ? null, #< bundle contents
depends ? [], depends ? [],
finish ? null, finish ? null,
producerFor ? null, producerFor ? null,
consumerFor ? null, run ? null,
}: { }: {
"${name}".dir = { "${name}".dir = {
"type".text = type; "type".text = type;
# TODO: finish and run should `exec` into their cli
"finish".executable = maybe (finish != null) ''
#!/bin/sh
${finish}
'';
"run".executable = maybe (run != null) ''
#!/bin/sh
echo "starting: s6-${name}"
${run} 2>&1
'';
"contents".text = maybe (contents != null) ( "contents".text = maybe (contents != null) (
lib.concatStringsSep "\n" contents lib.concatStringsSep "\n" contents
); );
# TODO: a bundle can also have dependencies "consumer-for".text = maybe (consumerFor != null) consumerFor;
"dependencies.d".dir = lib.genAttrs "dependencies.d".dir = lib.genAttrs
depends depends
(dep: { text = ""; }) (dep: { text = ""; })
; ;
"consumer-for".text = maybe (consumerFor != null) consumerFor; "finish".executable = maybe (finish != null) ''
#!/bin/sh
exec ${finish}
'';
"producer-for".text = maybe (producerFor != null) producerFor; "producer-for".text = maybe (producerFor != null) producerFor;
"run".executable = maybe (run != null) ''
#!/bin/sh
echo "starting: s6-${name}"
exec ${run} 2>&1
'';
}; };
}; };