48 lines
1.1 KiB
Nix
48 lines
1.1 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}: let
|
|
cfg = config.services.piano-led-visualizer;
|
|
in {
|
|
options.services.piano-led-visualizer = {
|
|
enable = lib.mkEnableOption "Enable Piano LED Visualizer";
|
|
|
|
user = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "plv";
|
|
description = "User to run the Piano LED Visualizer service.";
|
|
};
|
|
|
|
group = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "plv";
|
|
description = "Group to run the Piano LED Visualizer service.";
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
users.users.${cfg.user} = {
|
|
isSystemUser = true;
|
|
group = cfg.group;
|
|
};
|
|
users.groups.${cfg.group} = {};
|
|
|
|
systemd.services.piano-led-visualizer = {
|
|
description = "Piano LED Visualizer";
|
|
after = ["network-online.target"];
|
|
wants = ["network-online.target"];
|
|
wantedBy = ["multi-user.target"];
|
|
|
|
serviceConfig = {
|
|
ExecStart = "${pkgs.frajul.piano-led-visualizer}/bin/piano-led-visualizer";
|
|
Restart = "always";
|
|
Type = "simple";
|
|
User = cfg.user;
|
|
Group = cfg.group;
|
|
};
|
|
};
|
|
};
|
|
}
|