From 5fd8747939ead2aa54d2cb413577ad80edc924c6 Mon Sep 17 00:00:00 2001 From: Alexandre Macabies Date: Sun, 27 Sep 2020 20:48:30 +0200 Subject: [PATCH 1/3] snapcast: v0.20.0 -> v0.23.0 Includes dependency update: aixlog: v1.2.1 -> v1.4.0 --- pkgs/applications/audio/snapcast/default.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/applications/audio/snapcast/default.nix b/pkgs/applications/audio/snapcast/default.nix index 84695730db67..681601c7d884 100644 --- a/pkgs/applications/audio/snapcast/default.nix +++ b/pkgs/applications/audio/snapcast/default.nix @@ -20,8 +20,8 @@ let aixlog = dependency { name = "aixlog"; - version = "1.2.1"; - sha256 = "1rh4jib5g41b85bqrxkl5g74hk5ryf187y9fw0am76g59xlymfpr"; + version = "1.4.0"; + sha256 = "0f2bs5j1jjajcpa251dslnwkgglaam3b0cm6wdx5l7mbwvnmib2g"; }; popl = dependency { @@ -34,13 +34,13 @@ in stdenv.mkDerivation rec { pname = "snapcast"; - version = "0.20.0"; + version = "0.23.0"; src = fetchFromGitHub { owner = "badaix"; repo = "snapcast"; rev = "v${version}"; - sha256 = "152ic8hlyawcmj9pykb33xc6yx7il6yb9ilmsy6m9nlh40m8yxls"; + sha256 = "0183hhghzn0fhw2qzc1s009q7miabpcf0pxaqjdscsl8iivxqknd"; }; nativeBuildInputs = [ cmake pkg-config boost170.dev ]; From a36cc03d96594526565ce06a0b6db14286fe88ae Mon Sep 17 00:00:00 2001 From: Alexandre Macabies Date: Sun, 27 Sep 2020 20:49:23 +0200 Subject: [PATCH 2/3] nixos/snapserver: update available stream types for v0.21.0 * Add 'librespot' (new name for 'spotify'), 'alsa', 'tcp'. * Add a warning about the spotify -> librespot rename. * Fix the deprecated example `mode = "listen"` for type 'pipe'. * Update the tests to include a straightforward 'tcp' test. --- nixos/modules/services/audio/snapserver.nix | 22 +++++++++++++++++---- nixos/tests/snapcast.nix | 7 +++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/nixos/modules/services/audio/snapserver.nix b/nixos/modules/services/audio/snapserver.nix index f614f0ba3e10..b207fd30e222 100644 --- a/nixos/modules/services/audio/snapserver.nix +++ b/nixos/modules/services/audio/snapserver.nix @@ -198,13 +198,14 @@ in { type = with types; attrsOf (submodule { options = { location = mkOption { - type = types.path; + type = types.oneOf [ types.path types.str ]; description = '' - The location of the pipe. + The location of the pipe, file, Librespot/Airplay/process binary, or a TCP address. + Use an empty string for alsa. ''; }; type = mkOption { - type = types.enum [ "pipe" "file" "process" "spotify" "airplay" ]; + type = types.enum [ "pipe" "librespot" "airplay" "file" "process" "tcp" "alsa" "spotify" ]; default = "pipe"; description = '' The type of input stream. @@ -219,13 +220,21 @@ in { example = literalExample '' # for type == "pipe": { - mode = "listen"; + mode = "create"; }; # for type == "process": { params = "--param1 --param2"; logStderr = "true"; }; + # for type == "tcp": + { + mode = "client"; + } + # for type == "alsa": + { + device = "hw:0,0"; + } ''; }; inherit sampleFormat; @@ -255,6 +264,11 @@ in { config = mkIf cfg.enable { + # https://github.com/badaix/snapcast/blob/98ac8b2fb7305084376607b59173ce4097c620d8/server/streamreader/stream_manager.cpp#L85 + warnings = filter (w: w != "") (mapAttrsToList (k: v: if v.type == "spotify" then '' + services.snapserver.streams.${k}.type = "spotify" is deprecated, use services.snapserver.streams.${k}.type = "librespot" instead. + '' else "") cfg.streams); + systemd.services.snapserver = { after = [ "network.target" ]; description = "Snapserver"; diff --git a/nixos/tests/snapcast.nix b/nixos/tests/snapcast.nix index a69b7afe99da..05d08d76cc05 100644 --- a/nixos/tests/snapcast.nix +++ b/nixos/tests/snapcast.nix @@ -4,6 +4,7 @@ let port = 10004; tcpPort = 10005; httpPort = 10080; + tcpStreamPort = 10006; in { name = "snapcast"; meta = with pkgs.lib.maintainers; { @@ -21,11 +22,16 @@ in { mpd = { type = "pipe"; location = "/run/snapserver/mpd"; + query.mode = "create"; }; bluetooth = { type = "pipe"; location = "/run/snapserver/bluetooth"; }; + tcp = { + type = "tcp"; + location = "127.0.0.1:${toString tcpStreamPort}"; + }; }; }; }; @@ -42,6 +48,7 @@ in { server.wait_until_succeeds("ss -ntl | grep -q ${toString port}") server.wait_until_succeeds("ss -ntl | grep -q ${toString tcpPort}") server.wait_until_succeeds("ss -ntl | grep -q ${toString httpPort}") + server.wait_until_succeeds("ss -ntl | grep -q ${toString tcpStreamPort}") with subtest("check that pipes are created"): server.succeed("test -p /run/snapserver/mpd") From 255882fbcc64a9c210d5b1bba78a0ddba7ed352d Mon Sep 17 00:00:00 2001 From: Alexandre Macabies Date: Sun, 27 Sep 2020 20:54:04 +0200 Subject: [PATCH 3/3] nixos/snapserver: add AF_NETLINK to allowed address families This is necessary for Librespot, which is spawned by snapserver in the same cgroup. Librespot requires querying local ip links and addresses for MDNS (Zeroconf/Avahi), and does so through NETLINK interface. --- nixos/modules/services/audio/snapserver.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/services/audio/snapserver.nix b/nixos/modules/services/audio/snapserver.nix index b207fd30e222..0acaccfd3ca9 100644 --- a/nixos/modules/services/audio/snapserver.nix +++ b/nixos/modules/services/audio/snapserver.nix @@ -286,7 +286,7 @@ in { ProtectKernelTunables = true; ProtectControlGroups = true; ProtectKernelModules = true; - RestrictAddressFamilies = "AF_INET AF_INET6 AF_UNIX"; + RestrictAddressFamilies = "AF_INET AF_INET6 AF_UNIX AF_NETLINK"; RestrictNamespaces = true; RuntimeDirectory = name; StateDirectory = name;