From 371e4e131db0482cd24684f20ead9e4cf99d29f9 Mon Sep 17 00:00:00 2001 From: Dominik Polakovics Date: Thu, 3 Aug 2023 14:13:52 +0200 Subject: [PATCH] add mqtt to shairport-sync --- utils/modules/snapserver.nix | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/utils/modules/snapserver.nix b/utils/modules/snapserver.nix index 995d6a6..64a8303 100644 --- a/utils/modules/snapserver.nix +++ b/utils/modules/snapserver.nix @@ -12,6 +12,40 @@ shairport-sync = pkgs.shairport-sync.overrideAttrs (_: { }); in { + environment.etc = { + # Creates /etc/nanorc + shairport-sync = { + text = '' + whatever you want to put in the file goes here. + metadata = + { + enabled = "yes"; // set this to yes to get Shairport Sync to solicit metadata from the source and to pass it on via a pipe + include_cover_art = "yes"; // set to "yes" to get Shairport Sync to solicit cover art from the source and pass it via the pipe. You must also set "enabled" to "yes". + cover_art_cache_directory = "/tmp/shairport-sync/.cache/coverart"; // artwork will be stored in this directory if the dbus or MPRIS interfaces are enabled or if the MQTT client is in use. Set it to "" to prevent caching, which may be useful on some systems + pipe_name = "/tmp/shairport-sync-metadata"; + pipe_timeout = 5000; // wait for this number of milliseconds for a blocked pipe to unblock before giving up + }; + + + mqtt = + { + enabled = "yes"; // set this to yes to enable the mqtt-metadata-service + hostname = "127.0.0.1"; // Hostname of the MQTT Broker + port = 1883; // Port on the MQTT Broker to connect to + username = "shairport-mqtt"; //set this to a string to your username in order to enable username authentication + password = "insecure-password"; //set this to a string you your password in order to enable username & password authentication + topic = "shairport"; //MQTT topic where this instance of shairport-sync should publish. If not set, the general.name value is used. + // publish_raw = "no"; //whether to publish all available metadata under the codes given in the 'metadata' docs. + publish_parsed = "yes"; //whether to publish a small (but useful) subset of metadata under human-understandable topics + publish_cover = "yes"; //whether to publish the cover over mqtt in binary form. This may lead to a bit of load on the broker + // enable_remote = "no"; //whether to remote control via MQTT. RC is available under `topic`/remote. + }; + ''; + + # The UNIX file mode bits + mode = "0440"; + }; + }; services.snapserver = { enable = true; codec = "flac"; @@ -26,7 +60,7 @@ in query = { devicename = "Multi Room"; port = "5000"; - params = "--mdns=avahi"; + params = "--mdns=avahi -c=/etc/shairport-sync"; }; }; streams.mixed = {