1{
2 lib,
3 stdenv,
4 fetchurl,
5 unzip,
6 copyDesktopItems,
7 makeDesktopItem,
8 imagemagick,
9 SDL,
10 isStereo ? false,
11}:
12
13let
14 pname = "goattracker" + lib.optionalString isStereo "-stereo";
15 desktopItem = makeDesktopItem {
16 name = pname;
17 desktopName = "GoatTracker 2" + lib.optionalString isStereo " Stereo";
18 genericName = "Music Tracker";
19 exec = if isStereo then "gt2stereo" else "goattrk2";
20 icon = "goattracker";
21 categories = [
22 "AudioVideo"
23 "AudioVideoEditing"
24 ];
25 keywords = [
26 "tracker"
27 "music"
28 ];
29 };
30
31in
32stdenv.mkDerivation (finalAttrs: {
33 inherit pname;
34 version =
35 if isStereo then
36 "2.77" # stereo
37 else
38 "2.77"; # normal
39
40 src = fetchurl {
41 url = "mirror://sourceforge/goattracker2/GoatTracker_${finalAttrs.version}${lib.optionalString isStereo "_Stereo"}.zip";
42 sha256 =
43 if isStereo then
44 "1hiig2d152sv9kazwz33i56x1c54h5sh21ipkqnp6qlnwj8x1ksy" # stereo
45 else
46 "sha256-lsK9amqzrKL1uxixx2SsbqaawkXK4UACpyzYfFVFYe8="; # normal
47 };
48 sourceRoot = "src";
49
50 nativeBuildInputs = [
51 copyDesktopItems
52 unzip
53 imagemagick
54 ];
55 buildInputs = [ SDL ];
56
57 # PREFIX gets treated as BINDIR.
58 makeFlags = [ "PREFIX=$(out)/bin/" ];
59
60 # The zip contains some build artifacts.
61 prePatch = ''
62 make clean
63 '';
64
65 # The destination does not get created automatically.
66 preBuild = ''
67 mkdir -p $out/bin
68 '';
69
70 # Other files get installed during the build phase.
71 installPhase = ''
72 runHook preInstall
73
74 convert goattrk2.bmp goattracker.png
75 install -Dm644 goattracker.png $out/share/icons/hicolor/32x32/apps/goattracker.png
76 ${lib.optionalString (
77 !isStereo
78 ) "install -Dm644 ../linux/goattracker.1 $out/share/man/man1/goattracker.1"}
79
80 runHook postInstall
81 '';
82
83 desktopItems = [ desktopItem ];
84
85 meta = {
86 description =
87 "Crossplatform music editor for creating Commodore 64 music. Uses reSID library by Dag Lem and supports alternatively HardSID & CatWeasel devices"
88 + lib.optionalString isStereo " - Stereo version";
89 homepage = "https://cadaver.github.io/tools.html";
90 downloadPage = "https://sourceforge.net/projects/goattracker2/";
91 license = lib.licenses.gpl2Plus;
92 mainProgram = if isStereo then "gt2stereo" else "goattrk2";
93 maintainers = with lib.maintainers; [ fgaz ];
94 platforms = lib.platforms.all;
95 };
96})