nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 fetchpatch,
6 SDL2,
7 SDL2_image,
8 pkg-config,
9}:
10
11stdenv.mkDerivation (finalAttrs: {
12 pname = "klystrack";
13 version = "1.7.6";
14
15 src = fetchFromGitHub {
16 owner = "kometbomb";
17 repo = "klystrack";
18 tag = finalAttrs.version;
19 fetchSubmodules = true;
20 hash = "sha256-30fUI4abo4TxoUdZfKBowL4lF/lDiwnhQASr1kTVKcE=";
21 };
22
23 # https://github.com/kometbomb/klystrack/commit/6dac9eb5e75801ce4dec1d8b339f78e3df2f54bc fixes build but doesn't apply as-is, just patch in the flag
24 # Make embedded date reproducible
25 # Use pkg-config instead of sdl2-config
26 postPatch = ''
27 substituteInPlace Makefile \
28 --replace-fail '-DUSESDL_IMAGE' '-DUSESDL_IMAGE -DUSESDL_RWOPS'
29
30 substituteInPlace Makefile klystron/Makefile \
31 --replace-fail 'date' 'date --date @$(SOURCE_DATE_EPOCH)'
32
33 substituteInPlace klystron/common.mk klystron/tools/makebundle/Makefile \
34 --replace-fail 'sdl2-config' 'pkg-config sdl2 SDL2_image'
35 '';
36
37 strictDeps = true;
38
39 nativeBuildInputs = [
40 pkg-config
41 ];
42
43 buildInputs = [
44 SDL2
45 SDL2_image
46 ];
47
48 patches = [
49 (fetchpatch {
50 url = "https://github.com/kometbomb/klystrack/commit/bb537595d02140176831c4a1b8e9121978b32d22.patch";
51 hash = "sha256-sb7ZYf27qfmWp8RiZFIIOpUJenp0hNXvTAM8LgFO9Bk=";
52 })
53 ];
54
55 # Workaround build failure on -fno-common toolchains:
56 # ld: libengine_gui.a(gui_menu.o):(.bss+0x0): multiple definition of
57 # `menu_t'; objs.release/action.o:(.bss+0x20): first defined here
58 # TODO: remove it for 1.7.7+ release as it was fixed upstream.
59 env.NIX_CFLAGS_COMPILE = "-fcommon";
60
61 buildFlags = [
62 "PREFIX=${placeholder "out"}"
63 "CFG=release"
64 ];
65
66 installPhase = ''
67 runHook preInstall
68
69 install -Dm755 bin.release/klystrack $out/bin/klystrack
70
71 mkdir -p $out/lib/klystrack
72 cp -R res $out/lib/klystrack
73 cp -R key $out/lib/klystrack
74
75 install -DT icon/256x256.png $out/share/icons/hicolor/256x256/apps/klystrack.png
76 mkdir -p $out/share/applications
77 substitute linux/klystrack.desktop $out/share/applications/klystrack.desktop \
78 --replace "klystrack %f" "$out/bin/klystrack %f"
79
80 runHook postInstall
81 '';
82
83 meta = {
84 description = "Chiptune tracker";
85 homepage = "https://kometbomb.github.io/klystrack";
86 license = lib.licenses.mit;
87 maintainers = with lib.maintainers; [ suhr ];
88 platforms = lib.platforms.linux;
89 mainProgram = "klystrack";
90 };
91})