2024-07-15 21:37:37 +00:00
|
|
|
{
|
2025-02-10 21:55:08 +00:00
|
|
|
liminix,
|
|
|
|
lib,
|
|
|
|
s6-rc-round-robin,
|
2024-07-15 21:37:37 +00:00
|
|
|
}:
|
2025-02-10 21:55:08 +00:00
|
|
|
{ services, name }:
|
2024-07-15 21:37:37 +00:00
|
|
|
let
|
2025-02-10 21:55:08 +00:00
|
|
|
inherit (liminix.services) oneshot longrun;
|
|
|
|
controlled-services = builtins.map (
|
|
|
|
s:
|
|
|
|
s.overrideAttrs (o: {
|
|
|
|
inherit controller;
|
|
|
|
})
|
|
|
|
) services;
|
|
|
|
controller =
|
|
|
|
let
|
|
|
|
name' = "control-${name}";
|
|
|
|
in
|
|
|
|
longrun {
|
|
|
|
name = name';
|
|
|
|
run = ''
|
|
|
|
in_outputs ${name'}
|
|
|
|
exec ${s6-rc-round-robin}/bin/s6-rc-round-robin \
|
|
|
|
-p ${proxy.name} \
|
|
|
|
${lib.concatStringsSep " " (builtins.map (f: f.name) controlled-services)}
|
|
|
|
'';
|
|
|
|
};
|
2024-07-15 21:37:37 +00:00
|
|
|
proxy = oneshot rec {
|
|
|
|
inherit name;
|
|
|
|
inherit controller;
|
|
|
|
buildInputs = controlled-services;
|
|
|
|
up = ''
|
|
|
|
echo start proxy ${name}
|
|
|
|
set -x
|
|
|
|
(in_outputs ${name}
|
|
|
|
cp -rv $(output_path ${controller} active)/* .
|
|
|
|
)
|
|
|
|
'';
|
|
|
|
};
|
2025-02-10 21:55:08 +00:00
|
|
|
in
|
|
|
|
proxy
|