1{ lib, stdenv, fetchFromGitHub, pkg-config, python3Packages, makeWrapper
2, bash, libsamplerate, libsndfile, readline, eigen, celt
3, wafHook
4# Darwin Dependencies
5, aften, AudioUnit, CoreAudio, libobjc, Accelerate
6
7# Optional Dependencies
8, dbus ? null, libffado ? null, alsa-lib ? null
9, libopus ? null
10
11# Extra options
12, prefix ? ""
13}:
14
15with lib;
16let
17 inherit (python3Packages) python dbus-python;
18 shouldUsePkg = pkg: if pkg != null && lib.meta.availableOn stdenv.hostPlatform pkg then pkg else null;
19
20 libOnly = prefix == "lib";
21
22 optDbus = if stdenv.isDarwin then null else shouldUsePkg dbus;
23 optPythonDBus = if libOnly then null else shouldUsePkg dbus-python;
24 optLibffado = if libOnly then null else shouldUsePkg libffado;
25 optAlsaLib = if libOnly then null else shouldUsePkg alsa-lib;
26 optLibopus = shouldUsePkg libopus;
27in
28stdenv.mkDerivation rec {
29 pname = "${prefix}jack2";
30 version = "1.9.19";
31
32 src = fetchFromGitHub {
33 owner = "jackaudio";
34 repo = "jack2";
35 rev = "v${version}";
36 sha256 = "01s8i64qczxqawgrzrw19asaqmcspf5l2h3203xzg56wnnhhzcw7";
37 };
38
39 nativeBuildInputs = [ pkg-config python makeWrapper wafHook ];
40 buildInputs = [ libsamplerate libsndfile readline eigen celt
41 optDbus optPythonDBus optLibffado optAlsaLib optLibopus
42 ] ++ optionals stdenv.isDarwin [
43 aften AudioUnit CoreAudio Accelerate libobjc
44 ];
45
46 prePatch = ''
47 substituteInPlace svnversion_regenerate.sh \
48 --replace /bin/bash ${bash}/bin/bash
49 '';
50
51 PKGCONFIG = "${stdenv.cc.targetPrefix}pkg-config";
52
53 dontAddWafCrossFlags = "true";
54 wafConfigureFlags = [
55 "--classic"
56 "--autostart=${if (optDbus != null) then "dbus" else "classic"}"
57 ] ++ optional (optDbus != null) "--dbus"
58 ++ optional (optLibffado != null) "--firewire"
59 ++ optional (optAlsaLib != null) "--alsa";
60
61 postInstall = (if libOnly then ''
62 rm -rf $out/{bin,share}
63 rm -rf $out/lib/{jack,libjacknet*,libjackserver*}
64 '' else ''
65 wrapProgram $out/bin/jack_control --set PYTHONPATH $PYTHONPATH
66 '');
67
68 meta = {
69 description = "JACK audio connection kit, version 2 with jackdbus";
70 homepage = "https://jackaudio.org";
71 license = licenses.gpl2Plus;
72 platforms = platforms.unix;
73 maintainers = with maintainers; [ goibhniu ];
74 };
75}