1{ lib, stdenv, fetchurl, pkgconfig, intltool, autoreconfHook
2, json_c, libsndfile, libtool
3, xlibs, libcap, alsaLib, glib
4, avahi, libjack2, libasyncns, lirc, dbus
5, sbc, bluez5, udev, openssl, fftwFloat
6, speexdsp, systemd, webrtc-audio-processing, gconf ? null
7
8# Database selection
9, tdb ? null, gdbm ? null
10
11, x11Support ? false
12
13, useSystemd ? true
14
15, # Whether to support the JACK sound system as a backend.
16 jackaudioSupport ? false
17
18, # Whether to build the OSS wrapper ("padsp").
19 ossWrapper ? true
20
21, airtunesSupport ? false
22
23, gconfSupport ? false
24
25, bluetoothSupport ? false
26
27, remoteControlSupport ? false
28
29, zeroconfSupport ? false
30
31, # Whether to build only the library.
32 libOnly ? false
33}:
34
35stdenv.mkDerivation rec {
36 name = "${if libOnly then "lib" else ""}pulseaudio-${version}";
37 version = "6.0";
38
39 src = fetchurl {
40 url = "http://freedesktop.org/software/pulseaudio/releases/pulseaudio-${version}.tar.xz";
41 sha256 = "1xpnfxa0d8pgf6b4qdgnkcvrvdxbbbjd5ync19h0f5hbp3h401mm";
42 };
43
44 patches = [ ./caps-fix.patch ];
45
46 nativeBuildInputs = [ pkgconfig intltool autoreconfHook ];
47
48 propagatedBuildInputs =
49 lib.optionals stdenv.isLinux [ libcap ];
50
51 buildInputs =
52 [ json_c libsndfile speexdsp fftwFloat ]
53 ++ lib.optionals stdenv.isLinux [ glib dbus.libs ]
54 ++ lib.optionals (!libOnly) (
55 [ libasyncns webrtc-audio-processing ]
56 ++ lib.optional jackaudioSupport libjack2
57 ++ lib.optionals x11Support [ xlibs.xlibs xlibs.libXtst xlibs.libXi ]
58 ++ lib.optional useSystemd systemd
59 ++ lib.optionals stdenv.isLinux [ alsaLib udev ]
60 ++ lib.optional airtunesSupport openssl
61 ++ lib.optional gconfSupport gconf
62 ++ lib.optionals bluetoothSupport [ bluez5 sbc ]
63 ++ lib.optional remoteControlSupport lirc
64 ++ lib.optional zeroconfSupport avahi
65 );
66
67 preConfigure = ''
68 # Performs and autoreconf
69 export NOCONFIGURE="yes"
70 patchShebangs bootstrap.sh
71 ./bootstrap.sh
72
73 # Move the udev rules under $(prefix).
74 sed -i "src/Makefile.in" \
75 -e "s|udevrulesdir[[:blank:]]*=.*$|udevrulesdir = $out/lib/udev/rules.d|g"
76
77 # don't install proximity-helper as root and setuid
78 sed -i "src/Makefile.in" \
79 -e "s|chown root|true |" \
80 -e "s|chmod r+s |true |"
81 '';
82
83 configureFlags =
84 [ "--disable-solaris"
85 "--disable-jack"
86 "--disable-oss-output"
87 ] ++ lib.optional (!ossWrapper) "--disable-oss-wrapper" ++
88 [ "--localstatedir=/var"
89 "--sysconfdir=/etc"
90 "--with-access-group=audio"
91 ]
92 ++ lib.optional (jackaudioSupport && !libOnly) "--enable-jack"
93 ++ lib.optional stdenv.isDarwin "--with-mac-sysroot=/"
94 ++ lib.optional (stdenv.isLinux && useSystemd) "--with-systemduserunitdir=\${out}/lib/systemd/user";
95
96 enableParallelBuilding = true;
97
98 # not sure what the best practices are here -- can't seem to find a way
99 # for the compiler to bring in stdlib and stdio (etc.) properly
100 # the alternative is to copy the files from /usr/include to src, but there are
101 # probably a large number of files that would need to be copied (I stopped
102 # after the seventh)
103 NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin "-I/usr/include";
104
105 installFlags =
106 [ "sysconfdir=$(out)/etc"
107 "pulseconfdir=$(out)/etc/pulse"
108 ];
109
110 postInstall = lib.optionalString libOnly ''
111 rm -rf $out/{bin,share,etc,lib/{pulse-*,systemd}}
112 sed 's|-lltdl|-L${libtool}/lib -lltdl|' -i $out/lib/libpulsecore-6.0.la
113 '';
114
115 meta = {
116 description = "Sound server for POSIX and Win32 systems";
117 homepage = http://www.pulseaudio.org/;
118 licenses = lib.licenses.lgpl2Plus;
119 maintainers = with lib.maintainers; [ lovek323 wkennington ];
120 platforms = lib.platforms.unix;
121
122 longDescription = ''
123 PulseAudio is a sound server for POSIX and Win32 systems. A
124 sound server is basically a proxy for your sound applications.
125 It allows you to do advanced operations on your sound data as it
126 passes between your application and your hardware. Things like
127 transferring the audio to a different machine, changing the
128 sample format or channel count and mixing several sounds into
129 one are easily achieved using a sound server.
130 '';
131 };
132}