From cd81d4043e108c8d932605eac2130a82787e20b9 Mon Sep 17 00:00:00 2001 From: Nathaniel Glen Date: Thu, 23 Jul 2020 14:47:11 -0400 Subject: [PATCH 01/18] nixos/pipewire: add ALSA routing This code is based on the similar implementation for JACK. --- nixos/modules/services/desktops/pipewire.nix | 45 ++++++++++++++++++-- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/nixos/modules/services/desktops/pipewire.nix b/nixos/modules/services/desktops/pipewire.nix index 5aee59cfdcce..ed2f1c36016c 100644 --- a/nixos/modules/services/desktops/pipewire.nix +++ b/nixos/modules/services/desktops/pipewire.nix @@ -5,7 +5,9 @@ with lib; let cfg = config.services.pipewire; - packages = with pkgs; [ pipewire ]; + enable32BitAlsaPlugins = cfg.alsa.support32Bit + && pkgs.stdenv.isx86_64 + && pkgs.pkgsi686Linux.pipewire != null; in { @@ -25,17 +27,52 @@ in { Automatically run pipewire when connections are made to the pipewire socket. ''; }; + + alsa = { + enable = mkOption { + default = false; + type = types.bool; + description = '' + Route audio to/from generic ALSA-using applications via the ALSA PIPEWIRE PCM plugin. + ''; + }; + + support32Bit = mkOption { + default = false; + type = types.bool; + description = '' + Whether to support sound for 32-bit ALSA applications on a 64-bit system. + ''; + }; + }; }; }; ###### implementation config = mkIf cfg.enable { - environment.systemPackages = packages; + environment.systemPackages = [ pkgs.pipewire ]; - systemd.packages = packages; + systemd.packages = [ pkgs.pipewire ]; systemd.user.sockets.pipewire.wantedBy = lib.mkIf cfg.socketActivation [ "sockets.target" ]; - }; + sound.extraConfig = mkIf cfg.alsa.enable '' + pcm_type.pipewire { + libs.native = ${pkgs.pipewire.lib}/lib/alsa-lib/libasound_module_pcm_pipewire.so ; + ${optionalString enable32BitAlsaPlugins + "libs.32Bit = ${pkgs.pkgsi686Linux.pipewire.lib}/lib/alsa-lib/libasound_module_pcm_pipewire.so ;"} + } + pcm.!default { + @func getenv + vars [ PCM ] + default "plug:pipewire" + playback_mode "-1" + capture_mode "-1" + } + ''; + environment.etc."alsa/conf.d/50-pipewire.conf" = mkIf cfg.alsa.enable { + source = "${pkgs.pipewire}/share/alsa/alsa.conf.d/50-pipewire.conf"; + }; + }; } From ccefdd9dae70fd4ed1a6e6df5cf490b174efeb11 Mon Sep 17 00:00:00 2001 From: Nathaniel Glen Date: Fri, 24 Jul 2020 23:28:07 -0400 Subject: [PATCH 02/18] nixos/pipewire: add jack/pulse emulation This allows for transparent JACK and PulseAudio emulation. With this you can essentially replace your entire audio framework with just PipeWire for almost no configuration. --- nixos/modules/services/desktops/pipewire.nix | 33 +++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/desktops/pipewire.nix b/nixos/modules/services/desktops/pipewire.nix index ed2f1c36016c..c9c23593ce75 100644 --- a/nixos/modules/services/desktops/pipewire.nix +++ b/nixos/modules/services/desktops/pipewire.nix @@ -9,6 +9,14 @@ let && pkgs.stdenv.isx86_64 && pkgs.pkgsi686Linux.pipewire != null; + jack-libs = pkgs.runCommand "jack-libs" {} '' + mkdir -p "$out/lib" + ln -s "${pkgs.pipewire.lib}/lib/pipewire-0.3/jack" "$out/lib/pipewire" + ''; + pulse-libs = pkgs.runCommand "pulse-libs" {} '' + mkdir -p "$out/lib" + ln -s "${pkgs.pipewire.lib}/lib/pipewire-0.3/pulse" "$out/lib/pipewire" + ''; in { meta = { @@ -45,13 +53,35 @@ in { ''; }; }; + + jack = { + enable = mkOption { + default = false; + type = types.bool; + description = '' + Enable transparent JACK audio emulation using LD_LIBRARY_PATH. + ''; + }; + }; + + pulse = { + enable = mkOption { + default = false; + type = types.bool; + description = '' + Enable transparent PulseAudio emulation using LD_LIBRARY_PATH. + ''; + }; + }; }; }; ###### implementation config = mkIf cfg.enable { - environment.systemPackages = [ pkgs.pipewire ]; + environment.systemPackages = [ pkgs.pipewire ] + ++ lib.optional cfg.jack.enable jack-libs + ++ lib.optional cfg.pulse.enable pulse-libs; systemd.packages = [ pkgs.pipewire ]; @@ -74,5 +104,6 @@ in { environment.etc."alsa/conf.d/50-pipewire.conf" = mkIf cfg.alsa.enable { source = "${pkgs.pipewire}/share/alsa/alsa.conf.d/50-pipewire.conf"; }; + environment.sessionVariables.LD_LIBRARY_PATH = "/run/current-system/sw/lib/pipewire"; }; } From 89021b9a188880939b8683c0aabbb4b1cc5bece5 Mon Sep 17 00:00:00 2001 From: Nathaniel Glen Date: Wed, 5 Aug 2020 00:13:04 -0400 Subject: [PATCH 03/18] pipewire: 0.3.7 -> 0.3.9 Co-authored-by: Jan Tojnar --- .../pipewire/alsa-profiles-use-libdir.patch | 13 +++++++++++++ pkgs/development/libraries/pipewire/default.nix | 15 ++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 pkgs/development/libraries/pipewire/alsa-profiles-use-libdir.patch diff --git a/pkgs/development/libraries/pipewire/alsa-profiles-use-libdir.patch b/pkgs/development/libraries/pipewire/alsa-profiles-use-libdir.patch new file mode 100644 index 000000000000..c657d12f7d0c --- /dev/null +++ b/pkgs/development/libraries/pipewire/alsa-profiles-use-libdir.patch @@ -0,0 +1,13 @@ +diff --git a/meson.build b/meson.build +index ffee41b4..f3e4ec74 100644 +--- a/meson.build ++++ b/meson.build +@@ -53,7 +53,7 @@ endif + + spa_plugindir = join_paths(pipewire_libdir, spa_name) + +-alsadatadir = join_paths(pipewire_datadir, 'alsa-card-profile', 'mixer') ++alsadatadir = join_paths(pipewire_libdir, '..', 'share', 'alsa-card-profile', 'mixer') + + pipewire_headers_dir = join_paths(pipewire_name, 'pipewire') + diff --git a/pkgs/development/libraries/pipewire/default.nix b/pkgs/development/libraries/pipewire/default.nix index cb5073f50c15..b6cc22a18bee 100644 --- a/pkgs/development/libraries/pipewire/default.nix +++ b/pkgs/development/libraries/pipewire/default.nix @@ -24,6 +24,8 @@ , vulkan-loader , libpulseaudio , makeFontsConf +, ofonoSupport ? true +, nativeHspSupport ? true }: let @@ -33,7 +35,7 @@ let in stdenv.mkDerivation rec { pname = "pipewire"; - version = "0.3.7"; + version = "0.3.9"; outputs = [ "out" "lib" "dev" "doc" ]; @@ -42,9 +44,14 @@ stdenv.mkDerivation rec { owner = "pipewire"; repo = "pipewire"; rev = version; - sha256 = "04l66p0wj553gp2zf3vwwh6jbr1vkf6wrq4za9zlm9dn144am4j2"; + sha256 = "0q781r32mnm3qy6xcdd2rnb8g50gdi7mi50zmdiq24s24sr8f8r9"; }; + patches = [ + # Break up a dependency cycle between outputs. + ./alsa-profiles-use-libdir.patch + ]; + nativeBuildInputs = [ doxygen graphviz @@ -78,7 +85,9 @@ stdenv.mkDerivation rec { "-Ddocs=true" "-Dman=false" # we don't have xmltoman "-Dgstreamer=true" - ]; + "-Dudevrulesdir=lib/udev/rules.d" + ] ++ stdenv.lib.optional nativeHspSupport "-Dbluez5-backend-native=true" + ++ stdenv.lib.optional ofonoSupport "-Dbluez5-backend-ofono=true"; FONTCONFIG_FILE = fontsConf; # Fontconfig error: Cannot load default config file From e879eb6db6715faeafd6fc514c0e2752e4dcef3f Mon Sep 17 00:00:00 2001 From: Nathaniel Glen Date: Wed, 5 Aug 2020 14:48:37 -0400 Subject: [PATCH 04/18] pipewire: add testing This adds two tests. One is for whether the paths used by the module are present, while the other is for testing functionality of PipeWire itself. This is done with the recent addition of installed tests by upstream. --- nixos/modules/services/desktops/pipewire.nix | 1 + nixos/tests/installed-tests/default.nix | 1 + nixos/tests/installed-tests/pipewire.nix | 5 ++++ .../libraries/pipewire/default.nix | 28 ++++++++++++++++++- .../pipewire/installed-tests-path.patch | 15 ++++++++++ .../libraries/pipewire/test-paths.nix | 20 +++++++++++++ 6 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 nixos/tests/installed-tests/pipewire.nix create mode 100644 pkgs/development/libraries/pipewire/installed-tests-path.patch create mode 100644 pkgs/development/libraries/pipewire/test-paths.nix diff --git a/nixos/modules/services/desktops/pipewire.nix b/nixos/modules/services/desktops/pipewire.nix index c9c23593ce75..e3cdf0e5938d 100644 --- a/nixos/modules/services/desktops/pipewire.nix +++ b/nixos/modules/services/desktops/pipewire.nix @@ -87,6 +87,7 @@ in { systemd.user.sockets.pipewire.wantedBy = lib.mkIf cfg.socketActivation [ "sockets.target" ]; + # If any paths are updated here they must also be updated in the package test. sound.extraConfig = mkIf cfg.alsa.enable '' pcm_type.pipewire { libs.native = ${pkgs.pipewire.lib}/lib/alsa-lib/libasound_module_pcm_pipewire.so ; diff --git a/nixos/tests/installed-tests/default.nix b/nixos/tests/installed-tests/default.nix index 889a00d4b568..50ca8ad2b50f 100644 --- a/nixos/tests/installed-tests/default.nix +++ b/nixos/tests/installed-tests/default.nix @@ -101,5 +101,6 @@ in libxmlb = callInstalledTest ./libxmlb.nix {}; malcontent = callInstalledTest ./malcontent.nix {}; ostree = callInstalledTest ./ostree.nix {}; + pipewire = callInstalledTest ./pipewire.nix {}; xdg-desktop-portal = callInstalledTest ./xdg-desktop-portal.nix {}; } diff --git a/nixos/tests/installed-tests/pipewire.nix b/nixos/tests/installed-tests/pipewire.nix new file mode 100644 index 000000000000..f4154b5d2fd7 --- /dev/null +++ b/nixos/tests/installed-tests/pipewire.nix @@ -0,0 +1,5 @@ +{ pkgs, lib, makeInstalledTest, ... }: + +makeInstalledTest { + tested = pkgs.pipewire; +} diff --git a/pkgs/development/libraries/pipewire/default.nix b/pkgs/development/libraries/pipewire/default.nix index b6cc22a18bee..706d170ea430 100644 --- a/pkgs/development/libraries/pipewire/default.nix +++ b/pkgs/development/libraries/pipewire/default.nix @@ -24,6 +24,8 @@ , vulkan-loader , libpulseaudio , makeFontsConf +, callPackage +, nixosTests , ofonoSupport ? true , nativeHspSupport ? true }: @@ -37,7 +39,7 @@ stdenv.mkDerivation rec { pname = "pipewire"; version = "0.3.9"; - outputs = [ "out" "lib" "dev" "doc" ]; + outputs = [ "out" "lib" "dev" "doc" "installedTests" ]; src = fetchFromGitLab { domain = "gitlab.freedesktop.org"; @@ -50,8 +52,14 @@ stdenv.mkDerivation rec { patches = [ # Break up a dependency cycle between outputs. ./alsa-profiles-use-libdir.patch + # Move installed tests into their own output. + ./installed-tests-path.patch ]; + postPatch = '' + substituteInPlace meson.build --subst-var-by installed_tests_dir "$installedTests" + ''; + nativeBuildInputs = [ doxygen graphviz @@ -86,6 +94,7 @@ stdenv.mkDerivation rec { "-Dman=false" # we don't have xmltoman "-Dgstreamer=true" "-Dudevrulesdir=lib/udev/rules.d" + "-Dinstalled_tests=true" ] ++ stdenv.lib.optional nativeHspSupport "-Dbluez5-backend-native=true" ++ stdenv.lib.optional ofonoSupport "-Dbluez5-backend-ofono=true"; @@ -93,6 +102,23 @@ stdenv.mkDerivation rec { doCheck = true; + passthru.tests = { + installedTests = nixosTests.installed-tests.pipewire; + + # This ensures that all the paths used by the NixOS module are found. + test-paths = callPackage ./test-paths.nix { + paths-out = [ + "share/alsa/alsa.conf.d/50-pipewire.conf" + ]; + paths-lib = [ + "lib/alsa-lib/libasound_module_pcm_pipewire.so" + "lib/pipewire-0.3/jack" + "lib/pipewire-0.3/pulse" + "share/alsa-card-profile/mixer" + ]; + }; + }; + meta = with stdenv.lib; { description = "Server and user space API to deal with multimedia pipelines"; homepage = "https://pipewire.org/"; diff --git a/pkgs/development/libraries/pipewire/installed-tests-path.patch b/pkgs/development/libraries/pipewire/installed-tests-path.patch new file mode 100644 index 000000000000..154a480b73c0 --- /dev/null +++ b/pkgs/development/libraries/pipewire/installed-tests-path.patch @@ -0,0 +1,15 @@ +diff --git a/meson.build b/meson.build +index ffee41b4..b75921f9 100644 +--- a/meson.build ++++ b/meson.build +@@ -318,8 +318,8 @@ alsa_dep = (get_option('pipewire-alsa') + ? dependency('alsa', version : '>=1.1.7') + : dependency('', required: false)) + +-installed_tests_metadir = join_paths(pipewire_datadir, 'installed-tests', pipewire_name) +-installed_tests_execdir = join_paths(pipewire_libexecdir, 'installed-tests', pipewire_name) ++installed_tests_metadir = join_paths('@installed_tests_dir@', 'share', 'installed-tests', pipewire_name) ++installed_tests_execdir = join_paths('@installed_tests_dir@', 'libexec', 'installed-tests', pipewire_name) + installed_tests_enabled = get_option('installed_tests') + installed_tests_template = files('template.test.in') + diff --git a/pkgs/development/libraries/pipewire/test-paths.nix b/pkgs/development/libraries/pipewire/test-paths.nix new file mode 100644 index 000000000000..98fbd516a194 --- /dev/null +++ b/pkgs/development/libraries/pipewire/test-paths.nix @@ -0,0 +1,20 @@ +{ lib, runCommand, pipewire, paths-out, paths-lib }: + +runCommand "pipewire-test-paths" { } '' + ${lib.concatMapStringsSep "\n" (p: '' + if [ ! -f "${pipewire.lib}/${p}" ] && [ ! -d "${pipewire.lib}/${p}" ]; then + printf "pipewire failed to find the following path: %s\n" "${pipewire.lib}/${p}" + error=error + fi + '') paths-lib} + + ${lib.concatMapStringsSep "\n" (p: '' + if [ ! -f "${pipewire}/${p}" ] && [ ! -d "${pipewire}/${p}" ]; then + printf "pipewire failed to find the following path: %s\n" "${pipewire}/${p}" + error=error + fi + '') paths-out} + + [ -n "$error" ] && exit 1 + touch $out +'' From f01be2978b5d58682dc9cda6e72695f0059d0552 Mon Sep 17 00:00:00 2001 From: Nathaniel Glen Date: Wed, 12 Aug 2020 13:42:47 -0400 Subject: [PATCH 05/18] nixos/pipewire: use globs for the version --- nixos/modules/services/desktops/pipewire.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/desktops/pipewire.nix b/nixos/modules/services/desktops/pipewire.nix index e3cdf0e5938d..1a47cb27c16e 100644 --- a/nixos/modules/services/desktops/pipewire.nix +++ b/nixos/modules/services/desktops/pipewire.nix @@ -11,11 +11,11 @@ let jack-libs = pkgs.runCommand "jack-libs" {} '' mkdir -p "$out/lib" - ln -s "${pkgs.pipewire.lib}/lib/pipewire-0.3/jack" "$out/lib/pipewire" + ln -s "${pkgs.pipewire.lib}"/lib/pipewire-*/jack "$out/lib/pipewire" ''; pulse-libs = pkgs.runCommand "pulse-libs" {} '' mkdir -p "$out/lib" - ln -s "${pkgs.pipewire.lib}/lib/pipewire-0.3/pulse" "$out/lib/pipewire" + ln -s "${pkgs.pipewire.lib}"/lib/pipewire-*/pulse "$out/lib/pipewire" ''; in { From 3377257d0b7211cb564b9e53f9a2b35a13381a8b Mon Sep 17 00:00:00 2001 From: Nathaniel Glen Date: Mon, 31 Aug 2020 14:28:01 -0400 Subject: [PATCH 06/18] pipewire: split pulse and jack emulation out This splits PulseAudio and JACK emulation into separate outputs. Doing so provides a number of benefits. First it fixes pw-pulse and pw-jack. Prior to this they pointed to bogus locations because the environment variables were not evaluated. Technically fixing this only requires setting libpulse-path and libjack-path to any absolute path not necessarily separate outputs but it comes as a nice result. Secondly it allows overriding libpulseaudio with pipewire.pulse in many packages. This is possible because the new outputs have a more standard layout. --- nixos/modules/services/desktops/pipewire.nix | 4 ++-- pkgs/development/libraries/pipewire/default.nix | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/nixos/modules/services/desktops/pipewire.nix b/nixos/modules/services/desktops/pipewire.nix index 1a47cb27c16e..6168c252e310 100644 --- a/nixos/modules/services/desktops/pipewire.nix +++ b/nixos/modules/services/desktops/pipewire.nix @@ -11,11 +11,11 @@ let jack-libs = pkgs.runCommand "jack-libs" {} '' mkdir -p "$out/lib" - ln -s "${pkgs.pipewire.lib}"/lib/pipewire-*/jack "$out/lib/pipewire" + ln -s "${pkgs.pipewire.jack}/lib" "$out/lib/pipewire" ''; pulse-libs = pkgs.runCommand "pulse-libs" {} '' mkdir -p "$out/lib" - ln -s "${pkgs.pipewire.lib}"/lib/pipewire-*/pulse "$out/lib/pipewire" + ln -s "${pkgs.pipewire.pulse}/lib" "$out/lib/pipewire" ''; in { diff --git a/pkgs/development/libraries/pipewire/default.nix b/pkgs/development/libraries/pipewire/default.nix index 706d170ea430..8fc3ecb38736 100644 --- a/pkgs/development/libraries/pipewire/default.nix +++ b/pkgs/development/libraries/pipewire/default.nix @@ -39,7 +39,15 @@ stdenv.mkDerivation rec { pname = "pipewire"; version = "0.3.9"; - outputs = [ "out" "lib" "dev" "doc" "installedTests" ]; + outputs = [ + "out" + "lib" + "pulse" + "jack" + "dev" + "doc" + "installedTests" + ]; src = fetchFromGitLab { domain = "gitlab.freedesktop.org"; @@ -95,6 +103,8 @@ stdenv.mkDerivation rec { "-Dgstreamer=true" "-Dudevrulesdir=lib/udev/rules.d" "-Dinstalled_tests=true" + "-Dlibpulse-path=${placeholder "pulse"}/lib" + "-Dlibjack-path=${placeholder "jack"}/lib" ] ++ stdenv.lib.optional nativeHspSupport "-Dbluez5-backend-native=true" ++ stdenv.lib.optional ofonoSupport "-Dbluez5-backend-ofono=true"; From 994a2fe27cdbcb0859919969d30c1f453e143895 Mon Sep 17 00:00:00 2001 From: Nathaniel Glen Date: Mon, 31 Aug 2020 14:37:36 -0400 Subject: [PATCH 07/18] pipewire: remove direct dependency on PulseAudio Since PulseAudio is required as a build input, the libraries mistakenly reference the original libpulse.so rather than the custom one. --- pkgs/development/libraries/pipewire/default.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkgs/development/libraries/pipewire/default.nix b/pkgs/development/libraries/pipewire/default.nix index 8fc3ecb38736..60c08f2906c3 100644 --- a/pkgs/development/libraries/pipewire/default.nix +++ b/pkgs/development/libraries/pipewire/default.nix @@ -112,6 +112,14 @@ stdenv.mkDerivation rec { doCheck = true; + preFixup = '' + # The rpaths mistakenly points to libpulseaudio instead + for file in "$pulse"/lib/*.so; do + oldrpath="$(patchelf --print-rpath "$file")" + patchelf --set-rpath "$pulse/lib:$oldrpath" "$file" + done + ''; + passthru.tests = { installedTests = nixosTests.installed-tests.pipewire; From c6036190421c4b6093d02b35064ce8b217454bb1 Mon Sep 17 00:00:00 2001 From: Nathaniel Glen Date: Mon, 7 Sep 2020 11:03:58 -0400 Subject: [PATCH 08/18] nixos/pipewire: use provided udev rules As of PipeWire 0.3.8, the library is bundled with a slightly modified version of PulseAudio's udev rules. --- nixos/modules/services/desktops/pipewire.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/nixos/modules/services/desktops/pipewire.nix b/nixos/modules/services/desktops/pipewire.nix index 6168c252e310..4ea18e7ae1a8 100644 --- a/nixos/modules/services/desktops/pipewire.nix +++ b/nixos/modules/services/desktops/pipewire.nix @@ -86,6 +86,7 @@ in { systemd.packages = [ pkgs.pipewire ]; systemd.user.sockets.pipewire.wantedBy = lib.mkIf cfg.socketActivation [ "sockets.target" ]; + services.udev.packages = [ pkgs.pipewire ]; # If any paths are updated here they must also be updated in the package test. sound.extraConfig = mkIf cfg.alsa.enable '' From 888c1fbf96c3c167d2216f4451438a335c1c547b Mon Sep 17 00:00:00 2001 From: Nathaniel Glen Date: Thu, 10 Sep 2020 12:54:48 -0400 Subject: [PATCH 09/18] nixos/pipewire: add missing dbus dependency Without this it is possible for PipeWire to fail in binding the dbus socket. --- nixos/modules/services/desktops/pipewire.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/nixos/modules/services/desktops/pipewire.nix b/nixos/modules/services/desktops/pipewire.nix index 4ea18e7ae1a8..d51e00c00fd3 100644 --- a/nixos/modules/services/desktops/pipewire.nix +++ b/nixos/modules/services/desktops/pipewire.nix @@ -86,6 +86,7 @@ in { systemd.packages = [ pkgs.pipewire ]; systemd.user.sockets.pipewire.wantedBy = lib.mkIf cfg.socketActivation [ "sockets.target" ]; + systemd.user.services.pipewire.bindsTo = [ "dbus.service" ]; services.udev.packages = [ pkgs.pipewire ]; # If any paths are updated here they must also be updated in the package test. From 040059b5d5b6db5def40be2d797188c89bd585b6 Mon Sep 17 00:00:00 2001 From: Nathaniel Glen Date: Thu, 10 Sep 2020 13:11:56 -0400 Subject: [PATCH 10/18] pipewire: update to 0.3.11 --- pkgs/development/libraries/pipewire/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/libraries/pipewire/default.nix b/pkgs/development/libraries/pipewire/default.nix index 60c08f2906c3..356140d9e365 100644 --- a/pkgs/development/libraries/pipewire/default.nix +++ b/pkgs/development/libraries/pipewire/default.nix @@ -37,7 +37,7 @@ let in stdenv.mkDerivation rec { pname = "pipewire"; - version = "0.3.9"; + version = "0.3.11"; outputs = [ "out" @@ -54,7 +54,7 @@ stdenv.mkDerivation rec { owner = "pipewire"; repo = "pipewire"; rev = version; - sha256 = "0q781r32mnm3qy6xcdd2rnb8g50gdi7mi50zmdiq24s24sr8f8r9"; + sha256 = "1wbir3napjxcpjy2m70im0l2x1ylg541rwq6hhvm8z0n5khxgfy7"; }; patches = [ From 2fdf6dc94c7cb952b676f987ba31998a0ce6b1c9 Mon Sep 17 00:00:00 2001 From: Nathaniel Glen Date: Fri, 11 Sep 2020 11:47:07 -0400 Subject: [PATCH 11/18] pipewire: remove old tests --- pkgs/development/libraries/pipewire/default.nix | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkgs/development/libraries/pipewire/default.nix b/pkgs/development/libraries/pipewire/default.nix index 356140d9e365..179e1aec9afe 100644 --- a/pkgs/development/libraries/pipewire/default.nix +++ b/pkgs/development/libraries/pipewire/default.nix @@ -130,8 +130,6 @@ stdenv.mkDerivation rec { ]; paths-lib = [ "lib/alsa-lib/libasound_module_pcm_pipewire.so" - "lib/pipewire-0.3/jack" - "lib/pipewire-0.3/pulse" "share/alsa-card-profile/mixer" ]; }; From 59cbf9746c162359b9bbad334be8b43a2a1548aa Mon Sep 17 00:00:00 2001 From: Nathaniel Glen Date: Sat, 19 Sep 2020 18:00:44 -0400 Subject: [PATCH 12/18] nixos/pipewire: fix variable merging While both strings and lists are valid, lists are the more accurate type and only they can properly merge with each other. --- nixos/modules/services/desktops/pipewire.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/services/desktops/pipewire.nix b/nixos/modules/services/desktops/pipewire.nix index d51e00c00fd3..d527343966d7 100644 --- a/nixos/modules/services/desktops/pipewire.nix +++ b/nixos/modules/services/desktops/pipewire.nix @@ -107,6 +107,6 @@ in { environment.etc."alsa/conf.d/50-pipewire.conf" = mkIf cfg.alsa.enable { source = "${pkgs.pipewire}/share/alsa/alsa.conf.d/50-pipewire.conf"; }; - environment.sessionVariables.LD_LIBRARY_PATH = "/run/current-system/sw/lib/pipewire"; + environment.sessionVariables.LD_LIBRARY_PATH = [ "/run/current-system/sw/lib/pipewire" ]; }; } From 798b9c072e0cbda4298350310684750f04a11fd8 Mon Sep 17 00:00:00 2001 From: Nathaniel Glen Date: Fri, 23 Oct 2020 13:34:45 -0400 Subject: [PATCH 13/18] pipewire: update to 0.3.12 --- .../libraries/pipewire/default.nix | 47 ++++++++++--------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/pkgs/development/libraries/pipewire/default.nix b/pkgs/development/libraries/pipewire/default.nix index 179e1aec9afe..2c6062056644 100644 --- a/pkgs/development/libraries/pipewire/default.nix +++ b/pkgs/development/libraries/pipewire/default.nix @@ -1,43 +1,44 @@ { stdenv +, lib , fetchFromGitLab -, fetchpatch , meson , ninja +, systemd , pkgconfig , doxygen , graphviz , valgrind , glib , dbus -, gst_all_1 , alsaLib -, ffmpeg_3 , libjack2 , udev , libva -, xorg -, sbc -, SDL2 , libsndfile -, bluez , vulkan-headers , vulkan-loader , libpulseaudio , makeFontsConf , callPackage , nixosTests -, ofonoSupport ? true +, gstreamerSupport ? true, gst_all_1 ? null +, ffmpegSupport ? true, ffmpeg ? null +, bluezSupport ? true, bluez ? null, sbc ? null , nativeHspSupport ? true +, ofonoSupport ? true +, hsphfpdSupport ? false }: let fontsConf = makeFontsConf { fontDirectories = []; }; + + mesonBool = b: if b then "true" else "false"; in stdenv.mkDerivation rec { pname = "pipewire"; - version = "0.3.11"; + version = "0.3.12"; outputs = [ "out" @@ -54,7 +55,7 @@ stdenv.mkDerivation rec { owner = "pipewire"; repo = "pipewire"; rev = version; - sha256 = "1wbir3napjxcpjy2m70im0l2x1ylg541rwq6hhvm8z0n5khxgfy7"; + sha256 = "14w9sgznrvcs31qzbzz1vyp4p2sljawbrzhr93921ss0iqivhfwl"; }; patches = [ @@ -74,39 +75,39 @@ stdenv.mkDerivation rec { meson ninja pkgconfig - valgrind ]; buildInputs = [ - SDL2 alsaLib - bluez dbus - ffmpeg_3 glib - gst_all_1.gst-plugins-base - gst_all_1.gstreamer libjack2 libpulseaudio libsndfile - libva - sbc udev vulkan-headers vulkan-loader - xorg.libX11 - ]; + valgrind + systemd + ] ++ lib.optionals gstreamerSupport [ gst_all_1.gst-plugins-base gst_all_1.gstreamer ] + ++ lib.optional ffmpegSupport ffmpeg + ++ lib.optionals bluezSupport [ bluez sbc ]; mesonFlags = [ "-Ddocs=true" "-Dman=false" # we don't have xmltoman - "-Dgstreamer=true" + "-Dexamples=true" # only needed for `pipewire-media-session` "-Dudevrulesdir=lib/udev/rules.d" "-Dinstalled_tests=true" "-Dlibpulse-path=${placeholder "pulse"}/lib" "-Dlibjack-path=${placeholder "jack"}/lib" - ] ++ stdenv.lib.optional nativeHspSupport "-Dbluez5-backend-native=true" - ++ stdenv.lib.optional ofonoSupport "-Dbluez5-backend-ofono=true"; + "-Dgstreamer=${mesonBool gstreamerSupport}" + "-Dffmpeg=${mesonBool ffmpegSupport}" + "-Dbluez5=${mesonBool bluezSupport}" + "-Dbluez5-backend-native=${mesonBool nativeHspSupport}" + "-Dbluez5-backend-ofono=${mesonBool ofonoSupport}" + "-Dbluez5-backend-hsphfpd=${mesonBool hsphfpdSupport}" + ]; FONTCONFIG_FILE = fontsConf; # Fontconfig error: Cannot load default config file From f6745d06f5dc6c357e9bc101f524a5ced3562921 Mon Sep 17 00:00:00 2001 From: Nathaniel Glen Date: Fri, 23 Oct 2020 13:36:56 -0400 Subject: [PATCH 14/18] nixos/pipewire: cleanup module --- nixos/modules/services/desktops/pipewire.nix | 53 +++++++++----------- 1 file changed, 23 insertions(+), 30 deletions(-) diff --git a/nixos/modules/services/desktops/pipewire.nix b/nixos/modules/services/desktops/pipewire.nix index d527343966d7..ed1b15380ffe 100644 --- a/nixos/modules/services/desktops/pipewire.nix +++ b/nixos/modules/services/desktops/pipewire.nix @@ -9,6 +9,10 @@ let && pkgs.stdenv.isx86_64 && pkgs.pkgsi686Linux.pipewire != null; + # The package doesn't output to $out/lib/pipewire directly so that the + # overlays can use the outputs to replace the originals in FHS environments. + # + # This doesn't work in general because of missing development information. jack-libs = pkgs.runCommand "jack-libs" {} '' mkdir -p "$out/lib" ln -s "${pkgs.pipewire.jack}/lib" "$out/lib/pipewire" @@ -37,41 +41,16 @@ in { }; alsa = { - enable = mkOption { - default = false; - type = types.bool; - description = '' - Route audio to/from generic ALSA-using applications via the ALSA PIPEWIRE PCM plugin. - ''; - }; - - support32Bit = mkOption { - default = false; - type = types.bool; - description = '' - Whether to support sound for 32-bit ALSA applications on a 64-bit system. - ''; - }; + enable = mkEnableOption "ALSA support"; + support32Bit = mkEnableOption "32-bit ALSA support on 64-bit systems"; }; jack = { - enable = mkOption { - default = false; - type = types.bool; - description = '' - Enable transparent JACK audio emulation using LD_LIBRARY_PATH. - ''; - }; + enable = mkEnableOption "JACK audio emulation"; }; pulse = { - enable = mkOption { - default = false; - type = types.bool; - description = '' - Enable transparent PulseAudio emulation using LD_LIBRARY_PATH. - ''; - }; + enable = mkEnableOption "PulseAudio emulation"; }; }; }; @@ -79,12 +58,25 @@ in { ###### implementation config = mkIf cfg.enable { + assertions = [ + { + assertion = cfg.pulse.enable -> !config.hardware.pulseaudio.enable; + message = "PipeWire based PulseAudio emulation doesn't use the PulseAudio service"; + } + { + assertion = cfg.jack.enable -> !config.services.jack.jackd.enable; + message = "PIpeWire based JACK emulation doesn't use the JACK service"; + } + ]; + environment.systemPackages = [ pkgs.pipewire ] ++ lib.optional cfg.jack.enable jack-libs ++ lib.optional cfg.pulse.enable pulse-libs; systemd.packages = [ pkgs.pipewire ]; + # PipeWire depends on DBUS but doesn't list it. Without this booting + # into a terminal results in the service crashing with an error. systemd.user.sockets.pipewire.wantedBy = lib.mkIf cfg.socketActivation [ "sockets.target" ]; systemd.user.services.pipewire.bindsTo = [ "dbus.service" ]; services.udev.packages = [ pkgs.pipewire ]; @@ -107,6 +99,7 @@ in { environment.etc."alsa/conf.d/50-pipewire.conf" = mkIf cfg.alsa.enable { source = "${pkgs.pipewire}/share/alsa/alsa.conf.d/50-pipewire.conf"; }; - environment.sessionVariables.LD_LIBRARY_PATH = [ "/run/current-system/sw/lib/pipewire" ]; + environment.sessionVariables.LD_LIBRARY_PATH = + lib.optional (cfg.alsa.enable || cfg.jack.enable || cfg.pulse.enable) "/run/current-system/sw/lib/pipewire"; }; } From 68fa82a0ae9e11cbf6b05fc4123639ef448766ef Mon Sep 17 00:00:00 2001 From: Nathaniel Glen Date: Fri, 23 Oct 2020 13:40:59 -0400 Subject: [PATCH 15/18] pipewire: use meson options for installed_tests --- .../libraries/pipewire/default.nix | 4 +--- .../pipewire/installed-tests-path.patch | 20 ++++++++++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/pkgs/development/libraries/pipewire/default.nix b/pkgs/development/libraries/pipewire/default.nix index 2c6062056644..153042be774c 100644 --- a/pkgs/development/libraries/pipewire/default.nix +++ b/pkgs/development/libraries/pipewire/default.nix @@ -65,9 +65,6 @@ stdenv.mkDerivation rec { ./installed-tests-path.patch ]; - postPatch = '' - substituteInPlace meson.build --subst-var-by installed_tests_dir "$installedTests" - ''; nativeBuildInputs = [ doxygen @@ -99,6 +96,7 @@ stdenv.mkDerivation rec { "-Dexamples=true" # only needed for `pipewire-media-session` "-Dudevrulesdir=lib/udev/rules.d" "-Dinstalled_tests=true" + "-Dinstalled_test_prefix=${placeholder "installedTests"}" "-Dlibpulse-path=${placeholder "pulse"}/lib" "-Dlibjack-path=${placeholder "jack"}/lib" "-Dgstreamer=${mesonBool gstreamerSupport}" diff --git a/pkgs/development/libraries/pipewire/installed-tests-path.patch b/pkgs/development/libraries/pipewire/installed-tests-path.patch index 154a480b73c0..2a92711626bf 100644 --- a/pkgs/development/libraries/pipewire/installed-tests-path.patch +++ b/pkgs/development/libraries/pipewire/installed-tests-path.patch @@ -1,5 +1,5 @@ diff --git a/meson.build b/meson.build -index ffee41b4..b75921f9 100644 +index ffee41b4..bab6f019 100644 --- a/meson.build +++ b/meson.build @@ -318,8 +318,8 @@ alsa_dep = (get_option('pipewire-alsa') @@ -8,8 +8,22 @@ index ffee41b4..b75921f9 100644 -installed_tests_metadir = join_paths(pipewire_datadir, 'installed-tests', pipewire_name) -installed_tests_execdir = join_paths(pipewire_libexecdir, 'installed-tests', pipewire_name) -+installed_tests_metadir = join_paths('@installed_tests_dir@', 'share', 'installed-tests', pipewire_name) -+installed_tests_execdir = join_paths('@installed_tests_dir@', 'libexec', 'installed-tests', pipewire_name) ++installed_tests_metadir = join_paths(get_option('installed_test_prefix'), 'share', 'installed-tests', pipewire_name) ++installed_tests_execdir = join_paths(get_option('installed_test_prefix'), 'libexec', 'installed-tests', pipewire_name) installed_tests_enabled = get_option('installed_tests') installed_tests_template = files('template.test.in') +diff --git a/meson_options.txt b/meson_options.txt +index f03033c3..32df6c53 100644 +--- a/meson_options.txt ++++ b/meson_options.txt +@@ -18,6 +18,9 @@ option('installed_tests', + description: 'Install manual and automated test executables', + type: 'boolean', + value: false) ++option('installed_test_prefix', ++ description: 'Prefix for installed tests', ++ type: 'string') + option('gstreamer', + description: 'Build GStreamer plugins', + type: 'boolean', From 9397d535bddf4bd296f5d155edf7461d6c379e87 Mon Sep 17 00:00:00 2001 From: Nathaniel Glen Date: Fri, 23 Oct 2020 13:42:50 -0400 Subject: [PATCH 16/18] pipewire: remove pulseaudio references This replaces the temporary RPATH fix with the new upstream patch from jtojnar. It also removes the reference to the dev output. --- .../libraries/pipewire/default.nix | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/pkgs/development/libraries/pipewire/default.nix b/pkgs/development/libraries/pipewire/default.nix index 153042be774c..9d3a6f77ab8c 100644 --- a/pkgs/development/libraries/pipewire/default.nix +++ b/pkgs/development/libraries/pipewire/default.nix @@ -1,6 +1,8 @@ { stdenv , lib , fetchFromGitLab +, fetchpatch +, removeReferencesTo , meson , ninja , systemd @@ -63,8 +65,14 @@ stdenv.mkDerivation rec { ./alsa-profiles-use-libdir.patch # Move installed tests into their own output. ./installed-tests-path.patch - ]; + # TODO Remove this on next update + # Fixes rpath referencecs. + (fetchpatch { + url = "https://gitlab.freedesktop.org/pipewire/pipewire/commit/2e3556fa128b778be62a7ffad5fbe78393035825.diff"; + sha256 = "039yysb8j1aiqml54rxnaqfmzqz1b6m8sv5w3vz52grvav3kyr1l"; + }) + ]; nativeBuildInputs = [ doxygen @@ -72,6 +80,7 @@ stdenv.mkDerivation rec { meson ninja pkgconfig + removeReferencesTo ]; buildInputs = [ @@ -111,12 +120,10 @@ stdenv.mkDerivation rec { doCheck = true; + # Pulseaudio asserts lead to dev references. + # TODO This should be fixed in the pulseaudio sources instead. preFixup = '' - # The rpaths mistakenly points to libpulseaudio instead - for file in "$pulse"/lib/*.so; do - oldrpath="$(patchelf --print-rpath "$file")" - patchelf --set-rpath "$pulse/lib:$oldrpath" "$file" - done + remove-references-to -t ${libpulseaudio.dev} "$(readlink -f $pulse/lib/libpulse.so)" ''; passthru.tests = { From 57510bf522c90c63fec9b086a42b661ffdaf43c7 Mon Sep 17 00:00:00 2001 From: Nathaniel Glen Date: Fri, 23 Oct 2020 16:09:18 -0400 Subject: [PATCH 17/18] pipewire: cleanup path testing --- nixos/modules/services/desktops/pipewire.nix | 2 +- .../libraries/pipewire/test-paths.nix | 29 ++++++++++--------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/nixos/modules/services/desktops/pipewire.nix b/nixos/modules/services/desktops/pipewire.nix index ed1b15380ffe..5179cbaf6bc2 100644 --- a/nixos/modules/services/desktops/pipewire.nix +++ b/nixos/modules/services/desktops/pipewire.nix @@ -100,6 +100,6 @@ in { source = "${pkgs.pipewire}/share/alsa/alsa.conf.d/50-pipewire.conf"; }; environment.sessionVariables.LD_LIBRARY_PATH = - lib.optional (cfg.alsa.enable || cfg.jack.enable || cfg.pulse.enable) "/run/current-system/sw/lib/pipewire"; + lib.optional (cfg.jack.enable || cfg.pulse.enable) "/run/current-system/sw/lib/pipewire"; }; } diff --git a/pkgs/development/libraries/pipewire/test-paths.nix b/pkgs/development/libraries/pipewire/test-paths.nix index 98fbd516a194..0ae693741946 100644 --- a/pkgs/development/libraries/pipewire/test-paths.nix +++ b/pkgs/development/libraries/pipewire/test-paths.nix @@ -1,20 +1,23 @@ { lib, runCommand, pipewire, paths-out, paths-lib }: -runCommand "pipewire-test-paths" { } '' - ${lib.concatMapStringsSep "\n" (p: '' - if [ ! -f "${pipewire.lib}/${p}" ] && [ ! -d "${pipewire.lib}/${p}" ]; then - printf "pipewire failed to find the following path: %s\n" "${pipewire.lib}/${p}" +let + check-path = output: path: '' + if [[ ! -f "${output}/${path}" && ! -d "${output}/${path}" ]]; then + printf "Missing: %s\n" "${output}/${path}" | tee -a $out error=error + else + printf "Found: %s\n" "${output}/${path}" | tee -a $out fi - '') paths-lib} + ''; - ${lib.concatMapStringsSep "\n" (p: '' - if [ ! -f "${pipewire}/${p}" ] && [ ! -d "${pipewire}/${p}" ]; then - printf "pipewire failed to find the following path: %s\n" "${pipewire}/${p}" - error=error - fi - '') paths-out} - - [ -n "$error" ] && exit 1 + check-output = output: lib.concatMapStringsSep "\n" (check-path output); +in runCommand "pipewire-test-paths" { } '' touch $out + + ${check-output pipewire.lib paths-lib} + ${check-output pipewire paths-out} + + if [[ -n "$error" ]]; then + exit 1 + fi '' From 4bca42a6ec4e442f1a3a4b781b1adb529bf049e0 Mon Sep 17 00:00:00 2001 From: Nathaniel Glen Date: Fri, 23 Oct 2020 16:36:14 -0400 Subject: [PATCH 18/18] pipewire: update to 0.3.13 --- pkgs/development/libraries/pipewire/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/libraries/pipewire/default.nix b/pkgs/development/libraries/pipewire/default.nix index 9d3a6f77ab8c..d8a58e6a8eab 100644 --- a/pkgs/development/libraries/pipewire/default.nix +++ b/pkgs/development/libraries/pipewire/default.nix @@ -40,7 +40,7 @@ let in stdenv.mkDerivation rec { pname = "pipewire"; - version = "0.3.12"; + version = "0.3.13"; outputs = [ "out" @@ -57,7 +57,7 @@ stdenv.mkDerivation rec { owner = "pipewire"; repo = "pipewire"; rev = version; - sha256 = "14w9sgznrvcs31qzbzz1vyp4p2sljawbrzhr93921ss0iqivhfwl"; + sha256 = "19j5kmb7iaivkq2agfzncfm2qms41ckqi0ddxvhpc91ihwprdc5w"; }; patches = [