From 7df2bb1902e5bfe7a9891c66e11ac9ce20a6a226 Mon Sep 17 00:00:00 2001 From: Yarny0 <41838844+Yarny0@users.noreply.github.com> Date: Thu, 18 Aug 2022 10:20:30 +0200 Subject: nixos/tests/pulseaudio: fix url to mp3 sample file old URL returns 404 --- nixos/tests/pulseaudio.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/tests/pulseaudio.nix b/nixos/tests/pulseaudio.nix index cfdc61bc6c2b..f23be66fdda8 100644 --- a/nixos/tests/pulseaudio.nix +++ b/nixos/tests/pulseaudio.nix @@ -4,7 +4,7 @@ let let testFile = pkgs.fetchurl { url = - "https://file-examples-com.github.io/uploads/2017/11/file_example_MP3_700KB.mp3"; + "https://file-examples.com/storage/fe5947fd2362fc197a3c2df/2017/11/file_example_MP3_700KB.mp3"; hash = "sha256-+iggJW8s0/LfA/okfXsB550/55Q0Sq3OoIzuBrzOPJQ="; }; -- cgit v1.2.3 From 0fd253867885cebd9a8384110c0f0f50e9a5b327 Mon Sep 17 00:00:00 2001 From: Yarny0 <41838844+Yarny0@users.noreply.github.com> Date: Thu, 18 Aug 2022 10:28:02 +0200 Subject: nixos/tests/pulseaudio: fix pavucontrol detection The test tries to detect the presence of pavucontrol's window by looking for the tab label "Playback". However, the OCR mechanism fails to resolve the text, possibly due to the grey background color. To fix this issue, we instead look for the name of the sound device ("Dummy Output") which gets resolved by OCR. Note: Strangely, the tab "Playback" *is* correctly resolved when the test is run in interactive mode. This might be due to the changed screen resolution, but I didn't investigate further. --- nixos/tests/pulseaudio.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nixos/tests/pulseaudio.nix b/nixos/tests/pulseaudio.nix index f23be66fdda8..c553527a482c 100644 --- a/nixos/tests/pulseaudio.nix +++ b/nixos/tests/pulseaudio.nix @@ -59,9 +59,9 @@ let machine.screenshot("testPlay") # Pavucontrol only loads when Pulseaudio is running. If it isn't, the - # text "Playback" (one of the tabs) will never show. + # text "Dummy Output" (sound device name) will never show. machine.send_chars("pavucontrol\n") - machine.wait_for_text("Playback") + machine.wait_for_text("Dummy Output") machine.screenshot("Pavucontrol") ''; }); -- cgit v1.2.3 From 7ba079505aa414bb01c53f9d1ed6f97112f791c4 Mon Sep 17 00:00:00 2001 From: Yarny0 <41838844+Yarny0@users.noreply.github.com> Date: Thu, 18 Aug 2022 11:03:58 +0200 Subject: nixos/pulseaudio: add pulse-access group According to pulseaudio(1), a system wide pulseaudio instance can only be accessed by members of the `pulse-access` group. This name seems to be hardcoded in pulseaudio -- I didn't find any switch to change it. We need to define the group so users can connect to the deamon. This commit also fixes the systemwide pulseaudio vm test: Previously, the test user `alice` was just a member of the `audio` group. This blocked access to the daemon and failed the test. The commit changes the group assignment and fixes the vm test. --- nixos/modules/config/pulseaudio.nix | 3 ++- nixos/tests/pulseaudio.nix | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/nixos/modules/config/pulseaudio.nix b/nixos/modules/config/pulseaudio.nix index aa3ca549f09a..598a5b623fdf 100644 --- a/nixos/modules/config/pulseaudio.nix +++ b/nixos/modules/config/pulseaudio.nix @@ -102,7 +102,7 @@ in { each user that tries to use the sound system. The server runs with user privileges. If true, one system-wide PulseAudio server is launched on boot, running as the user "pulse", and - only users in the "audio" group will have access to the server. + only users in the "pulse-access" group will have access to the server. Please read the PulseAudio documentation for more details. Don't enable this option unless you know what you are doing. @@ -310,6 +310,7 @@ in { }; users.groups.pulse.gid = gid; + users.groups.pulse-access = {}; systemd.services.pulseaudio = { description = "PulseAudio System-Wide Server"; diff --git a/nixos/tests/pulseaudio.nix b/nixos/tests/pulseaudio.nix index c553527a482c..16809228b9dd 100644 --- a/nixos/tests/pulseaudio.nix +++ b/nixos/tests/pulseaudio.nix @@ -40,7 +40,7 @@ let environment.systemPackages = [ testers.testPlay pkgs.pavucontrol ] ++ lib.optional pkgs.stdenv.isx86_64 testers.testPlay32; } // lib.optionalAttrs systemWide { - users.users.alice.extraGroups = [ "audio" ]; + users.users.alice.extraGroups = [ "pulse-access" ]; systemd.services.pulseaudio.wantedBy = [ "multi-user.target" ]; }; -- cgit v1.2.3 From 78e5c0c97f9ab98b53ba8f1935bba1b1369c0ae5 Mon Sep 17 00:00:00 2001 From: Yarny0 <41838844+Yarny0@users.noreply.github.com> Date: Wed, 17 Aug 2022 12:05:13 +0200 Subject: nixos/tests/pulseaudio: add tests for pkgs.pulseaudioFull --- nixos/tests/pulseaudio.nix | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/nixos/tests/pulseaudio.nix b/nixos/tests/pulseaudio.nix index 16809228b9dd..c0376204defe 100644 --- a/nixos/tests/pulseaudio.nix +++ b/nixos/tests/pulseaudio.nix @@ -1,5 +1,5 @@ let - mkTest = { systemWide ? false }: + mkTest = { systemWide ? false , fullVersion ? false }: import ./make-test-python.nix ({ pkgs, lib, ... }: let testFile = pkgs.fetchurl { @@ -22,7 +22,7 @@ let testPlay32 = { inherit (pkgs.pkgsi686Linux) sox alsa-utils; }; }; in { - name = "pulseaudio${lib.optionalString systemWide "-systemWide"}"; + name = "pulseaudio${lib.optionalString fullVersion "Full"}${lib.optionalString systemWide "-systemWide"}"; meta = with pkgs.lib.maintainers; { maintainers = [ synthetica ] ++ pkgs.pulseaudio.meta.maintainers; }; @@ -35,6 +35,8 @@ let enable = true; support32Bit = true; inherit systemWide; + } // lib.optionalAttrs fullVersion { + package = pkgs.pulseaudioFull; }; environment.systemPackages = [ testers.testPlay pkgs.pavucontrol ] @@ -66,6 +68,8 @@ let ''; }); in builtins.mapAttrs (key: val: mkTest val) { - user = { systemWide = false; }; - system = { systemWide = true; }; + user = { systemWide = false; fullVersion = false; }; + system = { systemWide = true; fullVersion = false; }; + userFull = { systemWide = false; fullVersion = true; }; + systemFull = { systemWide = true; fullVersion = true; }; } -- cgit v1.2.3 From 3871f8be8d6de48d5f094fbe90a09e42cc0b289c Mon Sep 17 00:00:00 2001 From: Yarny0 <41838844+Yarny0@users.noreply.github.com> Date: Thu, 7 Jul 2022 18:41:47 +0200 Subject: pulseaudioFull: fix wrapGApp wrapping Since https://github.com/NixOS/nixpkgs/commit/7a2605e0f3dc99e02cd577634f792f7a4d229378 the pulseaudio build recipe incorporates the `wrapGAppsHook` wrapper setup-hook if `advancedBluetoothCodecs` are enabled. This wrapper setup-hook -- like most wrappers -- wraps binaries in `$out/bin` by first renaming them, then placing a wrapper script where the original binary was. Unfortunatelly, pulseaudio doesn't like its binary moved around after installation: It records the binaries path during installation time https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/blob/e5ad31e873eed62bc580a86a61177047f9e8c491/meson.build#L154 then checks the path in `/proc/self/exe` and complains > Jun 16 19:06:48 nixosb pulseaudio[2219]: W: [.pulseaudio-wra] main.c: /proc/self/exe does not point to /nix/store/bqfyzxwpxa2ydmyvh3j32xrm4chxbj22-pulseaudio-15.0/bin/pulseaudio, cannot self execute. Are you playing games? if they don't match https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/blob/e5ad31e873eed62bc580a86a61177047f9e8c491/src/daemon/main.c#L577 Somehow, this also results in a real bug: `pacmd` fails to connect to the pulseaudio server, see https://github.com/NixOS/nixpkgs/issues/177915 To fix this issue, the commit at hand changes the installation directory for binaries to `$out/.bin-unwrapped`. After the installation, `$out/bin` is created by hand and populated with symlinks to files in `$out/.bin-unwrapped`. `wrapGAppsHook` doesn't know or care about the `.bin-unwrapped` directory; it just sees all the symlinks in `bin`, renames them and places wrapper scripts beside them. Effectively, this leaves the original binary in `.bin-unwrapped` unchanged! So pulseaudio will find itself still in its oritinal place, and "users" of the package can call pulseaudio via the wrapper script in `bin` as usual. --- pkgs/servers/pulseaudio/default.nix | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/pkgs/servers/pulseaudio/default.nix b/pkgs/servers/pulseaudio/default.nix index ee2c0e0bd1c5..6dc158600fd1 100644 --- a/pkgs/servers/pulseaudio/default.nix +++ b/pkgs/servers/pulseaudio/default.nix @@ -116,6 +116,11 @@ stdenv.mkDerivation rec { "-Dsysconfdir=/etc" "-Dsysconfdir_install=${placeholder "out"}/etc" "-Dudevrulesdir=${placeholder "out"}/lib/udev/rules.d" + + # pulseaudio complains if its binary is moved after installation; + # this is needed so that wrapGApp can operate *without* + # renaming the unwrapped binaries (see below) + "--bindir=${placeholder "out"}/.bin-unwrapped" ] ++ lib.optional (stdenv.isLinux && useSystemd) "-Dsystemduserunitdir=${placeholder "out"}/lib/systemd/user" ++ lib.optionals stdenv.isDarwin [ @@ -133,11 +138,11 @@ stdenv.mkDerivation rec { postInstall = lib.optionalString libOnly '' find $out/share -maxdepth 1 -mindepth 1 ! -name "vala" -prune -exec rm -r {} \; find $out/share/vala -maxdepth 1 -mindepth 1 ! -name "vapi" -prune -exec rm -r {} \; - rm -r $out/{bin,etc,lib/pulse-*} + rm -r $out/{.bin-unwrapped,etc,lib/pulse-*} '' + '' moveToOutput lib/cmake "$dev" - rm -f $out/bin/qpaeq # this is packaged by the "qpaeq" package now, because of missing deps + rm -f $out/.bin-unwrapped/qpaeq # this is packaged by the "qpaeq" package now, because of missing deps ''; preFixup = lib.optionalString (stdenv.isLinux && (stdenv.hostPlatform == stdenv.buildPlatform)) '' @@ -151,6 +156,15 @@ stdenv.mkDerivation rec { ln -s "''$file" "''${file%.dylib}.so" ln -s "''$file" "$out/lib/pulseaudio/''$(basename ''$file .dylib).so" done + '' + # put symlinks to binaries in `$prefix/bin`; + # then wrapGApp will *rename these symlinks* instead of + # the original binaries in `$prefix/.bin-unwrapped` (see above); + # when pulseaudio is looking for its own binary (it does!), + # it will be happy to find it in its original installation location + + lib.optionalString (!libOnly) '' + mkdir -p $out/bin + ln -st $out/bin $out/.bin-unwrapped/* ''; passthru = { -- cgit v1.2.3 From 64d256ab15392c3b4059422e9dfe2eec46a9fece Mon Sep 17 00:00:00 2001 From: Yarny0 <41838844+Yarny0@users.noreply.github.com> Date: Thu, 18 Aug 2022 08:42:41 +0200 Subject: nixos/tests/pulseaudio: add test for pacmd Note that `pacmd` only connects to user session daemons, so we have to skip it in system wide mode. --- nixos/tests/pulseaudio.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nixos/tests/pulseaudio.nix b/nixos/tests/pulseaudio.nix index c0376204defe..dc8e33ccd559 100644 --- a/nixos/tests/pulseaudio.nix +++ b/nixos/tests/pulseaudio.nix @@ -60,6 +60,11 @@ let ''} machine.screenshot("testPlay") + ${lib.optionalString (!systemWide) '' + machine.send_chars("pacmd info && touch /tmp/pacmd_success\n") + machine.wait_for_file("/tmp/pacmd_success") + ''} + # Pavucontrol only loads when Pulseaudio is running. If it isn't, the # text "Dummy Output" (sound device name) will never show. machine.send_chars("pavucontrol\n") -- cgit v1.2.3