1{ lib, stdenv, fetchFromGitHub, pkg-config, python3Packages, makeWrapper
2, 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, testers
15}:
16
17let
18 inherit (python3Packages) python dbus-python;
19 shouldUsePkg = pkg: if pkg != null && lib.meta.availableOn stdenv.hostPlatform pkg then pkg else null;
20
21 libOnly = prefix == "lib";
22
23 optDbus = if stdenv.isDarwin then null else shouldUsePkg dbus;
24 optPythonDBus = if libOnly then null else shouldUsePkg dbus-python;
25 optLibffado = if libOnly then null else shouldUsePkg libffado;
26 optAlsaLib = if libOnly then null else shouldUsePkg alsa-lib;
27 optLibopus = shouldUsePkg libopus;
28in
29stdenv.mkDerivation (finalAttrs: {
30 pname = "${prefix}jack2";
31 version = "1.9.22";
32
33 src = fetchFromGitHub {
34 owner = "jackaudio";
35 repo = "jack2";
36 rev = "v${finalAttrs.version}";
37 sha256 = "sha256-Cslfys5fcZDy0oee9/nM5Bd1+Cg4s/ayXjJJOSQCL4E=";
38 };
39
40 outputs = [ "out" "dev" ];
41
42 nativeBuildInputs = [ pkg-config python makeWrapper wafHook ];
43 buildInputs = [ libsamplerate libsndfile readline eigen celt
44 optDbus optPythonDBus optLibffado optAlsaLib optLibopus
45 ] ++ lib.optionals stdenv.isDarwin [
46 aften AudioUnit CoreAudio Accelerate libobjc
47 ];
48
49 postPatch = ''
50 patchShebangs --build svnversion_regenerate.sh
51 '';
52
53 dontAddWafCrossFlags = true;
54
55 wafConfigureFlags = [
56 "--classic"
57 "--autostart=${if (optDbus != null) then "dbus" else "classic"}"
58 ] ++ lib.optional (optDbus != null) "--dbus"
59 ++ lib.optional (optLibffado != null) "--firewire"
60 ++ lib.optional (optAlsaLib != null) "--alsa";
61
62 postInstall = (if libOnly then ''
63 rm -rf $out/{bin,share}
64 rm -rf $out/lib/{jack,libjacknet*,libjackserver*}
65 '' else lib.optionalString (optDbus != null) ''
66 wrapProgram $out/bin/jack_control --set PYTHONPATH $PYTHONPATH
67 '');
68
69 postFixup = ''
70 substituteInPlace "$dev/lib/pkgconfig/jack.pc" \
71 --replace "$out/include" "$dev/include"
72 '';
73
74 passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
75
76 meta = with lib; {
77 description = "JACK audio connection kit, version 2 with jackdbus";
78 homepage = "https://jackaudio.org";
79 license = licenses.gpl2Plus;
80 pkgConfigModules = [ "jack" ];
81 platforms = platforms.unix;
82 maintainers = with maintainers; [ goibhniu ];
83 };
84})