nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchurl,
5 nixosTests,
6 pkg-config,
7 libjack2,
8 ncurses,
9 alsa-lib,
10 buildPackages,
11
12 ## Additional optional output modes
13 enableVorbis ? false,
14 libvorbis,
15}:
16
17stdenv.mkDerivation rec {
18 pname = "timidity";
19 version = "2.15.0";
20
21 src = fetchurl {
22 url = "mirror://sourceforge/timidity/TiMidity++-${version}.tar.bz2";
23 sha256 = "1xf8n6dqzvi6nr2asags12ijbj1lwk1hgl3s27vm2szib8ww07qn";
24 };
25
26 patches = [
27 ./timidity-iA-Oj.patch
28 # Fixes misdetection of features by clang 16. The configure script itself is patched because
29 # it is old and does not work nicely with autoreconfHook.
30 ./configure-compat.patch
31 ];
32
33 postPatch = ''
34 substituteInPlace configure \
35 --replace-fail "\$(pkg-config" "\$(\$PKG_CONFIG"
36 '';
37
38 nativeBuildInputs = [ pkg-config ];
39 buildInputs = [
40 libjack2
41 ncurses
42 ]
43 ++ lib.optionals stdenv.hostPlatform.isLinux [
44 alsa-lib
45 ]
46 ++ lib.optionals enableVorbis [
47 libvorbis
48 ];
49
50 enabledOutputModes = [
51 "jack"
52 ]
53 ++ lib.optionals stdenv.hostPlatform.isLinux [
54 "oss"
55 "alsa"
56 ]
57 ++ lib.optionals stdenv.hostPlatform.isDarwin [
58 "darwin"
59 ]
60 ++ lib.optionals enableVorbis [
61 "vorbis"
62 ];
63
64 configureFlags = [
65 "--enable-ncurses"
66 ("--enable-audio=" + builtins.concatStringsSep "," enabledOutputModes)
67 "lib_cv_va_copy=yes"
68 "lib_cv___va_copy=yes"
69 ]
70 ++ lib.optionals stdenv.hostPlatform.isLinux [
71 "--enable-alsaseq"
72 "--with-default-output=alsa"
73 "lib_cv_va_val_copy=yes"
74 ]
75 ++ lib.optionals stdenv.hostPlatform.isDarwin [
76 "lib_cv_va_val_copy=no"
77 "timidity_cv_ccoption_rdynamic=yes"
78 # These configure tests fail because of incompatible function pointer conversions.
79 "ac_cv_func_vprintf=yes"
80 "ac_cv_func_popen=yes"
81 "ac_cv_func_vsnprintf=yes"
82 "ac_cv_func_snprintf=yes"
83 "ac_cv_func_open_memstream=yes"
84 ];
85
86 makeFlags = [
87 "AR=${stdenv.cc.targetPrefix}ar"
88 ];
89
90 instruments = fetchurl {
91 url = "https://courses.cs.umbc.edu/pub/midia/instruments.tar.gz";
92 sha256 = "0lsh9l8l5h46z0y8ybsjd4pf6c22n33jsjvapfv3rjlfnasnqw67";
93 };
94
95 preBuild = ''
96 # calcnewt has to be built with the host compiler.
97 ${buildPackages.stdenv.cc}/bin/cc -o timidity/calcnewt -lm timidity/calcnewt.c
98 # Remove dependencies of calcnewt so it doesn't try to remake it.
99 sed -i 's/^\(calcnewt\$(EXEEXT):\).*/\1/g' timidity/Makefile
100 '';
101
102 # the instruments could be compressed (?)
103 postInstall = ''
104 mkdir -p $out/share/timidity/;
105 cp ${./timidity.cfg} $out/share/timidity/timidity.cfg
106 substituteAllInPlace $out/share/timidity/timidity.cfg
107 tar --strip-components=1 -xf $instruments -C $out/share/timidity/
108 # All but one of the symlinks in the instruments tarball have their permissions set to 0000.
109 # This causes problems on systems like Darwin that actually use symlink permissions.
110 chmod -Rh u+rwX $out/share/timidity/
111 '';
112
113 passthru.tests = nixosTests.timidity;
114
115 meta = with lib; {
116 homepage = "https://sourceforge.net/projects/timidity/";
117 license = licenses.gpl2Plus;
118 description = "Software MIDI renderer";
119 maintainers = [ maintainers.marcweber ];
120 platforms = platforms.unix;
121 mainProgram = "timidity";
122 };
123}