From a2a35082ccd64b4d00d88778d9633fe18c0bb215 Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Sat, 25 Apr 2015 21:27:41 -0700 Subject: [PATCH] pulseaudio: Refactor --- pkgs/servers/pulseaudio/default.nix | 164 ++++++++++++++++++++++------ pkgs/top-level/all-packages.nix | 28 +++-- 2 files changed, 152 insertions(+), 40 deletions(-) diff --git a/pkgs/servers/pulseaudio/default.nix b/pkgs/servers/pulseaudio/default.nix index 4228f8b1eab..31c32fd7222 100644 --- a/pkgs/servers/pulseaudio/default.nix +++ b/pkgs/servers/pulseaudio/default.nix @@ -1,32 +1,90 @@ -{ stdenv, fetchurl, fetchpatch, pkgconfig, gnum4, gdbm, libtool, glib, dbus, avahi -, gconf, gtk, intltool, gettext, alsaLib, libsamplerate, libsndfile, speex -, bluez, sbc, udev, libcap, json_c -, jackaudioSupport ? false, jack2 ? null -, x11Support ? false, xlibs -, useSystemd ? false, systemd ? null -, ossWrapper ? false }: +{ stdenv, fetchurl, pkgconfig, gnum4, libtool +, json_c, libsndfile, gettext, intltool, check -assert jackaudioSupport -> jack2 != null; +# Optional Dependencies +, xlibs ? null, libcap ? null, valgrind ? null, oss ? null, coreaudio ? null +, alsaLib ? null, esound ? null, glib ? null, gtk3 ? null, gconf ? null +, avahi ? null, libjack2 ? null, libasyncns ? null, lirc ? null, dbus ? null +, sbc ? null, bluez5 ? null, udev ? null, openssl ? null, fftw ? null +, speex ? null, systemd ? null, webrtc-audio-processing ? null +# Database selection +, tdb ? null, gdbm ? null + +# Extra options +, prefix ? "" +}: + +let + mkFlag = trueStr: falseStr: cond: name: val: + if cond == null then null else + "--${if cond != false then trueStr else falseStr}${name}${if val != null && cond != false then "=${val}" else ""}"; + mkEnable = mkFlag "enable-" "disable-"; + mkWith = mkFlag "with-" "without-"; + mkOther = mkFlag "" "" true; + + shouldUsePkg = pkg: if pkg != null && stdenv.lib.any (x: x == stdenv.system) pkg.meta.platforms then pkg else null; + + libOnly = prefix == "lib"; + + hasXlibs = xlibs != null; + + optLibcap = if libOnly then null else shouldUsePkg libcap; + hasCaps = optLibcap != null || stdenv.isFreeBSD; # Built-in on FreeBSD + + optOss = if libOnly then null else shouldUsePkg oss; + hasOss = optOss != null || stdenv.isFreeBSD; # Built-in on FreeBSD + + optCoreaudio = if libOnly then null else shouldUsePkg coreaudio; + optAlsaLib = if libOnly then null else shouldUsePkg alsaLib; + optEsound = if libOnly then null else shouldUsePkg esound; + optGlib = if libOnly then null else shouldUsePkg glib; + optGtk3 = if libOnly || hasXlibs then null else shouldUsePkg gtk3; + optGconf = if libOnly then null else shouldUsePkg gconf; + optAvahi = if libOnly then null else shouldUsePkg avahi; + optLibjack2 = if libOnly then null else shouldUsePkg libjack2; + optLibasyncns = shouldUsePkg libasyncns; + optLirc = if libOnly then null else shouldUsePkg lirc; + optDbus = shouldUsePkg dbus; + optSbc = if libOnly then null else shouldUsePkg sbc; + optBluez5 = if optDbus == null || optSbc == null then null + else shouldUsePkg bluez5; + optUdev = if libOnly then null else shouldUsePkg udev; + optOpenssl = if libOnly then null else shouldUsePkg openssl; + optFftw = if libOnly then null else shouldUsePkg fftw; + optSpeex = if libOnly then null else shouldUsePkg speex; + optSystemd = shouldUsePkg systemd; + optWebrtc-audio-processing = if libOnly then null else shouldUsePkg webrtc-audio-processing; + hasWebrtc = if libOnly then null else optWebrtc-audio-processing != null; + + # Pick a database to use + databaseName = if tdb != null then "tdb" else + if gdbm != null then "gdbm" else "simple"; + database = { + tdb = tdb; + gdbm = gdbm; + simple = null; + }.${databaseName}; +in stdenv.mkDerivation rec { - name = "pulseaudio-6.0"; + name = "${prefix}pulseaudio-${version}"; + version = "6.0"; src = fetchurl { - url = "http://freedesktop.org/software/pulseaudio/releases/${name}.tar.xz"; + url = "http://freedesktop.org/software/pulseaudio/releases/pulseaudio-${version}.tar.xz"; sha256 = "1xpnfxa0d8pgf6b4qdgnkcvrvdxbbbjd5ync19h0f5hbp3h401mm"; }; - # Since `libpulse*.la' contain `-lgdbm' and `-lcap', it must be propagated. - propagatedBuildInputs - = [ gdbm ] ++ stdenv.lib.optionals stdenv.isLinux [ libcap ]; + nativeBuildInputs = [ pkgconfig gnum4 libtool ]; + buildInputs = [ + json_c libsndfile gettext intltool check database - buildInputs = - [ pkgconfig gnum4 libtool intltool glib dbus avahi libsamplerate libsndfile - speex json_c ] - ++ stdenv.lib.optional jackaudioSupport jack2 - ++ stdenv.lib.optionals x11Support [ xlibs.xlibs xlibs.libXtst xlibs.libXi ] - ++ stdenv.lib.optional useSystemd systemd - ++ stdenv.lib.optionals stdenv.isLinux [ alsaLib bluez sbc udev ]; + optLibcap valgrind optOss optCoreaudio optAlsaLib optEsound optGlib + optGtk3 optGconf optAvahi optLibjack2 optLibasyncns optLirc optDbus optUdev + optOpenssl optFftw optSpeex optSystemd optWebrtc-audio-processing + ] ++ stdenv.lib.optionals hasXlibs (with xlibs; [ + libX11 libxcb libICE libSM libXtst xextproto libXi + ]) ++ stdenv.lib.optionals (optBluez5 != null) [ optBluez5 optSbc ]; preConfigure = '' # Move the udev rules under $(prefix). @@ -40,18 +98,55 @@ stdenv.mkDerivation rec { ''; configureFlags = [ - "--disable-solaris" - "--disable-jack" - "--disable-oss-output" - ] ++ stdenv.lib.optional (!ossWrapper) "--disable-oss-wrapper" ++ - [ "--localstatedir=/var" "--sysconfdir=/etc" - "--with-access-group=audio" + + (mkEnable false "atomic-arm-memory-barrier" null) # TODO: Enable on armv8 + (mkEnable false "neon-opt" null) # TODO: Enable on armv8 + (mkEnable hasXlibs "x11" null) + (mkWith hasCaps "caps" null) + (mkEnable true "tests" null) + (mkEnable false "samplerate" null) # Deprecated + (mkWith true "database" databaseName) + (mkEnable hasOss "oss-output" null) + (mkEnable hasOss "oss-wrapper" null) + (mkEnable (optCoreaudio != null) "coreaudio-output" null) + (mkEnable (optAlsaLib != null) "alsa" null) + (mkEnable (optEsound != null) "esound" null) + (mkEnable false "solaris" null) + (mkEnable false "waveout" null) # Windows Only + (mkEnable (optGlib != null) "glib2" null) + (mkEnable (optGtk3 != null) "gtk3" null) + (mkEnable (optGconf != null) "gconf" null) + (mkEnable (optAvahi != null) "avahi" null) + (mkEnable (optLibjack2 != null) "jack" null) + (mkEnable (optLibasyncns != null) "asyncns" null) + (mkEnable false "tcpwrap" null) + (mkEnable (optLirc != null) "lirc" null) + (mkEnable (optDbus != null) "dbus" null) + (mkEnable false "bluez4" null) + (mkEnable (optBluez5 != null) "bluez5" null) + (mkEnable (optBluez5 != null) "bluez5-ofono-headset" null) + (mkEnable (optBluez5 != null) "bluez5-native-headset" null) + (mkEnable (optUdev != null) "udev" null) + (mkEnable false "hal-compat" null) + (mkEnable true "ipv6" null) + (mkEnable (optOpenssl != null) "openssl" null) + (mkWith (optFftw != null) "fftw" null) + (mkWith (optSpeex != null) "speex" null) + (mkEnable false "xen" null) + (mkEnable false "gcov" null) + (mkEnable (optSystemd != null) "systemd-daemon" null) + (mkEnable (optSystemd != null) "systemd-login" null) + (mkEnable (optSystemd != null) "systemd-journal" null) + (mkEnable true "manpages" null) + (mkEnable hasWebrtc "webrtc-aec" null) + (mkEnable true "adrian-aec" null) + (mkWith true "system-user" "pulseaudio") + (mkWith true "system-group" "pulseaudio") + (mkWith true "access-group" "audio") "--with-systemduserunitdir=\${out}/lib/systemd/user" - ] - ++ stdenv.lib.optional jackaudioSupport "--enable-jack" - ++ stdenv.lib.optional stdenv.isDarwin "--with-mac-sysroot=/"; + ] ++ stdenv.lib.optional stdenv.isDarwin "--with-mac-sysroot=/"; enableParallelBuilding = true; @@ -63,7 +158,14 @@ stdenv.mkDerivation rec { NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.isDarwin "-I/usr/include"; - installFlags = "sysconfdir=$(out)/etc pulseconfdir=$(out)/etc/pulse"; + installFlags = [ + "sysconfdir=$(out)/etc" + "pulseconfdir=$(out)/etc/pulse" + ]; + + postInstall = stdenv.lib.optionalString libOnly '' + rm -rf $out/{bin,share,etc,lib/{pulse-*,systemd}} + ''; meta = with stdenv.lib; { description = "Sound server for POSIX and Win32 systems"; @@ -71,7 +173,7 @@ stdenv.mkDerivation rec { # Note: Practically, the server is under the GPL due to the # dependency on `libsamplerate'. See `LICENSE' for details. licenses = licenses.lgpl2Plus; - maintainers = with maintainers; [ lovek323 ]; + maintainers = with maintainers; [ lovek323 wkennington ]; platforms = platforms.unix; longDescription = '' diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index f7b7460aeb2..e9e6da1f7c3 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -8473,21 +8473,31 @@ let pshs = callPackage ../servers/http/pshs { }; - pulseaudio = callPackage ../servers/pulseaudio { - gconf = gnome.GConf; + libpulseaudio = pulseaudioFull.override { + prefix = "lib"; + }; + + pulseaudio = pulseaudioFull.override { # The following are disabled in the default build, because if this # functionality is desired, they are only needed in the PulseAudio # server. - bluez = null; + xlibs = null; + coreaudio = null; + esound = null; + jack2 = null; avahi = null; + lirc = null; + bluez5 = null; + tdb = null; + gdbm = null; }; - pulseaudioFull = pulseaudio.override { - bluez = bluez5; - avahi = avahi; - jackaudioSupport = true; - x11Support = true; - useSystemd = stdenv.isLinux; + pulseaudioFull = callPackage ../servers/pulseaudio { + gconf = gnome3.gconf; + fftw = fftwFloat; + + # Disabled unless debugging + valgrind = null; }; tomcat_connectors = callPackage ../servers/http/apache-modules/tomcat-connectors { };