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 # Fix build with gcc15
103 env.NIX_CFLAGS_COMPILE = "-std=gnu17";
104
105 # the instruments could be compressed (?)
106 postInstall = ''
107 mkdir -p $out/share/timidity/;
108 cp ${./timidity.cfg} $out/share/timidity/timidity.cfg
109 substituteAllInPlace $out/share/timidity/timidity.cfg
110 tar --strip-components=1 -xf $instruments -C $out/share/timidity/
111 # All but one of the symlinks in the instruments tarball have their permissions set to 0000.
112 # This causes problems on systems like Darwin that actually use symlink permissions.
113 chmod -Rh u+rwX $out/share/timidity/
114 '';
115
116 passthru.tests = nixosTests.timidity;
117
118 meta = {
119 homepage = "https://sourceforge.net/projects/timidity/";
120 license = lib.licenses.gpl2Plus;
121 description = "Software MIDI renderer";
122 maintainers = [ lib.maintainers.marcweber ];
123 platforms = lib.platforms.unix;
124 mainProgram = "timidity";
125 };
126}