diff --git a/nixos/modules/services/audio/music-assistant.nix b/nixos/modules/services/audio/music-assistant.nix index 40646f33c572..1bef47c20d5a 100644 --- a/nixos/modules/services/audio/music-assistant.nix +++ b/nixos/modules/services/audio/music-assistant.nix @@ -68,6 +68,14 @@ in }; config = mkIf cfg.enable { + services.avahi = lib.mkIf (lib.elem "airplay_receiver" cfg.providers) { + enable = true; + publish = { + enable = true; + userServices = true; + }; + }; + systemd.services.music-assistant = { description = "Music Assistant"; documentation = [ "https://music-assistant.io" ]; @@ -87,6 +95,9 @@ in [ lsof ] + ++ lib.optionals (lib.elem "airplay_receiver" cfg.providers) [ + shairport-sync + ] ++ lib.optionals (lib.elem "spotify" cfg.providers) [ librespot-ma ] diff --git a/pkgs/by-name/mu/music-assistant/package.nix b/pkgs/by-name/mu/music-assistant/package.nix index 9b0e4ecdce32..2edf5f216688 100644 --- a/pkgs/by-name/mu/music-assistant/package.nix +++ b/pkgs/by-name/mu/music-assistant/package.nix @@ -66,6 +66,9 @@ python.pkgs.buildPythonApplication rec { # Look up librespot from PATH at runtime ./librespot.patch + # Look up shairport-sync from PATH at runtime + ./shairport-sync.patch + # Disable interactive dependency resolution, which clashes with the immutable Python environment ./dont-install-deps.patch @@ -91,7 +94,9 @@ python.pkgs.buildPythonApplication rec { substituteInPlace pyproject.toml \ --replace-fail "get-mac" "getmac" - rm -rv music_assistant/providers/spotify/bin + rm -rv \ + music_assistant/providers/airplay_receiver/bin/{build_binaries.sh,shairport-sync-*} \ + music_assistant/providers/spotify/bin ''; build-system = with python.pkgs; [ diff --git a/pkgs/by-name/mu/music-assistant/shairport-sync.patch b/pkgs/by-name/mu/music-assistant/shairport-sync.patch new file mode 100644 index 000000000000..298d06f59449 --- /dev/null +++ b/pkgs/by-name/mu/music-assistant/shairport-sync.patch @@ -0,0 +1,20 @@ +diff --git a/music_assistant/providers/airplay_receiver/helpers.py b/music_assistant/providers/airplay_receiver/helpers.py +index 6f2b35df..dd839b73 100644 +--- a/music_assistant/providers/airplay_receiver/helpers.py ++++ b/music_assistant/providers/airplay_receiver/helpers.py +@@ -22,15 +22,9 @@ async def check_shairport_sync(shairport_path: str) -> str | None: + except OSError: + return None + +- # First, check if bundled binary exists +- base_path = os.path.join(os.path.dirname(__file__), "bin") + system = platform.system().lower().replace("darwin", "macos") + architecture = platform.machine().lower() + +- if shairport_binary := await check_shairport_sync( +- os.path.join(base_path, f"shairport-sync-{system}-{architecture}") +- ): +- return shairport_binary + + # If no bundled binary, check system PATH + if system_binary := shutil.which("shairport-sync"):