nixos-configuration/hosts/iron/services/snapcast/snapserver.nix
2025-04-16 22:54:29 +02:00

73 lines
1.6 KiB
Nix

{ lib, pkgs, config, ... }:
let
inherit (config.networking) ports;
interfaces = import ../../interfaces.nix;
in
{
services.snapserver = {
enable = true;
port = ports.snapserver.tcp;
tcp.port = ports.snapserverTcp.tcp;
http.port = ports.snapserverHttp.tcp;
streams = {
default = {
type = "meta";
location = "meta:///hass/bluetooth/airplay/mopidy";
query = {
chunk_ms = "30";
buffer = "690";
codec = "flac";
};
};
mopidy = {
type = "pipe";
location = "/run/snapserver/mopidy.fifo";
};
hass = {
type = "pipe";
location = "/run/snapserver/hass.fifo";
};
bluetooth = {
location = "";
type = "alsa";
query = {
device = "hw:bluetooth,1";
};
};
airplay = {
type = "airplay";
location = lib.getExe' pkgs.shairport-sync "shairport-sync";
query = {
devicename = "Snapcast";
};
};
};
};
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 = [
config.services.snapserver.http.port
config.services.snapserver.port
config.services.snapserver.tcp.port
5000 # airplay
];
allowedUDPPortRanges = [
{ from = 6001; to = 6011; } # airplay
];
};
networking.firewall.interfaces.iot = {
allowedTCPPorts = [
config.services.snapserver.port
];
};
}