1 { lib, stdenv, fetchurl, pkg-config
2 , libsndfile, libtool, makeWrapper, perlPackages
3 , xorg, libcap, alsa-lib, glib, dconf
4 , avahi, libjack2, libasyncns, lirc, dbus
5 , sbc, bluez5, udev, openssl, fftwFloat
6 , soxr, speexdsp, systemd, webrtc-audio-processing_1
8 , check, libintl, meson, ninja, m4, wrapGAppsHook3
14 , useSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd
16 , # Whether to support the JACK sound system as a backend.
17 jackaudioSupport ? false
19 , # Whether to build the OSS wrapper ("padsp").
22 , airtunesSupport ? false
24 , bluetoothSupport ? stdenv.hostPlatform.isLinux
25 , advancedBluetoothCodecs ? false
27 , remoteControlSupport ? false
29 , zeroconfSupport ? false
31 , alsaSupport ? stdenv.hostPlatform.isLinux
32 , udevSupport ? stdenv.hostPlatform.isLinux
34 , # Whether to build only the library.
37 , AudioUnit, Cocoa, CoreServices, CoreAudio
40 stdenv.mkDerivation rec {
41 pname = "${lib.optionalString libOnly "lib"}pulseaudio";
45 url = "http://freedesktop.org/software/pulseaudio/releases/pulseaudio-${version}.tar.xz";
46 hash = "sha256-BTeU1mcaPjl9hJ5HioC4KmPLnYyilr01tzMXu1zrh7U=";
50 # Install sysconfdir files inside of the nix store,
51 # but use a conventional runtime sysconfdir outside the store
52 ./add-option-for-installation-sysconfdir.patch
54 # Fix crashes with some UCM devices
55 # See https://gitlab.archlinux.org/archlinux/packaging/packages/pulseaudio/-/issues/4
57 name = "alsa-ucm-Check-UCM-verb-before-working-with-device-status.patch";
58 url = "https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/f5cacd94abcc47003bd88ad7ca1450de649ffb15.patch";
59 hash = "sha256-WyEqCitrqic2n5nNHeVS10vvGy5IzwObPPXftZKy/A8=";
62 name = "alsa-ucm-Replace-port-device-UCM-context-assertion-with-an-error.patch";
63 url = "https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/ed3d4f0837f670e5e5afb1afa5bcfc8ff05d3407.patch";
64 hash = "sha256-fMJ3EYq56sHx+zTrG6osvI/QgnhqLvWiifZxrRLMvns=";
68 outputs = [ "out" "dev" ];
70 nativeBuildInputs = [ pkg-config meson ninja makeWrapper perlPackages.perl perlPackages.XMLParser m4 ]
71 ++ lib.optionals stdenv.hostPlatform.isLinux [ glib ]
72 # gstreamer plugin discovery requires wrapping
73 ++ lib.optional (bluetoothSupport && advancedBluetoothCodecs) wrapGAppsHook3;
75 propagatedBuildInputs =
76 lib.optionals stdenv.hostPlatform.isLinux [ libcap ];
79 [ libtool libsndfile soxr speexdsp fftwFloat check ]
80 ++ lib.optionals stdenv.hostPlatform.isLinux [ glib dbus ]
81 ++ lib.optionals stdenv.hostPlatform.isDarwin [ AudioUnit Cocoa CoreServices CoreAudio libintl ]
82 ++ lib.optionals (!libOnly) (
83 [ libasyncns webrtc-audio-processing_1 ]
84 ++ lib.optional jackaudioSupport libjack2
85 ++ lib.optionals x11Support [ xorg.libICE xorg.libSM xorg.libX11 xorg.libXi xorg.libXtst ]
86 ++ lib.optional useSystemd systemd
87 ++ lib.optionals stdenv.hostPlatform.isLinux [ alsa-lib udev ]
88 ++ lib.optional airtunesSupport openssl
89 ++ lib.optionals bluetoothSupport [ bluez5 sbc ]
90 # aptX and LDAC codecs are in gst-plugins-bad so far, rtpldacpay is in -good
91 ++ lib.optionals (bluetoothSupport && advancedBluetoothCodecs) (builtins.attrValues { inherit (gst_all_1) gst-plugins-bad gst-plugins-good gst-plugins-base gstreamer; })
92 ++ lib.optional remoteControlSupport lirc
93 ++ lib.optional zeroconfSupport avahi
97 (lib.mesonEnable "alsa" (!libOnly && alsaSupport))
98 (lib.mesonEnable "asyncns" (!libOnly))
99 (lib.mesonEnable "avahi" zeroconfSupport)
100 (lib.mesonEnable "bluez5" (!libOnly && bluetoothSupport))
101 # advanced bluetooth audio codecs are provided by gstreamer
102 (lib.mesonEnable "bluez5-gstreamer" (!libOnly && bluetoothSupport && advancedBluetoothCodecs))
103 (lib.mesonOption "database" "simple")
104 (lib.mesonBool "doxygen" false)
105 (lib.mesonEnable "elogind" false)
106 # gsettings does not support cross-compilation
107 (lib.mesonEnable "gsettings" (stdenv.hostPlatform.isLinux && (stdenv.buildPlatform == stdenv.hostPlatform)))
108 (lib.mesonEnable "gstreamer" false)
109 (lib.mesonEnable "gtk" false)
110 (lib.mesonEnable "jack" (jackaudioSupport && !libOnly))
111 (lib.mesonEnable "lirc" remoteControlSupport)
112 (lib.mesonEnable "openssl" airtunesSupport)
113 (lib.mesonEnable "orc" false)
114 (lib.mesonEnable "systemd" (useSystemd && !libOnly))
115 (lib.mesonEnable "tcpwrap" false)
116 (lib.mesonEnable "udev" (!libOnly && udevSupport))
117 (lib.mesonEnable "valgrind" false)
118 (lib.mesonEnable "webrtc-aec" (!libOnly))
119 (lib.mesonEnable "x11" x11Support)
121 (lib.mesonOption "localstatedir" "/var")
122 (lib.mesonOption "sysconfdir" "/etc")
123 (lib.mesonOption "sysconfdir_install" "${placeholder "out"}/etc")
124 (lib.mesonOption "udevrulesdir" "${placeholder "out"}/lib/udev/rules.d")
126 # pulseaudio complains if its binary is moved after installation;
127 # this is needed so that wrapGApp can operate *without*
128 # renaming the unwrapped binaries (see below)
129 "--bindir=${placeholder "out"}/.bin-unwrapped"
131 ++ lib.optionals (stdenv.hostPlatform.isLinux && useSystemd) [
132 (lib.mesonOption "systemduserunitdir" "${placeholder "out"}/lib/systemd/user")
134 ++ lib.optionals stdenv.hostPlatform.isDarwin [
135 (lib.mesonEnable "consolekit" false)
136 (lib.mesonEnable "dbus" false)
137 (lib.mesonEnable "glib" false)
138 (lib.mesonEnable "oss-output" false)
141 # tests fail on Darwin because of timeouts
142 doCheck = !stdenv.hostPlatform.isDarwin;
144 export HOME=$(mktemp -d)
147 postInstall = lib.optionalString libOnly ''
148 find $out/share -maxdepth 1 -mindepth 1 ! -name "vala" -prune -exec rm -r {} \;
149 find $out/share/vala -maxdepth 1 -mindepth 1 ! -name "vapi" -prune -exec rm -r {} \;
150 rm -r $out/{.bin-unwrapped,etc,lib/pulse-*}
153 moveToOutput lib/cmake "$dev"
154 rm -f $out/.bin-unwrapped/qpaeq # this is packaged by the "qpaeq" package now, because of missing deps
156 cp config.h $dev/include/pulse
159 preFixup = lib.optionalString (stdenv.hostPlatform.isLinux && (stdenv.hostPlatform == stdenv.buildPlatform)) ''
160 wrapProgram $out/libexec/pulse/gsettings-helper \
161 --prefix XDG_DATA_DIRS : "$out/share/gsettings-schemas/${pname}-${version}" \
162 --prefix GIO_EXTRA_MODULES : "${lib.getLib dconf}/lib/gio/modules"
164 # add .so symlinks for modules to be found under macOS
165 + lib.optionalString stdenv.hostPlatform.isDarwin ''
166 for file in $out/lib/pulseaudio/modules/*.dylib; do
167 ln -s "''$file" "''${file%.dylib}.so"
168 ln -s "''$file" "$out/lib/pulseaudio/''$(basename ''$file .dylib).so"
171 # put symlinks to binaries in `$prefix/bin`;
172 # then wrapGApp will *rename these symlinks* instead of
173 # the original binaries in `$prefix/.bin-unwrapped` (see above);
174 # when pulseaudio is looking for its own binary (it does!),
175 # it will be happy to find it in its original installation location
176 + lib.optionalString (!libOnly) ''
178 ln -st $out/bin $out/.bin-unwrapped/*
180 # Ensure that service files use the wrapped binaries.
181 find "$out" -name "*.service" | while read f; do
182 substituteInPlace "$f" --replace "$out/.bin-unwrapped/" "$out/bin/"
186 passthru.tests = { inherit (nixosTests) pulseaudio; };
189 description = "Sound server for POSIX and Win32 systems";
190 homepage = "http://www.pulseaudio.org/";
191 license = lib.licenses.lgpl2Plus;
192 maintainers = with lib.maintainers; [ lovek323 ];
193 platforms = lib.platforms.unix;
195 # https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues/1089
196 badPlatforms = [ lib.systems.inspect.platformPatterns.isStatic ];
199 PulseAudio is a sound server for POSIX and Win32 systems. A
200 sound server is basically a proxy for your sound applications.
201 It allows you to do advanced operations on your sound data as it
202 passes between your application and your hardware. Things like
203 transferring the audio to a different machine, changing the
204 sample format or channel count and mixing several sounds into
205 one are easily achieved using a sound server.