2016-06-11 12:46:02 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
2021-02-10 02:30:38 +00:00
|
|
|
inherit (lib) mkEnableOption mkIf mkOption optionalString types;
|
|
|
|
|
2018-03-29 08:59:00 +00: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 12:46:02 +00:00
|
|
|
|
2021-02-10 02:30:38 +00:00
|
|
|
in
|
|
|
|
{
|
2016-06-11 12:46:02 +00:00
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
2021-02-10 02:30:38 +00:00
|
|
|
options.services.squeezelite = {
|
|
|
|
enable = mkEnableOption (lib.mdDoc "Squeezelite, a software Squeezebox emulator");
|
2016-06-11 12:46:02 +00:00
|
|
|
|
2021-02-10 02:30:38 +00:00
|
|
|
pulseAudio = mkEnableOption (lib.mdDoc "pulseaudio support");
|
2016-06-11 12:46:02 +00:00
|
|
|
|
2021-02-10 02:30:38 +00:00
|
|
|
extraArguments = mkOption {
|
|
|
|
default = "";
|
|
|
|
type = types.str;
|
|
|
|
description = lib.mdDoc ''
|
|
|
|
Additional command line arguments to pass to Squeezelite.
|
|
|
|
'';
|
2016-06-11 12:46:02 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2021-02-10 02:30:38 +00:00
|
|
|
systemd.services.squeezelite = {
|
2016-06-11 12:46:02 +00:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network.target" "sound.target" ];
|
|
|
|
description = "Software Squeezebox emulator";
|
|
|
|
serviceConfig = {
|
2018-03-29 08:59:00 +00:00
|
|
|
DynamicUser = true;
|
2021-02-10 02:30:38 +00:00
|
|
|
ExecStart = "${bin} -N ${dataDir}/player-name ${cfg.extraArguments}";
|
2018-03-29 08:59:00 +00:00
|
|
|
StateDirectory = builtins.baseNameOf dataDir;
|
|
|
|
SupplementaryGroups = "audio";
|
2016-06-11 12:46:02 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|