1{ stdenv
2, lib
3, fetchFromGitHub
4, fetchpatch
5, cmake
6, pkg-config
7, alsaSupport ? stdenv.hostPlatform.isLinux
8, alsa-lib
9, jackSupport ? true
10, jack
11, coremidiSupport ? stdenv.hostPlatform.isDarwin
12, CoreMIDI
13, CoreAudio
14, CoreServices
15}:
16
17stdenv.mkDerivation rec {
18 version = "4.0.0";
19 pname = "rtmidi";
20
21 src = fetchFromGitHub {
22 owner = "thestk";
23 repo = "rtmidi";
24 rev = version;
25 sha256 = "1g31p6a96djlbk9jh5r4pjly3x76lhccva9hrw6xzdma8dsjzgyq";
26 };
27
28 patches = [
29 # PR #230, fix CMake problems
30 (fetchpatch {
31 name = "RtMidi-Fix-JACK_HAS_PORT_RENAME-define.patch";
32 url = "https://github.com/thestk/rtmidi/pull/230/commits/768a30a61b60240b66cc2d43bc27a544ff9f1622.patch";
33 sha256 = "1sym4f7nb2qyyxfhi1l0xsm2hfh6gddn81y36qvfq4mcs33vvid0";
34 })
35 (fetchpatch {
36 name = "RtMidi-Add-prefix-define-for-pkgconfig.patch";
37 url = "https://github.com/thestk/rtmidi/pull/230/commits/7a32e23e3f6cb43c0d2d58443ce205d438e76f44.patch";
38 sha256 = "06im8mb05wah6bnkadw2gpkhmilxb8p84pxqr50b205cchpq304w";
39 })
40 (fetchpatch {
41 name = "RtMidi-Adjust-public-header-installs-to-match-autotools.patch";
42 url = "https://github.com/thestk/rtmidi/pull/230/commits/892fe5492f0e787484fa4a37027b08c265ce001f.patch";
43 sha256 = "0ca9m42xa3gmycimzvzvl67wa266xq9pfp1b4v555rh2fp52kbcj";
44 })
45 ];
46
47 postPatch = ''
48 substituteInPlace rtmidi.pc.in \
49 --replace 'Requires:' 'Requires.private:'
50 '';
51
52 nativeBuildInputs = [ cmake pkg-config ];
53
54 buildInputs = lib.optional alsaSupport alsa-lib
55 ++ lib.optional jackSupport jack
56 ++ lib.optionals coremidiSupport [ CoreMIDI CoreAudio CoreServices ];
57
58 cmakeFlags = [
59 "-DRTMIDI_API_ALSA=${if alsaSupport then "ON" else "OFF"}"
60 "-DRTMIDI_API_JACK=${if jackSupport then "ON" else "OFF"}"
61 "-DRTMIDI_API_CORE=${if coremidiSupport then "ON" else "OFF"}"
62 ];
63
64 meta = with lib; {
65 description = "A set of C++ classes that provide a cross platform API for realtime MIDI input/output";
66 homepage = "https://www.music.mcgill.ca/~gary/rtmidi/";
67 license = licenses.mit;
68 maintainers = with maintainers; [ magnetophon ];
69 platforms = platforms.unix;
70 };
71}