nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 fetchpatch2,
6 pkg-config,
7 python3Packages,
8 makeWrapper,
9 libsamplerate,
10 wafHook,
11 # Darwin Dependencies
12 aften,
13
14 # BSD Dependencies
15 freebsd,
16
17 # Optional Dependencies
18 dbus ? null,
19 expat, # for dbus
20 libffado ? null,
21 alsa-lib ? null,
22
23 # Extra options
24 prefix ? "",
25
26 testers,
27}:
28
29let
30 inherit (python3Packages) python dbus-python;
31 shouldUsePkg =
32 pkg: if pkg != null && lib.meta.availableOn stdenv.hostPlatform pkg then pkg else null;
33
34 libOnly = prefix == "lib";
35
36 optDbus = if stdenv.hostPlatform.isDarwin then null else shouldUsePkg dbus;
37 optPythonDBus = if libOnly then null else shouldUsePkg dbus-python;
38 optLibffado = if libOnly then null else shouldUsePkg libffado;
39 optAlsaLib = if libOnly then null else shouldUsePkg alsa-lib;
40in
41stdenv.mkDerivation (finalAttrs: {
42 pname = "${prefix}jack2";
43 version = "1.9.22";
44
45 src = fetchFromGitHub {
46 owner = "jackaudio";
47 repo = "jack2";
48 rev = "v${finalAttrs.version}";
49 sha256 = "sha256-Cslfys5fcZDy0oee9/nM5Bd1+Cg4s/ayXjJJOSQCL4E=";
50 };
51
52 outputs = [
53 "out"
54 "dev"
55 ];
56
57 nativeBuildInputs = [
58 pkg-config
59 python
60 wafHook
61 ]
62 ++ lib.optionals (optDbus != null) [ makeWrapper ];
63 buildInputs = [
64 libsamplerate
65 optDbus
66 optPythonDBus
67 optLibffado
68 optAlsaLib
69 ]
70 ++ lib.optionals (optDbus != null) [ expat ]
71 ++ lib.optionals stdenv.hostPlatform.isDarwin [
72 aften
73 ]
74 ++ lib.optionals stdenv.hostPlatform.isFreeBSD [
75 freebsd.libsysinfo
76 ];
77
78 patches = [
79 (fetchpatch2 {
80 # Python 3.12 support
81 name = "jack2-waf2.0.26.patch";
82 url = "https://github.com/jackaudio/jack2/commit/250420381b1a6974798939ad7104ab1a4b9a9994.patch";
83 hash = "sha256-M/H72lLTeddefqth4BSkEfySZRYMIzLErb7nIgVN0u8=";
84 })
85 ];
86
87 postPatch = ''
88 patchShebangs --build svnversion_regenerate.sh
89 '';
90
91 wafConfigureFlags = [
92 "--classic"
93 "--autostart=${if (optDbus != null) then "dbus" else "classic"}"
94 ]
95 ++ lib.optional (optDbus != null) "--dbus"
96 ++ lib.optional (optLibffado != null) "--firewire"
97 ++ lib.optional (optAlsaLib != null) "--alsa"
98 ++ lib.optional (
99 stdenv.hostPlatform != stdenv.buildPlatform
100 ) "--platform=${stdenv.hostPlatform.parsed.kernel.name}";
101
102 postInstall = (
103 if libOnly then
104 ''
105 rm -rf $out/{bin,share}
106 rm -rf $out/lib/{jack,libjacknet*,libjackserver*}
107 ''
108 else
109 lib.optionalString (optDbus != null) ''
110 wrapProgram $out/bin/jack_control --set PYTHONPATH $PYTHONPATH
111 ''
112 );
113
114 postFixup = ''
115 substituteInPlace "$dev/lib/pkgconfig/jack.pc" \
116 --replace-fail "$out/include" "$dev/include"
117 '';
118
119 passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
120
121 meta = {
122 description = "JACK audio connection kit, version 2 with jackdbus";
123 homepage = "https://jackaudio.org";
124 license = lib.licenses.gpl2Plus;
125 pkgConfigModules = [ "jack" ];
126 platforms = lib.platforms.unix;
127 maintainers = [ ];
128 };
129})