liminix/modules/service-trigger/rule.nix

25 lines
641 B
Nix
Raw Normal View History

2024-06-02 17:27:59 +00:00
{
liminix
, uevent-watch
, serviceFns
, lib }:
{
serviceName, terms, symlink
2024-06-02 17:27:59 +00:00
}:
let
inherit (liminix.services) longrun;
inherit (lib.attrsets) collect mapAttrsRecursive;
inherit (lib.strings) concatStringsSep;
stringify = attrs :
concatStringsSep " "
(collect lib.isString
(mapAttrsRecursive
(path : value : "${concatStringsSep "." path}=${value}")
attrs));
termsString = stringify terms;
in longrun {
name = "watch-for-${serviceName}";
2024-06-02 17:27:59 +00:00
isTrigger = true;
run = "${uevent-watch}/bin/uevent-watch ${if symlink != null then "-n ${symlink}" else ""} -s ${serviceName} ${termsString}";
2024-06-02 17:27:59 +00:00
}