Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / development / libraries / pipewire / default.nix
blob3876a5c892a0ed2d4df6c99f5415f2976c5342d6
1 { stdenv
2 , lib
3 , buildPackages
4 , fetchFromGitLab
5 , fetchpatch
6 , python3
7 , meson
8 , ninja
9 , eudev
10 , systemd
11 , enableSystemd ? true
12 , pkg-config
13 , docutils
14 , doxygen
15 , graphviz
16 , glib
17 , dbus
18 , alsa-lib
19 , libjack2
20 , libusb1
21 , udev
22 , libsndfile
23 , vulkan-headers
24 , vulkan-loader
25 , webrtc-audio-processing
26 , webrtc-audio-processing_1
27 , ncurses
28 , readline # meson can't find <7 as those versions don't have a .pc file
29 , lilv
30 , makeFontsConf
31 , callPackage
32 , nixosTests
33 , withValgrind ? lib.meta.availableOn stdenv.hostPlatform valgrind
34 , valgrind
35 , libcameraSupport ? true
36 , libcamera
37 , libdrm
38 , gstreamerSupport ? true
39 , gst_all_1
40 , ffmpegSupport ? true
41 , ffmpeg
42 , bluezSupport ? true
43 , bluez
44 , sbc
45 , libfreeaptx
46 , liblc3
47 , fdk_aac
48 , libopus
49 , ldacbtSupport ? bluezSupport && lib.meta.availableOn stdenv.hostPlatform ldacbt
50 , ldacbt
51 , nativeHspSupport ? true
52 , nativeHfpSupport ? true
53 , nativeModemManagerSupport ? true
54 , modemmanager
55 , ofonoSupport ? true
56 , hsphfpdSupport ? true
57 , pulseTunnelSupport ? true
58 , libpulseaudio
59 , zeroconfSupport ? true
60 , avahi
61 , raopSupport ? true
62 , openssl
63 , rocSupport ? true
64 , roc-toolkit
65 , x11Support ? true
66 , libcanberra
67 , xorg
68 , mysofaSupport ? true
69 , libmysofa
70 , tinycompress
71 , ffadoSupport ? stdenv.buildPlatform.canExecute stdenv.hostPlatform
72 , ffado
73 , libselinux
76 # Bluetooth codec only makes sense if general bluetooth enabled
77 assert ldacbtSupport -> bluezSupport;
79 let
80   mesonEnableFeature = b: if b then "enabled" else "disabled";
82   self = stdenv.mkDerivation rec {
83     pname = "pipewire";
84     version = "0.3.84";
86     outputs = [
87       "out"
88       "jack"
89       "dev"
90       "doc"
91       "man"
92       "installedTests"
93     ];
95     src = fetchFromGitLab {
96       domain = "gitlab.freedesktop.org";
97       owner = "pipewire";
98       repo = "pipewire";
99       rev = version;
100       sha256 = "sha256-9W9y+wtS/CYUaPRrCRmRDeyvuS1XllMBNQLy6GAMqBM=";
101     };
103     patches = [
104       # Load libjack from a known location
105       ./0060-libjack-path.patch
106       # Move installed tests into their own output.
107       ./0070-installed-tests-path.patch
108     ];
110     strictDeps = true;
111     nativeBuildInputs = [
112       docutils
113       doxygen
114       graphviz
115       meson
116       ninja
117       pkg-config
118       python3
119       glib
120     ];
122     buildInputs = [
123       alsa-lib
124       dbus
125       glib
126       libjack2
127       libusb1
128       libselinux
129       libsndfile
130       lilv
131       ncurses
132       readline
133       udev
134       vulkan-headers
135       vulkan-loader
136       tinycompress
137     ] ++ (if enableSystemd then [ systemd ] else [ eudev ])
138     ++ (if lib.meta.availableOn stdenv.hostPlatform webrtc-audio-processing_1 then [ webrtc-audio-processing_1 ] else [ webrtc-audio-processing ])
139     ++ lib.optionals gstreamerSupport [ gst_all_1.gst-plugins-base gst_all_1.gstreamer ]
140     ++ lib.optionals libcameraSupport [ libcamera libdrm ]
141     ++ lib.optional ffmpegSupport ffmpeg
142     ++ lib.optionals bluezSupport [ bluez libfreeaptx liblc3 sbc fdk_aac libopus ]
143     ++ lib.optional ldacbtSupport ldacbt
144     ++ lib.optional nativeModemManagerSupport modemmanager
145     ++ lib.optional pulseTunnelSupport libpulseaudio
146     ++ lib.optional zeroconfSupport avahi
147     ++ lib.optional raopSupport openssl
148     ++ lib.optional rocSupport roc-toolkit
149     ++ lib.optionals x11Support [ libcanberra xorg.libX11 xorg.libXfixes ]
150     ++ lib.optional mysofaSupport libmysofa
151     ++ lib.optional ffadoSupport ffado;
153     # Valgrind binary is required for running one optional test.
154     nativeCheckInputs = lib.optional withValgrind valgrind;
156     mesonFlags = [
157       "-Ddocs=enabled"
158       "-Dudevrulesdir=lib/udev/rules.d"
159       "-Dinstalled_tests=enabled"
160       "-Dinstalled_test_prefix=${placeholder "installedTests"}"
161       "-Dlibjack-path=${placeholder "jack"}/lib"
162       "-Dlibcamera=${mesonEnableFeature libcameraSupport}"
163       "-Dlibffado=${mesonEnableFeature ffadoSupport}"
164       "-Droc=${mesonEnableFeature rocSupport}"
165       "-Dlibpulse=${mesonEnableFeature pulseTunnelSupport}"
166       "-Davahi=${mesonEnableFeature zeroconfSupport}"
167       "-Dgstreamer=${mesonEnableFeature gstreamerSupport}"
168       "-Dsystemd-system-service=${mesonEnableFeature enableSystemd}"
169       "-Dudev=${mesonEnableFeature (!enableSystemd)}"
170       "-Dffmpeg=${mesonEnableFeature ffmpegSupport}"
171       "-Dbluez5=${mesonEnableFeature bluezSupport}"
172       "-Dbluez5-backend-hsp-native=${mesonEnableFeature nativeHspSupport}"
173       "-Dbluez5-backend-hfp-native=${mesonEnableFeature nativeHfpSupport}"
174       "-Dbluez5-backend-native-mm=${mesonEnableFeature nativeModemManagerSupport}"
175       "-Dbluez5-backend-ofono=${mesonEnableFeature ofonoSupport}"
176       "-Dbluez5-backend-hsphfpd=${mesonEnableFeature hsphfpdSupport}"
177       # source code is not easily obtainable
178       "-Dbluez5-codec-lc3plus=disabled"
179       "-Dbluez5-codec-lc3=${mesonEnableFeature bluezSupport}"
180       "-Dbluez5-codec-ldac=${mesonEnableFeature ldacbtSupport}"
181       "-Dsysconfdir=/etc"
182       "-Draop=${mesonEnableFeature raopSupport}"
183       "-Dsession-managers="
184       "-Dvulkan=enabled"
185       "-Dx11=${mesonEnableFeature x11Support}"
186       "-Dx11-xfixes=${mesonEnableFeature x11Support}"
187       "-Dlibcanberra=${mesonEnableFeature x11Support}"
188       "-Dlibmysofa=${mesonEnableFeature mysofaSupport}"
189       "-Dsdl2=disabled" # required only to build examples, causes dependency loop
190       "-Drlimits-install=false" # installs to /etc, we won't use this anyway
191       "-Dcompress-offload=enabled"
192     ];
194     # Fontconfig error: Cannot load default config file
195     FONTCONFIG_FILE = makeFontsConf { fontDirectories = [ ]; };
197     doCheck = true;
199     postUnpack = ''
200       patchShebangs source/doc/input-filter.sh
201       patchShebangs source/doc/input-filter-h.sh
202     '';
204     postInstall = ''
205       moveToOutput "bin/pw-jack" "$jack"
206     '';
208     passthru.tests.installed-tests = nixosTests.installed-tests.pipewire;
210     meta = with lib; {
211       description = "Server and user space API to deal with multimedia pipelines";
212       changelog = "https://gitlab.freedesktop.org/pipewire/pipewire/-/releases/${version}";
213       homepage = "https://pipewire.org/";
214       license = licenses.mit;
215       platforms = platforms.linux;
216       maintainers = with maintainers; [ kranzes k900 ];
217     };
218   };
221 self