1{
2 stdenv,
3 lib,
4 fetchFromGitHub,
5 unstableGitUpdater,
6 catch2_3,
7 cmake,
8 pkg-config,
9 libX11,
10 libXrandr,
11 libXinerama,
12 libXext,
13 libXcursor,
14 freetype,
15 alsa-lib,
16}:
17
18stdenv.mkDerivation (finalAttrs: {
19 pname = "fire";
20 version = "1.0.1-unstable-2025-03-12";
21
22 src = fetchFromGitHub {
23 owner = "jerryuhoo";
24 repo = "Fire";
25 rev = "b7ded116ce7ab78a57bb9b6b61796cb2cf3a6e8b";
26 fetchSubmodules = true;
27 hash = "sha256-d8w+b4OpU2/kQdcAimR4ihDEgVTM1V7J0hj7saDrQpY=";
28 };
29
30 postPatch = ''
31 # Disable automatic copying of built plugins during buildPhase, it defaults
32 # into user home and we want to have building & installing separated.
33 substituteInPlace CMakeLists.txt \
34 --replace-fail 'COPY_PLUGIN_AFTER_BUILD TRUE' 'COPY_PLUGIN_AFTER_BUILD FALSE'
35 ''
36 + lib.optionalString stdenv.hostPlatform.isLinux ''
37 # Remove hardcoded LTO flags: needs extra setup on Linux
38 substituteInPlace CMakeLists.txt \
39 --replace-fail 'juce::juce_recommended_lto_flags' '# Not forcing LTO'
40 ''
41 + lib.optionalString (!finalAttrs.finalPackage.doCheck) ''
42 substituteInPlace CMakeLists.txt \
43 --replace-fail 'include(Tests)' '# Not building tests' \
44 --replace-fail 'include(Benchmarks)' '# Not building benchmark test'
45 '';
46
47 strictDeps = true;
48
49 nativeBuildInputs = [
50 cmake
51 pkg-config
52 ];
53
54 buildInputs = lib.optionals stdenv.hostPlatform.isLinux [
55 libX11
56 libXrandr
57 libXinerama
58 libXext
59 libXcursor
60 freetype
61 alsa-lib
62 ];
63
64 cmakeFlags = [
65 (lib.cmakeBool "FETCHCONTENT_FULLY_DISCONNECTED" true)
66 (lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_CATCH2" "${catch2_3.src}")
67 ];
68
69 installPhase =
70 let
71 pathMappings = [
72 {
73 from = "LV2";
74 to = "${placeholder "out"}/${
75 if stdenv.hostPlatform.isDarwin then "Library/Audio/Plug-Ins/LV2" else "lib/lv2"
76 }";
77 }
78 {
79 from = "VST3";
80 to = "${placeholder "out"}/${
81 if stdenv.hostPlatform.isDarwin then "Library/Audio/Plug-Ins/VST3" else "lib/vst3"
82 }";
83 }
84 # this one's a guess, don't know where ppl have agreed to put them yet
85 {
86 from = "CLAP";
87 to = "${placeholder "out"}/${
88 if stdenv.hostPlatform.isDarwin then "Library/Audio/Plug-Ins/CLAP" else "lib/clap"
89 }";
90 }
91 ]
92 ++ lib.optionals stdenv.hostPlatform.isDarwin [
93 {
94 from = "AU";
95 to = "${placeholder "out"}/Library/Audio/Plug-Ins/Components";
96 }
97 ];
98 in
99 ''
100 runHook preInstall
101
102 ''
103 + lib.strings.concatMapStringsSep "\n" (entry: ''
104 mkdir -p ${entry.to}
105 # Exact path of the build artefact depends on used CMAKE_BUILD_TYPE
106 cp -r Fire_artefacts/*/${entry.from}/* ${entry.to}/
107 '') pathMappings
108 + ''
109
110 runHook postInstall
111 '';
112
113 doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
114
115 passthru.updateScript = unstableGitUpdater { tagPrefix = "v"; };
116
117 meta = {
118 description = "Multi-band distortion plugin by Wings";
119 homepage = "https://github.com/jerryuhoo/Fire";
120 license = lib.licenses.agpl3Only; # Not clarified if Only or Plus
121 platforms = lib.platforms.unix;
122 maintainers = with lib.maintainers; [ OPNA2608 ];
123 };
124})