wrap uevent-watch in a service

This commit is contained in:
Daniel Barlow
2024-06-02 18:27:59 +01:00
parent f091bbd706
commit 884d8d194e
4 changed files with 76 additions and 5 deletions

View File

@@ -0,0 +1,25 @@
{
liminix
, uevent-watch
, serviceFns
, lib }:
{
service, terms, symlink
}:
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-${service.name}";
isTrigger = true;
buildInputs = [ service ];
run = "${uevent-watch}/bin/uevent-watch ${if symlink != null then "-n ${symlink}" else ""} -s ${service.name} ${termsString}";
}