@@ -1,9 +1,12 @@
11{ stdenv, fetchFromGitHub, pkgconfig, python2Packages, makeWrapper
22, bash, libsamplerate, libsndfile, readline, eigen, celt
3+# Darwin Dependencies
4+, aften, AudioToolbox, CoreAudio, CoreFoundation
35
46# Optional Dependencies
57, dbus ? null, libffado ? null, alsaLib ? null
68, libopus ? null
9+, darwin
710
811# Extra options
912, prefix ? ""
@@ -16,7 +19,7 @@ let
1619
1720 libOnly = prefix == "lib";
1821
19− optDbus = shouldUsePkg dbus;
22+ optDbus = if stdenv.isDarwin then null else shouldUsePkg dbus;
2023 optPythonDBus = if libOnly then null else shouldUsePkg dbus-python;
2124 optLibffado = if libOnly then null else shouldUsePkg libffado;
2225 optAlsaLib = if libOnly then null else shouldUsePkg alsaLib;
@@ -34,21 +37,36 @@ stdenv.mkDerivation rec {
3437 };
3538
3639 nativeBuildInputs = [ pkgconfig python makeWrapper ];
37− buildInputs = [ python libsamplerate libsndfile readline eigen celt
40+ buildInputs = [ libsamplerate libsndfile readline eigen celt
3841 optDbus optPythonDBus optLibffado optAlsaLib optLibopus
39− ];
42+ ] ++ stdenv.lib.optionals stdenv.isDarwin [ aften AudioToolbox CoreAudio CoreFoundation ];
4043
41− patchPhase = ''
42− substituteInPlace svnversion_regenerate.sh --replace /bin/bash ${bash}/bin/bash
44+ # CoreFoundation 10.10 doesn't include CFNotificationCenter.h yet.
45+ patches = stdenv.lib.optionals stdenv.isDarwin [ ./clang.patch ./darwin-cf.patch ];
46+
47+ prePatch = ''
48+ substituteInPlace svnversion_regenerate.sh \
49+ --replace /bin/bash ${bash}/bin/bash
50+ '';
51+
52+ # It looks like one of the frameworks depends on <CoreFoundation/CFAttributedString.h>
53+ # since frameworks are impure we also have to use the impure CoreFoundation here.
54+ # FIXME: remove when CoreFoundation is updated to 10.11
55+ preConfigure = stdenv.lib.optionalString stdenv.isDarwin ''
56+ export NIX_CFLAGS_COMPILE="-F${CoreFoundation}/Library/Frameworks $NIX_CFLAGS_COMPILE"
4357 '';
4458
4559 configurePhase = ''
60+ runHook preConfigure
61+
4662 python waf configure --prefix=$out \
4763 ${optionalString (optDbus != null) "--dbus"} \
4864 --classic \
4965 ${optionalString (optLibffado != null) "--firewire"} \
5066 ${optionalString (optAlsaLib != null) "--alsa"} \
5167 --autostart=${if (optDbus != null) then "dbus" else "classic"} \
68+
69+ runHook postConfigure
5270 '';
5371
5472 buildPhase = ''