1{
2 stdenv,
3 lib,
4 fetchFromGitHub,
5 gitUpdater,
6 cmake,
7 pkg-config,
8 libX11,
9 libXrandr,
10 libXinerama,
11 libXext,
12 libXcursor,
13 freetype,
14 alsa-lib,
15 libjack2,
16}:
17
18stdenv.mkDerivation (finalAttrs: {
19 pname = "dexed";
20 version = "0.9.8";
21
22 src = fetchFromGitHub {
23 owner = "asb2m10";
24 repo = "dexed";
25 tag = "v${finalAttrs.version}";
26 fetchSubmodules = true;
27 hash = "sha256-mXr1KGzA+DF2dEgAJE4lpnefPqO8pqfnKa43vyjSJgU=";
28 };
29
30 postPatch = ''
31 substituteInPlace CMakeLists.txt \
32 --replace-fail 'set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE INTERNAL "")' '# Not forcing output archs'
33
34 substituteInPlace Source/CMakeLists.txt \
35 --replace-fail 'COPY_PLUGIN_AFTER_BUILD TRUE' 'COPY_PLUGIN_AFTER_BUILD FALSE'
36 ''
37 # LTO needs special setup on Linux
38 + lib.optionalString stdenv.hostPlatform.isLinux ''
39 substituteInPlace Source/CMakeLists.txt \
40 --replace-fail 'juce::juce_recommended_lto_flags' '# Not forcing LTO'
41 '';
42
43 strictDeps = true;
44
45 nativeBuildInputs = [
46 cmake
47 pkg-config
48 ];
49
50 buildInputs = lib.optionals stdenv.hostPlatform.isLinux [
51 libX11
52 libXext
53 libXcursor
54 libXinerama
55 libXrandr
56 freetype
57 alsa-lib
58 libjack2
59 ];
60
61 # JUCE insists on only dlopen'ing these
62 NIX_LDFLAGS = lib.optionalString stdenv.hostPlatform.isLinux (toString [
63 "-lX11"
64 "-lXext"
65 "-lXcursor"
66 "-lXinerama"
67 "-lXrandr"
68 "-ljack"
69 ]);
70
71 installPhase =
72 let
73 vst3Dir =
74 if stdenv.hostPlatform.isDarwin then "$out/Library/Audio/Plug-Ins/VST3" else "$out/lib/vst3";
75 # this one's a guess, don't know where ppl have agreed to put them yet
76 clapDir =
77 if stdenv.hostPlatform.isDarwin then "$out/Library/Audio/Plug-Ins/CLAP" else "$out/lib/clap";
78 auDir = "$out/Library/Audio/Plug-Ins/Components";
79 in
80 ''
81 runHook preInstall
82
83 ''
84 + (
85 if stdenv.hostPlatform.isDarwin then
86 ''
87 mkdir -p $out/{Applications,bin}
88 mv Source/Dexed_artefacts/Release/Standalone/Dexed.app $out/Applications/
89 ln -s $out/{Applications/Dexed.app/Contents/MacOS,bin}/Dexed
90 ''
91 else
92 ''
93 install -Dm755 {Source/Dexed_artefacts/Release/Standalone,$out/bin}/Dexed
94 ''
95 )
96 + ''
97 mkdir -p ${vst3Dir} ${clapDir}
98 mv Source/Dexed_artefacts/Release/VST3/* ${vst3Dir}
99 mv Source/Dexed_artefacts/Release/CLAP/* ${clapDir}
100 ''
101 + lib.optionalString stdenv.hostPlatform.isDarwin ''
102 mkdir -p ${auDir}
103 mv Source/Dexed_artefacts/Release/AU/* ${auDir}
104 ''
105 + ''
106
107 runHook postInstall
108 '';
109
110 passthru.updateScript = gitUpdater { rev-prefix = "v"; };
111
112 meta = {
113 description = "DX7 FM multi platform/multi format plugin";
114 mainProgram = "Dexed";
115 homepage = "https://asb2m10.github.io/dexed";
116 license = lib.licenses.gpl3Only;
117 platforms = lib.platforms.all;
118 maintainers = with lib.maintainers; [ OPNA2608 ];
119 };
120})