flip dependencies for triggered/controlled services

Instead of treating the trigger as the "main" service and the
triggered service as subsidary, now we treat the triggered
service as the service and the trigger as "subsidary". This
needs some special handling when we work out which services
go in the default bundle, but it works better for declaring
dependencies on triggered services because it means the
dependency runs after the triggered service comes up, not
just when the watcher-for-events starts
This commit is contained in:
Daniel Barlow
2024-06-09 22:37:45 +01:00
parent 2c10790a6d
commit e6e4665a18
6 changed files with 29 additions and 22 deletions

View File

@@ -15,9 +15,9 @@ in {
};
config = {
system.service.uevent-rule = liminix.callService ./rule.nix {
service = mkOption {
description = "the service to run when the rule matches";
type = liminix.lib.types.service;
serviceName = mkOption {
description = "name of the service to run when the rule matches";
type = types.str;
};
terms = mkOption {
type = types.attrs;

View File

@@ -4,7 +4,7 @@
, serviceFns
, lib }:
{
service, terms, symlink
serviceName, terms, symlink
}:
let
inherit (liminix.services) longrun;
@@ -18,8 +18,7 @@ let
attrs));
termsString = stringify terms;
in longrun {
name = "watch-for-${service.name}";
name = "watch-for-${serviceName}";
isTrigger = true;
buildInputs = [ service ];
run = "${uevent-watch}/bin/uevent-watch ${if symlink != null then "-n ${symlink}" else ""} -s ${service.name} ${termsString}";
run = "${uevent-watch}/bin/uevent-watch ${if symlink != null then "-n ${symlink}" else ""} -s ${serviceName} ${termsString}";
}