···1+{ lib
2+, stdenv
3+, fetchFromGitHub
4+, pkg-config
5+, makeWrapper
6+, SDL
7+, SDL_image
8+, SDL_ttf
9+, gtk2
10+, glib
11+}:
12+13+stdenv.mkDerivation rec {
14+ pname = "hivelytracker";
15+ version = "unstable-2020-08-19";
16+17+ src = fetchFromGitHub {
18+ owner = "pete-gordon";
19+ repo = "hivelytracker";
20+ rev = "c8e3c7a5ee9f4a07cb4a941caecf7e4c4f4d40e0";
21+ sha256 = "1nqianlf1msir6wqwapi7ys1vbmf6aik58wa54b6cn5v6kwxh75a";
22+ };
23+24+ nativeBuildInputs = [
25+ pkg-config
26+ makeWrapper
27+ ];
28+29+ buildInputs = [
30+ SDL
31+ SDL_image
32+ SDL_ttf
33+ gtk2
34+ glib
35+ ];
36+37+ makeFlags = [
38+ "-C sdl"
39+ "-f Makefile.linux"
40+ "PREFIX=$(out)"
41+ ];
42+43+ # TODO: try to exclude gtk and glib from darwin builds
44+ NIX_CFLAGS_COMPILE = [
45+ "-I${SDL}/include/SDL"
46+ "-I${SDL_image}/include/SDL"
47+ "-I${SDL_ttf}/include/SDL"
48+ "-I${gtk2.dev}/include/gtk-2.0"
49+ "-I${glib.dev}/include/glib-2.0"
50+ ];
51+52+ # Also build the hvl2wav tool
53+ postBuild = ''
54+ make -C hvl2wav
55+ '';
56+57+ postInstall = ''
58+ # https://github.com/pete-gordon/hivelytracker/issues/43
59+ # Ideally we should patch the sources, but the program can't open
60+ # files passed as arguments anyway, so this works well enough until the
61+ # issue is fixed.
62+ wrapProgram $out/bin/hivelytracker \
63+ --run "cd $out/share/hivelytracker"
64+65+ # Also install the hvl2wav tool
66+ install -Dm755 hvl2wav/hvl2wav $out/bin/hvl2wav
67+ '';
68+69+ meta = with lib; {
70+ homepage = "http://www.hivelytracker.co.uk/";
71+ downloadPage = "http://www.hivelytracker.co.uk/downl.php";
72+ description = "Chip music tracker based upon the AHX format";
73+ longDescription = ''
74+ Hively Tracker is a tracker program based upon the AHX format created in
75+ the mid '90s by Dexter and Pink of Abyss. The format was relatively
76+ popular, and many songs were created and used in scene productions and
77+ games. AHX was designed to create a very SID-like sound on the Amiga.
78+79+ HivelyTracker can import and export modules and instruments in the AHX
80+ format, but it also improves on AHX in several ways and therefore has
81+ its own instrument and module formats.
82+ '';
83+ license = licenses.bsd3;
84+ platforms = platforms.all;
85+ maintainers = with maintainers; [ fgaz ];
86+ broken = stdenv.isDarwin; # TODO: try to use xcbuild
87+ };
88+}
89+