1 { config, lib, pkgs, ... }:
7 cfg = config.services.shairport-sync;
17 services.shairport-sync = {
23 Enable the shairport-sync daemon.
25 Running with a local system-wide or remote pulseaudio server
30 arguments = mkOption {
34 Arguments to pass to the daemon. Defaults to a local pulseaudio
39 openFirewall = mkOption {
43 Whether to automatically open ports in the firewall.
49 default = "shairport";
51 User account name under which to run shairport-sync. The account
58 default = "shairport";
60 Group account name under which to run shairport-sync. The account
72 config = mkIf config.services.shairport-sync.enable {
74 services.avahi.enable = true;
75 services.avahi.publish.enable = true;
76 services.avahi.publish.userServices = true;
80 description = "Shairport user";
83 home = "/var/lib/shairport-sync";
85 extraGroups = [ "audio" ] ++ optional (config.hardware.pulseaudio.enable || config.services.pipewire.pulse.enable) "pulse";
87 groups.${cfg.group} = {};
90 networking.firewall = mkIf cfg.openFirewall {
91 allowedTCPPorts = [ 5000 ];
92 allowedUDPPortRanges = [ { from = 6001; to = 6011; } ];
95 systemd.services.shairport-sync =
97 description = "shairport-sync";
98 after = [ "network.target" "avahi-daemon.service" ];
99 wantedBy = [ "multi-user.target" ];
103 ExecStart = "${pkgs.shairport-sync}/bin/shairport-sync ${cfg.arguments}";
104 RuntimeDirectory = "shairport-sync";
108 environment.systemPackages = [ pkgs.shairport-sync ];