1{ stdenv
2, lib
3, fetchFromGitHub
4, unstableGitUpdater
5, dos2unix
6, pkg-config
7, zlib
8, alsa-lib
9, libjack2
10}:
11
12stdenv.mkDerivation rec {
13 pname = "fmtoy";
14 version = "unstable-2022-12-23";
15
16 src = fetchFromGitHub {
17 owner = "vampirefrog";
18 repo = "fmtoy";
19 rev = "78b61b5e9bc0c6874962dc4040456581c9999b36";
20 sha256 = "r5zbr6TCxzDiQvDsLQu/QwNfem1K4Ahaji0yIz/2yl0=";
21 };
22
23 postPatch = ''
24 dos2unix Makefile
25 # Don't hardcode compilers
26 sed -i -e '/CC=/d' -e '/CXX=/d' Makefile
27 '' + lib.optionalString stdenv.hostPlatform.isDarwin ''
28 # Remove Linux-only program & its dependencies
29 sed -i -e '/PROGS/ s/fmtoy_jack//' Makefile
30 substituteInPlace Makefile \
31 --replace '$(shell pkg-config alsa jack --cflags)' ""
32 '';
33
34 nativeBuildInputs = [
35 dos2unix
36 ] ++ lib.optionals stdenv.hostPlatform.isLinux [
37 pkg-config
38 ];
39
40 buildInputs = [
41 zlib
42 ] ++ lib.optionals stdenv.hostPlatform.isLinux [
43 alsa-lib
44 libjack2
45 ];
46
47 enableParallelBuilding = true;
48
49 installPhase = ''
50 runHook preInstall
51
52 for prog in $(grep 'PROGS=' Makefile | cut -d= -f2-); do
53 install -Dm755 $prog $out/bin/$prog
54 done
55
56 runHook postInstall
57 '';
58
59 passthru.updateScript = unstableGitUpdater {
60 url = "https://github.com/vampirefrog/fmtoy.git";
61 };
62
63 meta = with lib; {
64 homepage = "https://github.com/vampirefrog/fmtoy";
65 description = "Tools for FM voices for Yamaha YM chips (OPL, OPM and OPN series)";
66 # Unclear if gpl3Only or gpl3Plus
67 # https://github.com/vampirefrog/fmtoy/issues/1
68 license = licenses.gpl3;
69 maintainers = with maintainers; [ OPNA2608 ];
70 platforms = platforms.all;
71 };
72}