nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 stdenv,
3 lib,
4 fetchurl,
5 fetchFromGitHub,
6 runCommand,
7 gitUpdater,
8 catch2_3,
9 cmake,
10 fontconfig,
11 pkg-config,
12 libX11,
13 libXrandr,
14 libXinerama,
15 libXext,
16 libXcursor,
17 freetype,
18 alsa-lib,
19
20 # Only able to test this myself in Linux
21 withStandalone ? stdenv.hostPlatform.isLinux,
22}:
23
24let
25 # Required version, base URL and expected location specified in cmake/CPM.cmake
26 cpmDownloadVersion = "0.40.2";
27 cpmSrc = fetchurl {
28 url = "https://github.com/cpm-cmake/CPM.cmake/releases/download/v${cpmDownloadVersion}/CPM.cmake";
29 hash = "sha256-yM3DLAOBZTjOInge1ylk3IZLKjSjENO3EEgSpcotg10=";
30 };
31 cpmSourceCache = runCommand "cpm-source-cache" { } ''
32 mkdir -p $out/cpm
33 ln -s ${cpmSrc} $out/cpm/CPM_${cpmDownloadVersion}.cmake
34 '';
35
36 pathMappings = [
37 {
38 from = "LV2";
39 to = "${placeholder "out"}/${
40 if stdenv.hostPlatform.isDarwin then "Library/Audio/Plug-Ins/LV2" else "lib/lv2"
41 }";
42 }
43 {
44 from = "VST3";
45 to = "${placeholder "out"}/${
46 if stdenv.hostPlatform.isDarwin then "Library/Audio/Plug-Ins/VST3" else "lib/vst3"
47 }";
48 }
49 # this one's a guess, don't know where ppl have agreed to put them yet
50 {
51 from = "CLAP";
52 to = "${placeholder "out"}/${
53 if stdenv.hostPlatform.isDarwin then "Library/Audio/Plug-Ins/CLAP" else "lib/clap"
54 }";
55 }
56 ]
57 ++ lib.optionals withStandalone [
58 {
59 from = "Standalone";
60 to = "${placeholder "out"}/bin";
61 }
62 ]
63 ++ lib.optionals stdenv.hostPlatform.isDarwin [
64 # Audio Unit is a macOS-specific thing
65 {
66 from = "AU";
67 to = "${placeholder "out"}/Library/Audio/Plug-Ins/Components";
68 }
69 ];
70
71 x11Libs = [
72 libX11
73 libXrandr
74 libXinerama
75 libXext
76 libXcursor
77 ];
78in
79stdenv.mkDerivation (finalAttrs: {
80 pname = "fire";
81 # 1.5.0b is considered a beta release of 1.5.0, but gitUpdater identifies 1.5.0b as the newer version
82 # Sanity checked manually. Drop this once running the updateScript doesn't produce a downgrade.
83 # nixpkgs-update: no auto update
84 version = "1.5.0";
85
86 src = fetchFromGitHub {
87 owner = "jerryuhoo";
88 repo = "Fire";
89 tag = "v${finalAttrs.version}";
90 fetchSubmodules = true;
91 hash = "sha256-i8viPGErCuLSuRWstDtLwQ3XBz9gfiHin7Zvvq8l3kA=";
92 };
93
94 postPatch =
95 let
96 formatsListing = lib.strings.concatMapStringsSep " " (entry: entry.from) pathMappings;
97 in
98 ''
99 # Allow all the formats we can handle
100 # Set LV2URI again for LV2 build
101 # Disable automatic copying of built plugins during buildPhase, it defaults
102 # into user home and we want to have building & installing separated.
103 substituteInPlace CMakeLists.txt \
104 --replace-fail 'set(FORMATS' 'set(FORMATS ${formatsListing}) #' \
105 --replace-fail 'BUNDLE_ID "''${BUNDLE_ID}"' 'BUNDLE_ID "''${BUNDLE_ID}" LV2URI "https://www.bluewingsmusic.com/Fire/"' \
106 --replace-fail 'COPY_PLUGIN_AFTER_BUILD TRUE' 'COPY_PLUGIN_AFTER_BUILD FALSE'
107
108 # Regression tests require big sound files stored in LFS, skip them
109 rm -v tests/RegressionTests.cpp
110 ''
111 + lib.optionalString (!finalAttrs.finalPackage.doCheck) ''
112 substituteInPlace CMakeLists.txt \
113 --replace-fail 'include(Tests)' '# Not building tests' \
114 --replace-fail 'include(Benchmarks)' '# Not building benchmark test'
115 '';
116
117 strictDeps = true;
118
119 nativeBuildInputs = [
120 cmake
121 pkg-config
122 ];
123
124 buildInputs = [
125 catch2_3
126 fontconfig
127 ]
128 ++ lib.optionals stdenv.hostPlatform.isLinux (
129 x11Libs
130 ++ [
131 freetype
132 alsa-lib
133 ]
134 );
135
136 cmakeFlags = [
137 (lib.cmakeFeature "CPM_SOURCE_CACHE" "${cpmSourceCache}")
138 (lib.cmakeBool "CPM_LOCAL_PACKAGES_ONLY" true)
139 (lib.cmakeFeature "Catch2_SOURCE_DIR" "${catch2_3.src}")
140 ];
141
142 env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isLinux (toString [
143 # juce, compiled in this build as part of a Git submodule, uses `-flto` as
144 # a Link Time Optimization flag, and instructs the plugin compiled here to
145 # use this flag to. This breaks the build for us. Using _fat_ LTO allows
146 # successful linking while still providing LTO benefits. If our build of
147 # `juce` was used as a dependency, we could have patched that `-flto` line
148 # in our juce's source, but that is not possible because it is used as a
149 # Git Submodule.
150 "-ffat-lto-objects"
151 ]);
152
153 installPhase = ''
154 runHook preInstall
155
156 ''
157 + lib.strings.concatMapStringsSep "\n" (entry: ''
158 mkdir -p ${entry.to}
159 # Exact path of the build artefact depends on used CMAKE_BUILD_TYPE
160 cp -r -t ${entry.to} Fire_artefacts/${finalAttrs.cmakeBuildType or "Release"}/${entry.from}/*
161 '') pathMappings
162 + ''
163
164 runHook postInstall
165 '';
166
167 doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
168
169 # Standalone dlopen's X11 libraries
170 postFixup = lib.strings.optionalString (withStandalone && stdenv.hostPlatform.isLinux) ''
171 patchelf --add-rpath ${lib.makeLibraryPath x11Libs} $out/bin/Fire
172 '';
173
174 passthru.updateScript = gitUpdater { rev-prefix = "v"; };
175
176 meta = {
177 description = "Multi-band distortion plugin by Wings";
178 homepage = "https://www.bluewingsmusic.com/Fire";
179 license = lib.licenses.agpl3Only; # Not clarified if Only or Plus
180 platforms = lib.platforms.unix;
181 maintainers = with lib.maintainers; [ OPNA2608 ];
182 }
183 // lib.optionalAttrs withStandalone {
184 mainProgram = "Fire";
185 };
186})