2015-11-27 02:44:56 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.shairport-sync;
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.shairport-sync = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
2020-04-20 20:05:26 +02:00
|
|
|
type = types.bool;
|
2015-11-27 02:44:56 +01:00
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Enable the shairport-sync daemon.
|
|
|
|
|
|
|
|
Running with a local system-wide or remote pulseaudio server
|
|
|
|
is recommended.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
arguments = mkOption {
|
2019-01-02 19:07:33 +01:00
|
|
|
default = "-v -o pa";
|
2015-11-27 02:44:56 +01:00
|
|
|
description = ''
|
|
|
|
Arguments to pass to the daemon. Defaults to a local pulseaudio
|
|
|
|
server.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
user = mkOption {
|
|
|
|
default = "shairport";
|
|
|
|
description = ''
|
|
|
|
User account name under which to run shairport-sync. The account
|
|
|
|
will be created.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf config.services.shairport-sync.enable {
|
|
|
|
|
|
|
|
services.avahi.enable = true;
|
2016-07-08 16:01:35 +02:00
|
|
|
services.avahi.publish.enable = true;
|
|
|
|
services.avahi.publish.userServices = true;
|
2015-11-27 02:44:56 +01:00
|
|
|
|
2019-09-14 19:51:29 +02:00
|
|
|
users.users.${cfg.user} =
|
|
|
|
{ description = "Shairport user";
|
2015-11-27 02:44:56 +01:00
|
|
|
isSystemUser = true;
|
|
|
|
createHome = true;
|
|
|
|
home = "/var/lib/shairport-sync";
|
|
|
|
extraGroups = [ "audio" ] ++ optional config.hardware.pulseaudio.enable "pulse";
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.shairport-sync =
|
|
|
|
{
|
|
|
|
description = "shairport-sync";
|
|
|
|
after = [ "network.target" "avahi-daemon.service" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
User = cfg.user;
|
|
|
|
ExecStart = "${pkgs.shairport-sync}/bin/shairport-sync ${cfg.arguments}";
|
2018-09-26 18:07:06 +02:00
|
|
|
RuntimeDirectory = "shairport-sync";
|
2015-11-27 02:44:56 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
environment.systemPackages = [ pkgs.shairport-sync ];
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|