python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / pkgs / development / libraries / pipewire / default.nix
blobf2907afab018863b3bf438ac1ab8a333aad99f2a
1 { stdenv
2 , lib
3 , buildPackages
4 , fetchFromGitLab
5 , fetchpatch
6 , removeReferencesTo
7 , python3
8 , meson
9 , ninja
10 , eudev
11 , systemd
12 , enableSystemd ? true
13 , pkg-config
14 , docutils
15 , doxygen
16 , graphviz
17 , glib
18 , dbus
19 , alsa-lib
20 , libjack2
21 , libusb1
22 , udev
23 , libva
24 , libsndfile
25 , vulkan-headers
26 , vulkan-loader
27 , webrtc-audio-processing
28 , ncurses
29 , readline81 # meson can't find <7 as those versions don't have a .pc file
30 , lilv
31 , makeFontsConf
32 , callPackage
33 , nixosTests
34 , withValgrind ? lib.meta.availableOn stdenv.hostPlatform valgrind
35 , valgrind
36 , withMediaSession ? true
37 , libcameraSupport ? true
38 , libcamera
39 , libdrm
40 , gstreamerSupport ? true
41 , gst_all_1
42 , ffmpegSupport ? true
43 , ffmpeg
44 , bluezSupport ? true
45 , bluez
46 , sbc
47 , libfreeaptx
48 , ldacbt
49 , liblc3
50 , fdk_aac
51 , libopus
52 , nativeHspSupport ? true
53 , nativeHfpSupport ? true
54 , ofonoSupport ? true
55 , hsphfpdSupport ? true
56 , pulseTunnelSupport ? true
57 , libpulseaudio
58 , zeroconfSupport ? true
59 , avahi
60 , raopSupport ? true
61 , openssl
62 , rocSupport ? true
63 , roc-toolkit
64 , x11Support ? true
65 , libcanberra
66 , xorg
69 let
70   mesonEnableFeature = b: if b then "enabled" else "disabled";
71   mesonList = l: "[" + lib.concatStringsSep "," l + "]";
73   self = stdenv.mkDerivation rec {
74     pname = "pipewire";
75     version = "0.3.59";
77     outputs = [
78       "out"
79       "lib"
80       "pulse"
81       "jack"
82       "dev"
83       "doc"
84       "man"
85       "installedTests"
86     ];
88     src = fetchFromGitLab {
89       domain = "gitlab.freedesktop.org";
90       owner = "pipewire";
91       repo = "pipewire";
92       rev = version;
93       sha256 = "sha256-4wDtdgkjBRlthhwbI3cSQFnbr+gxPQP5j5YnrWiQVp4=";
94     };
96     patches = [
97       # Break up a dependency cycle between outputs.
98       ./0040-alsa-profiles-use-libdir.patch
99       # Change the path of the pipewire-pulse binary in the service definition.
100       ./0050-pipewire-pulse-path.patch
101       # Move installed tests into their own output.
102       ./0070-installed-tests-path.patch
103       # Add option for changing the config install directory
104       ./0080-pipewire-config-dir.patch
105       # Remove output paths from the comments in the config templates to break dependency cycles
106       ./0090-pipewire-config-template-paths.patch
107       # Place SPA data files in lib output to avoid dependency cycles
108       ./0095-spa-data-dir.patch
110       # remove when updating to 0.3.60
111       (fetchpatch { # filter-chain: iterate the port correctly
112         url = "https://gitlab.freedesktop.org/pipewire/pipewire/-/commit/94a64268613adac8ef6f3e6c1f04468220540d00.patch";
113         sha256 = "sha256-IDTB7NgadgR3vKv97Nvd9pBfnOnMi21YsvLdD1Ew7HE=";
114       })
115     ];
117     nativeBuildInputs = [
118       docutils
119       doxygen
120       graphviz
121       meson
122       ninja
123       pkg-config
124       python3
125     ];
127     buildInputs = [
128       alsa-lib
129       dbus
130       glib
131       libjack2
132       libusb1
133       libsndfile
134       lilv
135       ncurses
136       readline81
137       udev
138       vulkan-headers
139       vulkan-loader
140       webrtc-audio-processing
141     ] ++ (if enableSystemd then [ systemd ] else [ eudev ])
142     ++ lib.optionals gstreamerSupport [ gst_all_1.gst-plugins-base gst_all_1.gstreamer ]
143     ++ lib.optionals libcameraSupport [ libcamera libdrm ]
144     ++ lib.optional ffmpegSupport ffmpeg
145     ++ lib.optionals bluezSupport [ bluez libfreeaptx ldacbt liblc3 sbc fdk_aac libopus ]
146     ++ lib.optional pulseTunnelSupport libpulseaudio
147     ++ lib.optional zeroconfSupport avahi
148     ++ lib.optional raopSupport openssl
149     ++ lib.optional rocSupport roc-toolkit
150     ++ lib.optionals x11Support [ libcanberra xorg.libX11 xorg.libXfixes ];
152     # Valgrind binary is required for running one optional test.
153     checkInputs = lib.optional withValgrind valgrind;
155     mesonFlags = [
156       "-Ddocs=enabled"
157       "-Dudevrulesdir=lib/udev/rules.d"
158       "-Dinstalled_tests=enabled"
159       "-Dinstalled_test_prefix=${placeholder "installedTests"}"
160       "-Dpipewire_pulse_prefix=${placeholder "pulse"}"
161       "-Dlibjack-path=${placeholder "jack"}/lib"
162       "-Dlibv4l2-path=${placeholder "out"}/lib"
163       "-Dlibcamera=${mesonEnableFeature libcameraSupport}"
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       "-Dudevrulesdir=${placeholder "out"}/lib/udev/rules.d"
171       "-Dffmpeg=${mesonEnableFeature ffmpegSupport}"
172       "-Dbluez5=${mesonEnableFeature bluezSupport}"
173       "-Dbluez5-backend-hsp-native=${mesonEnableFeature nativeHspSupport}"
174       "-Dbluez5-backend-hfp-native=${mesonEnableFeature nativeHfpSupport}"
175       "-Dbluez5-backend-ofono=${mesonEnableFeature ofonoSupport}"
176       "-Dbluez5-backend-hsphfpd=${mesonEnableFeature hsphfpdSupport}"
177       "-Dbluez5-codec-lc3plus=disabled"
178       "-Dbluez5-codec-lc3=${mesonEnableFeature bluezSupport}"
179       "-Dsysconfdir=/etc"
180       "-Dpipewire_confdata_dir=${placeholder "lib"}/share/pipewire"
181       "-Draop=${mesonEnableFeature raopSupport}"
182       "-Dsession-managers="
183       "-Dvulkan=enabled"
184       "-Dx11=${mesonEnableFeature x11Support}"
185       "-Dsdl2=disabled" # required only to build examples, causes dependency loop
186     ];
188     # Fontconfig error: Cannot load default config file
189     FONTCONFIG_FILE = makeFontsConf { fontDirectories = [ ]; };
191     doCheck = true;
193     postUnpack = ''
194       patchShebangs source/doc/input-filter.sh
195       patchShebangs source/doc/input-filter-h.sh
196     '';
198     postInstall = ''
199       mkdir $out/nix-support
200       ${if (stdenv.hostPlatform == stdenv.buildPlatform) then ''
201         pushd $lib/share/pipewire
202         for f in *.conf; do
203           echo "Generating JSON from $f"
205           $out/bin/spa-json-dump "$f" > "$out/nix-support/$f.json"
206         done
207         popd
208       '' else ''
209         cp ${buildPackages.pipewire}/nix-support/*.json "$out/nix-support"
210       ''}
212       ${lib.optionalString enableSystemd ''
213         moveToOutput "share/systemd/user/pipewire-pulse.*" "$pulse"
214         moveToOutput "lib/systemd/user/pipewire-pulse.*" "$pulse"
215       ''}
217       moveToOutput "bin/pipewire-pulse" "$pulse"
219       moveToOutput "bin/pw-jack" "$jack"
220     '';
222     passthru = {
223       updateScript = ./update-pipewire.sh;
224       tests = {
225         installedTests = nixosTests.installed-tests.pipewire;
227         # This ensures that all the paths used by the NixOS module are found.
228         test-paths = callPackage ./test-paths.nix { package = self; } {
229           paths-out = [
230             "share/alsa/alsa.conf.d/50-pipewire.conf"
231             "nix-support/client-rt.conf.json"
232             "nix-support/client.conf.json"
233             "nix-support/jack.conf.json"
234             "nix-support/minimal.conf.json"
235             "nix-support/pipewire.conf.json"
236             "nix-support/pipewire-pulse.conf.json"
237           ];
238           paths-lib = [
239             "lib/alsa-lib/libasound_module_pcm_pipewire.so"
240             "share/alsa-card-profile/mixer"
241           ];
242         };
243       };
244     };
246     meta = with lib; {
247       description = "Server and user space API to deal with multimedia pipelines";
248       homepage = "https://pipewire.org/";
249       license = licenses.mit;
250       platforms = platforms.linux;
251       maintainers = with maintainers; [ jtojnar kranzes ];
252     };
253   };
256 self