thekenlicht/module.nix

34 lines
984 B
Nix
Raw Normal View History

2024-08-28 22:58:04 +02:00
{flake}:
2024-08-28 22:48:06 +02:00
{ self, config, pkgs, lib, ... }:
let
cfg = config.services.thekenlicht-daemon;
in
{
options = {
services.thekenlicht-daemon = {
enable = lib.mkEnableOption "Enable Module";
2024-08-28 22:58:04 +02:00
serialPort = lib.mkOption {
description = "Serial Port";
type = lib.types.uniq lib.types.str;
};
2024-08-28 22:48:06 +02:00
};
};
config = lib.mkIf cfg.enable {
2024-08-28 22:58:04 +02:00
users.users.thekenlicht-daemon = {
isSystemUser = true;
extraGroups = [ "dialout" ];
group = "thekenlicht-daemon";
};
users.groups.thekenlicht-daemon = {};
2024-08-28 22:48:06 +02:00
systemd.services.thekenlicht-daemon = {
description = "converts artnet to serial thekenlicht commands";
wantedBy = [ "multi-user.target" ];
2024-08-28 22:58:04 +02:00
serviceConfig.ExecStart = "${flake.packages.${pkgs.system}.default}/bin/thekenlicht-daemon ${cfg.serialPort}";
2024-08-28 22:48:06 +02:00
serviceConfig.Restart = "on-failure";
2024-08-28 22:58:04 +02:00
serviceConfig.User = "thekenlicht-daemon";
serviceConfig.Group = "thekenlicht-daemon";
2024-08-28 22:48:06 +02:00
};
};
}