2024-10-30 17:39:29 +01:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
config,
|
|
|
|
...
|
2024-11-17 15:11:42 +01:00
|
|
|
}: let
|
|
|
|
cfg = config.services.snapclient;
|
|
|
|
in {
|
2024-10-30 17:39:29 +01:00
|
|
|
options.services.snapclient.enable = lib.mkEnableOption "a local snapclient service";
|
2024-11-01 19:52:41 +01:00
|
|
|
options.services.snapclient.latency = lib.mkOption {
|
|
|
|
type = lib.types.number;
|
|
|
|
description = "latency of the PCM device";
|
|
|
|
default = 0;
|
|
|
|
};
|
2024-10-30 17:39:29 +01:00
|
|
|
|
|
|
|
config.systemd.user.services.snapclient = lib.mkIf cfg.enable {
|
|
|
|
wantedBy = lib.warnIfNot config.services.pipewire.enable "Pipewire is not running, snapclient won't work" [
|
|
|
|
"pipewire.service"
|
2024-11-01 14:28:53 +01:00
|
|
|
"default.target"
|
2024-10-30 17:39:29 +01:00
|
|
|
];
|
|
|
|
after = [
|
|
|
|
"pipewire.service"
|
|
|
|
];
|
|
|
|
serviceConfig = {
|
2024-11-17 15:11:42 +01:00
|
|
|
ExecStart = "${pkgs.snapcast}/bin/snapclient --host snapserver.lan --player pulse --latency ${builtins.toString cfg.latency}";
|
|
|
|
Slice = "session.slice";
|
2024-11-21 09:37:37 +01:00
|
|
|
Restart = "on-failure";
|
|
|
|
RestartSec = 60;
|
|
|
|
};
|
|
|
|
unitConfig = {
|
|
|
|
StartLimitIntervalSec = 0;
|
2024-10-30 17:39:29 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|