about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/pipewire
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/pipewire')
-rw-r--r--nixpkgs/pkgs/development/libraries/pipewire/0.2.nix49
-rw-r--r--nixpkgs/pkgs/development/libraries/pipewire/alsa-profiles-use-libdir.patch13
-rw-r--r--nixpkgs/pkgs/development/libraries/pipewire/default.nix146
-rw-r--r--nixpkgs/pkgs/development/libraries/pipewire/installed-tests-path.patch29
-rw-r--r--nixpkgs/pkgs/development/libraries/pipewire/pipewire-config-dir.patch30
-rw-r--r--nixpkgs/pkgs/development/libraries/pipewire/pipewire-pulse-path.patch24
-rw-r--r--nixpkgs/pkgs/development/libraries/pipewire/test-paths.nix23
7 files changed, 314 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/pipewire/0.2.nix b/nixpkgs/pkgs/development/libraries/pipewire/0.2.nix
new file mode 100644
index 000000000000..1e686b980043
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/pipewire/0.2.nix
@@ -0,0 +1,49 @@
+{ lib, stdenv, fetchFromGitHub, meson, ninja, pkg-config, doxygen, graphviz, valgrind
+, glib, dbus, gst_all_1, alsaLib, ffmpeg_4, libjack2, udev, libva, xorg
+, sbc, SDL2, makeFontsConf
+}:
+
+let
+  fontsConf = makeFontsConf {
+    fontDirectories = [ ];
+  };
+in stdenv.mkDerivation rec {
+  pname = "pipewire";
+  version = "0.2.7";
+
+  src = fetchFromGitHub {
+    owner = "PipeWire";
+    repo = "pipewire";
+    rev = version;
+    sha256 = "1q5wrqnhhs6r49p8yvkw1pl0cnsd4rndxy4h5lvdydwgf1civcwc";
+  };
+
+  outputs = [ "out" "lib" "dev" "doc" ];
+
+  nativeBuildInputs = [
+    meson ninja pkg-config doxygen graphviz valgrind
+  ];
+  buildInputs = [
+    glib dbus gst_all_1.gst-plugins-base gst_all_1.gstreamer
+    alsaLib ffmpeg_4 libjack2 udev libva xorg.libX11 sbc SDL2
+  ];
+
+  mesonFlags = [
+    "-Ddocs=true"
+    "-Dgstreamer=enabled"
+  ];
+
+  PKG_CONFIG_SYSTEMD_SYSTEMDUSERUNITDIR = "${placeholder "out"}/lib/systemd/user";
+
+  FONTCONFIG_FILE = fontsConf; # Fontconfig error: Cannot load default config file
+
+  doCheck = true;
+
+  meta = with lib; {
+    description = "Server and user space API to deal with multimedia pipelines";
+    homepage = "https://pipewire.org/";
+    license = licenses.lgpl21;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ jtojnar ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/pipewire/alsa-profiles-use-libdir.patch b/nixpkgs/pkgs/development/libraries/pipewire/alsa-profiles-use-libdir.patch
new file mode 100644
index 000000000000..c657d12f7d0c
--- /dev/null
+++ b/nixpkgs/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/nixpkgs/pkgs/development/libraries/pipewire/default.nix b/nixpkgs/pkgs/development/libraries/pipewire/default.nix
new file mode 100644
index 000000000000..fdd45b4bb0d9
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/pipewire/default.nix
@@ -0,0 +1,146 @@
+{ stdenv
+, lib
+, fetchFromGitLab
+, fetchpatch
+, removeReferencesTo
+, meson
+, ninja
+, systemd
+, pkg-config
+, doxygen
+, graphviz
+, valgrind
+, glib
+, dbus
+, alsaLib
+, libjack2
+, udev
+, libva
+, libsndfile
+, vulkan-headers
+, vulkan-loader
+, makeFontsConf
+, callPackage
+, nixosTests
+, gstreamerSupport ? true, gst_all_1 ? null
+, ffmpegSupport ? true, ffmpeg ? null
+, bluezSupport ? true, bluez ? null, sbc ? null, libopenaptx ? null, ldacbt ? null
+, nativeHspSupport ? true
+, ofonoSupport ? true
+, hsphfpdSupport ? true
+}:
+
+let
+  fontsConf = makeFontsConf {
+    fontDirectories = [];
+  };
+
+  mesonBool = b: if b then "true" else "false";
+in
+stdenv.mkDerivation rec {
+  pname = "pipewire";
+  version = "0.3.18";
+
+  outputs = [
+    "out"
+    "lib"
+    "pulse"
+    "jack"
+    "dev"
+    "doc"
+    "installedTests"
+  ];
+
+  src = fetchFromGitLab {
+    domain = "gitlab.freedesktop.org";
+    owner = "pipewire";
+    repo = "pipewire";
+    rev = version;
+    sha256 = "1yghhgs18yqrnd0b2r75l5n8yng962r1wszbsi01v6i9zib3jc9g";
+  };
+
+  patches = [
+    # Break up a dependency cycle between outputs.
+    ./alsa-profiles-use-libdir.patch
+    # Move installed tests into their own output.
+    ./installed-tests-path.patch
+    # Change the path of the pipewire-pulse binary in the service definition.
+    ./pipewire-pulse-path.patch
+    # Add flag to specify configuration directory (different from the installation directory).
+    ./pipewire-config-dir.patch
+  ];
+
+  nativeBuildInputs = [
+    doxygen
+    graphviz
+    meson
+    ninja
+    pkg-config
+  ];
+
+  buildInputs = [
+    alsaLib
+    dbus
+    glib
+    libjack2
+    libsndfile
+    udev
+    vulkan-headers
+    vulkan-loader
+    valgrind
+    systemd
+  ] ++ lib.optionals gstreamerSupport [ gst_all_1.gst-plugins-base gst_all_1.gstreamer ]
+  ++ lib.optional ffmpegSupport ffmpeg
+  ++ lib.optionals bluezSupport [ bluez libopenaptx ldacbt sbc ];
+
+  mesonFlags = [
+    "-Ddocs=true"
+    "-Dman=false" # we don't have xmltoman
+    "-Dexamples=true" # only needed for `pipewire-media-session`
+    "-Dudevrulesdir=lib/udev/rules.d"
+    "-Dinstalled_tests=true"
+    "-Dinstalled_test_prefix=${placeholder "installedTests"}"
+    "-Dpipewire_pulse_prefix=${placeholder "pulse"}"
+    "-Dlibjack-path=${placeholder "jack"}/lib"
+    "-Dgstreamer=${mesonBool gstreamerSupport}"
+    "-Dffmpeg=${mesonBool ffmpegSupport}"
+    "-Dbluez5=${mesonBool bluezSupport}"
+    "-Dbluez5-backend-native=${mesonBool nativeHspSupport}"
+    "-Dbluez5-backend-ofono=${mesonBool ofonoSupport}"
+    "-Dbluez5-backend-hsphfpd=${mesonBool hsphfpdSupport}"
+    "-Dpipewire_config_dir=/etc/pipewire"
+  ];
+
+  FONTCONFIG_FILE = fontsConf; # Fontconfig error: Cannot load default config file
+
+  doCheck = true;
+
+  postInstall = ''
+    moveToOutput "share/systemd/user/pipewire-pulse.*" "$pulse"
+    moveToOutput "lib/systemd/user/pipewire-pulse.*" "$pulse"
+    moveToOutput "bin/pipewire-pulse" "$pulse"
+  '';
+
+  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"
+        "share/alsa-card-profile/mixer"
+      ];
+    };
+  };
+
+  meta = with lib; {
+    description = "Server and user space API to deal with multimedia pipelines";
+    homepage = "https://pipewire.org/";
+    license = licenses.mit;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ jtojnar ];
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/pipewire/installed-tests-path.patch b/nixpkgs/pkgs/development/libraries/pipewire/installed-tests-path.patch
new file mode 100644
index 000000000000..2a92711626bf
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/pipewire/installed-tests-path.patch
@@ -0,0 +1,29 @@
+diff --git a/meson.build b/meson.build
+index ffee41b4..bab6f019 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(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',
diff --git a/nixpkgs/pkgs/development/libraries/pipewire/pipewire-config-dir.patch b/nixpkgs/pkgs/development/libraries/pipewire/pipewire-config-dir.patch
new file mode 100644
index 000000000000..ad1ae93684b1
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/pipewire/pipewire-config-dir.patch
@@ -0,0 +1,30 @@
+diff --git a/meson.build b/meson.build
+index 0073eb13..0ffc6863 100644
+--- a/meson.build
++++ b/meson.build
+@@ -34,7 +34,10 @@ pipewire_libexecdir = join_paths(prefix, get_option('libexecdir'))
+ pipewire_localedir = join_paths(prefix, get_option('localedir'))
+ pipewire_sysconfdir = join_paths(prefix, get_option('sysconfdir'))
+ 
+-pipewire_configdir = join_paths(pipewire_sysconfdir, 'pipewire')
++pipewire_configdir = get_option('pipewire_config_dir')
++if pipewire_configdir == ''
++  pipewire_configdir = join_paths(pipewire_sysconfdir, 'pipewire')
++endif
+ modules_install_dir = join_paths(pipewire_libdir, pipewire_name)
+ 
+ if host_machine.system() == 'linux'
+diff --git a/meson_options.txt b/meson_options.txt
+index 4b9e46b8..8c301459 100644
+--- a/meson_options.txt
++++ b/meson_options.txt
+@@ -56,6 +56,9 @@ option('pipewire-pulseaudio',
+ option('libpulse-path',
+        description: 'Where to install the libpulse.so library',
+        type: 'string')
++option('pipewire_config_dir',
++       type : 'string',
++       description : 'Directory for pipewire configuration (defaults to /etc/pipewire)')
+ option('spa-plugins',
+        description: 'Enable spa plugins integration',
+        type: 'boolean',
diff --git a/nixpkgs/pkgs/development/libraries/pipewire/pipewire-pulse-path.patch b/nixpkgs/pkgs/development/libraries/pipewire/pipewire-pulse-path.patch
new file mode 100644
index 000000000000..6ac86b111eef
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/pipewire/pipewire-pulse-path.patch
@@ -0,0 +1,24 @@
+diff --git a/meson_options.txt b/meson_options.txt
+index 4b9e46b8..9d73ed06 100644
+--- a/meson_options.txt
++++ b/meson_options.txt
+@@ -147,3 +147,6 @@ option('pw-cat',
+ option('udevrulesdir',
+        type : 'string',
+        description : 'Directory for udev rules (defaults to /lib/udev/rules.d)')
++option('pipewire_pulse_prefix',
++       type : 'string',
++       description : 'Install directory for the pipewire-pulse daemon')
+diff --git a/src/daemon/systemd/user/meson.build b/src/daemon/systemd/user/meson.build
+index 29fc93d4..f78946f2 100644
+--- a/src/daemon/systemd/user/meson.build
++++ b/src/daemon/systemd/user/meson.build
+@@ -6,7 +6,7 @@ install_data(
+ 
+ systemd_config = configuration_data()
+ systemd_config.set('PW_BINARY', join_paths(pipewire_bindir, 'pipewire'))
+-systemd_config.set('PW_PULSE_BINARY', join_paths(pipewire_bindir, 'pipewire-pulse'))
++systemd_config.set('PW_PULSE_BINARY', join_paths(get_option('pipewire_pulse_prefix'), 'bin/pipewire-pulse'))
+ 
+ configure_file(input : 'pipewire.service.in',
+                output : 'pipewire.service',
diff --git a/nixpkgs/pkgs/development/libraries/pipewire/test-paths.nix b/nixpkgs/pkgs/development/libraries/pipewire/test-paths.nix
new file mode 100644
index 000000000000..0ae693741946
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/pipewire/test-paths.nix
@@ -0,0 +1,23 @@
+{ lib, runCommand, pipewire, paths-out, paths-lib }:
+
+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
+  '';
+
+  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
+''