12 , enableSystemd ? true
27 , webrtc-audio-processing
29 , readline81 # meson can't find <7 as those versions don't have a .pc file
34 , withValgrind ? lib.meta.availableOn stdenv.hostPlatform valgrind
36 , withMediaSession ? true
37 , libcameraSupport ? true
40 , gstreamerSupport ? true
42 , ffmpegSupport ? true
52 , nativeHspSupport ? true
53 , nativeHfpSupport ? true
55 , hsphfpdSupport ? true
56 , pulseTunnelSupport ? true
58 , zeroconfSupport ? true
70 mesonEnableFeature = b: if b then "enabled" else "disabled";
71 mesonList = l: "[" + lib.concatStringsSep "," l + "]";
73 self = stdenv.mkDerivation rec {
88 src = fetchFromGitLab {
89 domain = "gitlab.freedesktop.org";
93 sha256 = "sha256-4wDtdgkjBRlthhwbI3cSQFnbr+gxPQP5j5YnrWiQVp4=";
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=";
117 nativeBuildInputs = [
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;
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}"
180 "-Dpipewire_confdata_dir=${placeholder "lib"}/share/pipewire"
181 "-Draop=${mesonEnableFeature raopSupport}"
182 "-Dsession-managers="
184 "-Dx11=${mesonEnableFeature x11Support}"
185 "-Dsdl2=disabled" # required only to build examples, causes dependency loop
188 # Fontconfig error: Cannot load default config file
189 FONTCONFIG_FILE = makeFontsConf { fontDirectories = [ ]; };
194 patchShebangs source/doc/input-filter.sh
195 patchShebangs source/doc/input-filter-h.sh
199 mkdir $out/nix-support
200 ${if (stdenv.hostPlatform == stdenv.buildPlatform) then ''
201 pushd $lib/share/pipewire
203 echo "Generating JSON from $f"
205 $out/bin/spa-json-dump "$f" > "$out/nix-support/$f.json"
209 cp ${buildPackages.pipewire}/nix-support/*.json "$out/nix-support"
212 ${lib.optionalString enableSystemd ''
213 moveToOutput "share/systemd/user/pipewire-pulse.*" "$pulse"
214 moveToOutput "lib/systemd/user/pipewire-pulse.*" "$pulse"
217 moveToOutput "bin/pipewire-pulse" "$pulse"
219 moveToOutput "bin/pw-jack" "$jack"
223 updateScript = ./update-pipewire.sh;
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; } {
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"
239 "lib/alsa-lib/libasound_module_pcm_pipewire.so"
240 "share/alsa-card-profile/mixer"
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 ];