1{
2 stdenv,
3 lib,
4 fetchFromGitHub,
5 acme,
6 ldc,
7 patchelf,
8 SDL,
9}:
10stdenv.mkDerivation {
11 pname = "cheesecutter";
12 version = "unstable-2021-02-27";
13
14 src = fetchFromGitHub {
15 owner = "theyamo";
16 repo = "CheeseCutter";
17 rev = "84450d3614b8fb2cabda87033baab7bedd5a5c98";
18 sha256 = "sha256:0q4a791nayya6n01l0f4kk497rdq6kiq0n72fqdpwqy138pfwydn";
19 };
20
21 patches = [
22 ./0001-Drop-baked-in-build-date-for-r13y.patch
23 ]
24 ++ lib.optional stdenv.hostPlatform.isDarwin ./0002-Prepend-libSDL.dylib-to-macOS-SDL-loader.patch;
25
26 nativeBuildInputs = [
27 acme
28 ldc
29 ]
30 ++ lib.optional (!stdenv.hostPlatform.isDarwin) patchelf;
31
32 buildInputs = [ SDL ];
33
34 makefile = "Makefile.ldc";
35
36 installPhase = ''
37 for exe in {ccutter,ct2util}; do
38 install -D $exe $out/bin/$exe
39 done
40
41 mkdir -p $out/share/cheesecutter/example_tunes
42 cp -r tunes/* $out/share/cheesecutter/example_tunes
43
44 install -Dm444 arch/fd/ccutter.desktop -t $out/share/applications
45 for res in $(ls icons | sed -e 's/cc//g' -e 's/.png//g'); do
46 install -Dm444 icons/cc$res.png $out/share/icons/hicolor/''${res}x''${res}/apps/cheesecutter.png
47 done
48 '';
49
50 postFixup =
51 let
52 rpathSDL = lib.makeLibraryPath [ SDL ];
53 in
54 if stdenv.hostPlatform.isDarwin then
55 ''
56 install_name_tool -add_rpath ${rpathSDL} $out/bin/ccutter
57 ''
58 else
59 ''
60 rpath=$(patchelf --print-rpath $out/bin/ccutter)
61 patchelf --set-rpath "$rpath:${rpathSDL}" $out/bin/ccutter
62 '';
63
64 meta = with lib; {
65 description = "Tracker program for composing music for the SID chip";
66 homepage = "https://github.com/theyamo/CheeseCutter/";
67 license = licenses.gpl2Plus;
68 platforms = [
69 "x86_64-linux"
70 "i686-linux"
71 "x86_64-darwin"
72 ];
73 maintainers = with maintainers; [ OPNA2608 ];
74 };
75}