diff --git a/nixos/modules/services/desktops/pipewire.nix b/nixos/modules/services/desktops/pipewire.nix index c9c23593ce7..e3cdf0e5938 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 889a00d4b56..50ca8ad2b50 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 00000000000..f4154b5d2fd --- /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 b6cc22a18be..706d170ea43 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 00000000000..154a480b73c --- /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 00000000000..98fbd516a19 --- /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 +''