57 lines
1.4 KiB
Nix
57 lines
1.4 KiB
Nix
{ pkgs, config, ... }:
|
|
let
|
|
inherit (config.networking) ports;
|
|
interfaces = import ../../interfaces.nix;
|
|
cfg = config.services.snapserver;
|
|
airplayPort1 = 5000;
|
|
in
|
|
{
|
|
services.snapserver = {
|
|
enable = true;
|
|
settings = {
|
|
tcp-streaming.port = ports.snapserver.tcp;
|
|
tcp = {
|
|
enabled = true;
|
|
port = ports.snapserverTcp.tcp;
|
|
};
|
|
http = {
|
|
enabled = true;
|
|
port = ports.snapserverHttp.tcp;
|
|
};
|
|
stream.source = [
|
|
"airplay://${pkgs.shairport-sync}/bin/shairport-sync?name=airplay&devicename=Snapcast&port=${toString airplayPort1}"
|
|
#"alsa://?name=bluetooth&device=hw:bluetooth,1"
|
|
"pipe:///run/snapserver/hass.fifo?name=hass"
|
|
"pipe:///run/snapserver/mopidy.fifo?name=mopidy"
|
|
"meta:///hass/airplay/mopidy?name=default&buffer=690&chunk_ms=30&codec=flac"
|
|
];
|
|
};
|
|
};
|
|
|
|
systemd.services.snapserver.serviceConfig.SupplementaryGroups = [ "audio" ];
|
|
|
|
services.home-assistant.config.media_player = [
|
|
{
|
|
platform = "snapcast";
|
|
host = "127.0.0.1";
|
|
}
|
|
];
|
|
|
|
networking.firewall.interfaces."${interfaces.lan}" = {
|
|
allowedTCPPorts = [
|
|
cfg.settings.http.port
|
|
cfg.settings.tcp.port
|
|
cfg.settings.tcp-streaming.port
|
|
airplayPort1
|
|
];
|
|
allowedUDPPortRanges = [
|
|
{ from = 6001; to = 6011; } # airplay
|
|
];
|
|
};
|
|
|
|
networking.firewall.interfaces.iot = {
|
|
allowedTCPPorts = [
|
|
cfg.settings.stream.port
|
|
];
|
|
};
|
|
}
|