2016-06-11 13:46:02 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
2021-02-10 02:30:38 +00:00
|
|
|
inherit (lib) mkEnableOption mkIf mkOption optionalString types;
|
|
|
|
|
2018-03-29 09:59:00 +01:00
|
|
|
dataDir = "/var/lib/squeezelite";
|
2019-02-24 00:28:02 +00:00
|
|
|
cfg = config.services.squeezelite;
|
2021-02-10 02:30:38 +00:00
|
|
|
pkg = if cfg.pulseAudio then pkgs.squeezelite-pulse else pkgs.squeezelite;
|
|
|
|
bin = "${pkg}/bin/${pkg.pname}";
|
2016-06-11 13:46:02 +01:00
|
|
|
|
2021-02-10 02:30:38 +00:00
|
|
|
in
|
|
|
|
{
|
2016-06-11 13:46:02 +01:00
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
2021-02-10 02:30:38 +00:00
|
|
|
options.services.squeezelite = {
|
2022-08-28 20:18:44 +01:00
|
|
|
enable = mkEnableOption (lib.mdDoc "Squeezelite, a software Squeezebox emulator");
|
2016-06-11 13:46:02 +01:00
|
|
|
|
2022-08-28 20:18:44 +01:00
|
|
|
pulseAudio = mkEnableOption (lib.mdDoc "pulseaudio support");
|
2016-06-11 13:46:02 +01:00
|
|
|
|
2021-02-10 02:30:38 +00:00
|
|
|
extraArguments = mkOption {
|
|
|
|
default = "";
|
|
|
|
type = types.str;
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc ''
|
2021-02-10 02:30:38 +00:00
|
|
|
Additional command line arguments to pass to Squeezelite.
|
|
|
|
'';
|
2016-06-11 13:46:02 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2021-02-10 02:30:38 +00:00
|
|
|
systemd.services.squeezelite = {
|
2016-06-11 13:46:02 +01:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network.target" "sound.target" ];
|
|
|
|
description = "Software Squeezebox emulator";
|
|
|
|
serviceConfig = {
|
2018-03-29 09:59:00 +01:00
|
|
|
DynamicUser = true;
|
2021-02-10 02:30:38 +00:00
|
|
|
ExecStart = "${bin} -N ${dataDir}/player-name ${cfg.extraArguments}";
|
2018-03-29 09:59:00 +01:00
|
|
|
StateDirectory = builtins.baseNameOf dataDir;
|
|
|
|
SupplementaryGroups = "audio";
|
2016-06-11 13:46:02 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|