1{
2 stdenv,
3 lib,
4 testers,
5 buildPackages,
6 fetchFromGitLab,
7 python3,
8 meson,
9 ninja,
10 freebsd,
11 elogind,
12 libinotify-kqueue,
13 epoll-shim,
14 systemd,
15 enableSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd, # enableSystemd=false maintained by maintainers.qyliss.
16 pkg-config,
17 docutils,
18 doxygen,
19 graphviz,
20 glib,
21 dbus,
22 alsa-lib,
23 libjack2,
24 libusb1,
25 udev,
26 libsndfile,
27 vulkanSupport ? true,
28 vulkan-headers,
29 vulkan-loader,
30 webrtc-audio-processing,
31 ncurses,
32 readline, # meson can't find <7 as those versions don't have a .pc file
33 lilv,
34 makeFontsConf,
35 nixosTests,
36 valgrind,
37 libcamera,
38 libdrm,
39 gst_all_1,
40 ffmpeg,
41 fftwFloat,
42 bluezSupport ? stdenv.hostPlatform.isLinux,
43 bluez,
44 sbc,
45 libfreeaptx,
46 liblc3,
47 fdk_aac,
48 libopus,
49 ldacbt,
50 modemmanager,
51 libpulseaudio,
52 zeroconfSupport ? true,
53 avahi,
54 raopSupport ? true,
55 openssl,
56 rocSupport ? true,
57 roc-toolkit,
58 x11Support ? true,
59 libcanberra,
60 xorg,
61 libmysofa,
62 ffadoSupport ?
63 x11Support
64 && lib.systems.equals stdenv.buildPlatform stdenv.hostPlatform
65 && lib.meta.availableOn stdenv.hostPlatform ffado,
66 ffado,
67 libselinux,
68 libebur128,
69}:
70
71let
72 modemmanagerSupport = lib.meta.availableOn stdenv.hostPlatform modemmanager;
73 libcameraSupport = lib.meta.availableOn stdenv.hostPlatform libcamera;
74 ldacbtSupport = lib.meta.availableOn stdenv.hostPlatform ldacbt;
75 webrtcAudioProcessingSupport = lib.meta.availableOn stdenv.hostPlatform webrtc-audio-processing;
76in
77
78stdenv.mkDerivation (finalAttrs: {
79 pname = "pipewire";
80 version = "1.4.6";
81
82 outputs = [
83 "out"
84 "jack"
85 "dev"
86 "doc"
87 "man"
88 "installedTests"
89 ];
90
91 src = fetchFromGitLab {
92 domain = "gitlab.freedesktop.org";
93 owner = "pipewire";
94 repo = "pipewire";
95 rev = finalAttrs.version;
96 sha256 = "sha256-Hk43rKrKCJA6njQ9ap/Pje9AQKygrDc+GTlimaMh/pg=";
97 };
98
99 patches = [
100 # Load libjack from a known location
101 ./0060-libjack-path.patch
102 # Move installed tests into their own output.
103 ./0070-installed-tests-path.patch
104 ];
105
106 strictDeps = true;
107 depsBuildBuild = [ buildPackages.stdenv.cc ];
108 nativeBuildInputs = [
109 docutils
110 doxygen
111 graphviz
112 meson
113 ninja
114 pkg-config
115 python3
116 glib
117 ];
118
119 buildInputs = [
120 dbus
121 ffmpeg
122 fftwFloat
123 glib
124 gst_all_1.gst-plugins-base
125 gst_all_1.gstreamer
126 libebur128
127 libjack2
128 libmysofa
129 libopus
130 libpulseaudio
131 libusb1
132 libsndfile
133 lilv
134 ncurses
135 readline
136 ]
137 ++ (
138 if enableSystemd then
139 [ systemd ]
140 else if stdenv.hostPlatform.isLinux then
141 [
142 elogind
143 udev
144 ]
145 else
146 [ ]
147 )
148 ++ lib.optionals stdenv.hostPlatform.isFreeBSD [
149 libinotify-kqueue
150 epoll-shim
151 freebsd.libstdthreads
152 ]
153 ++ lib.optional webrtcAudioProcessingSupport webrtc-audio-processing
154 ++ lib.optional stdenv.hostPlatform.isLinux alsa-lib
155 ++ lib.optional ldacbtSupport ldacbt
156 ++ lib.optional libcameraSupport libcamera
157 ++ lib.optional zeroconfSupport avahi
158 ++ lib.optional raopSupport openssl
159 ++ lib.optional rocSupport roc-toolkit
160 ++ lib.optionals vulkanSupport [
161 libdrm
162 vulkan-headers
163 vulkan-loader
164 ]
165 ++ lib.optionals x11Support [
166 libcanberra
167 xorg.libX11
168 xorg.libXfixes
169 ]
170 ++ lib.optionals bluezSupport [
171 bluez
172 libfreeaptx
173 liblc3
174 sbc
175 fdk_aac
176 ]
177 ++ lib.optional ffadoSupport ffado
178 ++ lib.optional stdenv.hostPlatform.isLinux libselinux
179 ++ lib.optional modemmanagerSupport modemmanager;
180
181 # Valgrind binary is required for running one optional test.
182 nativeCheckInputs = lib.optional (lib.meta.availableOn stdenv.hostPlatform valgrind) valgrind;
183
184 mesonFlags = [
185 (lib.mesonEnable "pipewire-alsa" stdenv.hostPlatform.isLinux)
186 (lib.mesonEnable "alsa" stdenv.hostPlatform.isLinux)
187 (lib.mesonEnable "docs" true)
188 (lib.mesonOption "udevrulesdir" "lib/udev/rules.d")
189 (lib.mesonEnable "installed_tests" true)
190 (lib.mesonOption "installed_test_prefix" (placeholder "installedTests"))
191 (lib.mesonOption "libjack-path" "${placeholder "jack"}/lib")
192 (lib.mesonEnable "echo-cancel-webrtc" webrtcAudioProcessingSupport)
193 (lib.mesonEnable "libcamera" (lib.meta.availableOn stdenv.hostPlatform libcamera))
194 (lib.mesonEnable "libffado" ffadoSupport)
195 (lib.mesonEnable "roc" rocSupport)
196 (lib.mesonEnable "libpulse" true)
197 (lib.mesonEnable "avahi" zeroconfSupport)
198 (lib.mesonEnable "gstreamer" true)
199 (lib.mesonEnable "gstreamer-device-provider" true)
200 (lib.mesonOption "logind-provider" (if enableSystemd then "libsystemd" else "libelogind"))
201 (lib.mesonEnable "logind" stdenv.hostPlatform.isLinux)
202 (lib.mesonEnable "selinux" stdenv.hostPlatform.isLinux)
203 (lib.mesonEnable "avb" stdenv.hostPlatform.isLinux)
204 (lib.mesonEnable "v4l2" stdenv.hostPlatform.isLinux)
205 (lib.mesonEnable "pipewire-v4l2" stdenv.hostPlatform.isLinux)
206 (lib.mesonEnable "systemd" enableSystemd)
207 (lib.mesonEnable "systemd-system-service" enableSystemd)
208 (lib.mesonEnable "udev" (!enableSystemd && stdenv.hostPlatform.isLinux))
209 (lib.mesonEnable "ffmpeg" true)
210 (lib.mesonEnable "pw-cat-ffmpeg" true)
211 (lib.mesonEnable "bluez5" bluezSupport)
212 (lib.mesonEnable "bluez5-backend-hsp-native" bluezSupport)
213 (lib.mesonEnable "bluez5-backend-hfp-native" bluezSupport)
214 (lib.mesonEnable "bluez5-backend-native-mm" bluezSupport)
215 (lib.mesonEnable "bluez5-backend-ofono" bluezSupport)
216 (lib.mesonEnable "bluez5-backend-hsphfpd" bluezSupport)
217 # source code is not easily obtainable
218 (lib.mesonEnable "bluez5-codec-lc3plus" false)
219 (lib.mesonEnable "bluez5-codec-lc3" bluezSupport)
220 (lib.mesonEnable "bluez5-codec-ldac" (bluezSupport && ldacbtSupport))
221 (lib.mesonEnable "opus" true)
222 (lib.mesonOption "sysconfdir" "/etc")
223 (lib.mesonEnable "raop" raopSupport)
224 (lib.mesonOption "session-managers" "")
225 (lib.mesonEnable "vulkan" vulkanSupport)
226 (lib.mesonEnable "x11" x11Support)
227 (lib.mesonEnable "x11-xfixes" x11Support)
228 (lib.mesonEnable "libcanberra" x11Support)
229 (lib.mesonEnable "libmysofa" true)
230 (lib.mesonEnable "sdl2" false) # required only to build examples, causes dependency loop
231 (lib.mesonBool "rlimits-install" false) # installs to /etc, we won't use this anyway
232 (lib.mesonEnable "compress-offload" true)
233 (lib.mesonEnable "man" true)
234 (lib.mesonEnable "snap" false) # we don't currently have a working snapd
235 ];
236
237 # Fontconfig error: Cannot load default config file
238 FONTCONFIG_FILE = makeFontsConf { fontDirectories = [ ]; };
239
240 doCheck = true;
241 doInstallCheck = true;
242
243 postUnpack = ''
244 patchShebangs ${finalAttrs.src.name}/doc/*.py
245 patchShebangs ${finalAttrs.src.name}/doc/input-filter-h.sh
246 '';
247
248 postInstall = ''
249 moveToOutput "bin/pw-jack" "$jack"
250 '';
251
252 passthru.tests = {
253 installed-tests = nixosTests.installed-tests.pipewire;
254 pkg-config = testers.hasPkgConfigModules {
255 package = finalAttrs.finalPackage;
256 };
257 };
258
259 meta = with lib; {
260 description = "Server and user space API to deal with multimedia pipelines";
261 changelog = "https://gitlab.freedesktop.org/pipewire/pipewire/-/releases/${finalAttrs.version}";
262 homepage = "https://pipewire.org/";
263 license = licenses.mit;
264 platforms = platforms.linux ++ platforms.freebsd;
265 maintainers = with maintainers; [
266 kranzes
267 k900
268 ];
269 pkgConfigModules = [
270 "libpipewire-0.3"
271 "libspa-0.2"
272 ];
273 };
274})