From fbe6eb952a657ef372548a6fa45d9da9ded13de8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Tue, 17 Mar 2026 01:45:14 +0100 Subject: [PATCH] nixos/music-assistant: add openFirewall option to open all required ports for airplay or sendspin as otherwise airplay (raopcli) just coredumps. --- .../services/audio/music-assistant.nix | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/nixos/modules/services/audio/music-assistant.nix b/nixos/modules/services/audio/music-assistant.nix index c4717bb5817f..a9f605fcf461 100644 --- a/nixos/modules/services/audio/music-assistant.nix +++ b/nixos/modules/services/audio/music-assistant.nix @@ -16,6 +16,7 @@ let ; inherit (types) + bool listOf enum str @@ -54,6 +55,15 @@ in ''; }; + openFirewall = lib.mkOption { + type = bool; + default = false; + description = '' + Whether to open required ports for the configured providers. + Currently airplay and sendspin need port to be opened to function. + ''; + }; + providers = mkOption { type = listOf (enum cfg.package.providerNames); default = [ ]; @@ -68,6 +78,23 @@ in }; config = mkIf cfg.enable { + networking.firewall = lib.mkIf cfg.openFirewall { + allowedTCPPorts = + lib.optional cfg.enable 8097 # Music Assistant stream port + ++ lib.optional (lib.elem "airplay" cfg.providers) 7000 + ++ lib.optional (lib.elem "sendspin" cfg.providers) 8927; + # The information published by Apple 1 seem to not apply to libraop. + # The closest we could find that represents the port range being used as observed by tcpdump is the ephemeral port range. + # 1: https://support.apple.com/en-us/103229#:~:text=49152%E2%80%93-,65535,-TCP%2C%20UDP + # 2: https://en.wikipedia.org/wiki/Ephemeral_port#Range + allowedUDPPortRanges = lib.mkIf (lib.elem "airplay" cfg.providers) [ + { + from = 32768; + to = 65535; + } + ]; + }; + services.avahi = lib.mkIf (lib.elem "airplay_receiver" cfg.providers) { enable = true; publish = {