fire: Modernise, nixfmt

This commit is contained in:
OPNA2608 2024-11-22 17:01:50 +01:00
parent b8c9d52b84
commit f5afe5b452

View File

@ -1,21 +1,22 @@
{ stdenv
, lib
, fetchFromGitHub
, unstableGitUpdater
, catch2_3
, cmake
, pkg-config
, libX11
, libXrandr
, libXinerama
, libXext
, libXcursor
, freetype
, alsa-lib
, apple-sdk_11
{
stdenv,
lib,
fetchFromGitHub,
unstableGitUpdater,
catch2_3,
cmake,
pkg-config,
libX11,
libXrandr,
libXinerama,
libXext,
libXcursor,
freetype,
alsa-lib,
apple-sdk_11,
}:
stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
pname = "fire";
version = "1.0.1-unstable-2024-10-22";
@ -27,20 +28,23 @@ stdenv.mkDerivation rec {
hash = "sha256-DyYP/uDawa+m2FtNvEvu36iRl6zfMyGNMMad5f/rX4k=";
};
postPatch = ''
# Disable automatic copying of built plugins during buildPhase, it defaults
# into user home and we want to have building & installing separated.
substituteInPlace CMakeLists.txt \
--replace-fail 'COPY_PLUGIN_AFTER_BUILD TRUE' 'COPY_PLUGIN_AFTER_BUILD FALSE'
'' + lib.optionalString stdenv.hostPlatform.isLinux ''
# Remove hardcoded LTO flags: needs extra setup on Linux
substituteInPlace CMakeLists.txt \
--replace-fail 'juce::juce_recommended_lto_flags' '# Not forcing LTO'
'' + lib.optionalString (!doCheck) ''
substituteInPlace CMakeLists.txt \
--replace-fail 'include(Tests)' '# Not building tests' \
--replace-fail 'include(Benchmarks)' '# Not building benchmark test'
'';
postPatch =
''
# Disable automatic copying of built plugins during buildPhase, it defaults
# into user home and we want to have building & installing separated.
substituteInPlace CMakeLists.txt \
--replace-fail 'COPY_PLUGIN_AFTER_BUILD TRUE' 'COPY_PLUGIN_AFTER_BUILD FALSE'
''
+ lib.optionalString stdenv.hostPlatform.isLinux ''
# Remove hardcoded LTO flags: needs extra setup on Linux
substituteInPlace CMakeLists.txt \
--replace-fail 'juce::juce_recommended_lto_flags' '# Not forcing LTO'
''
+ lib.optionalString (!finalAttrs.finalPackage.doCheck) ''
substituteInPlace CMakeLists.txt \
--replace-fail 'include(Tests)' '# Not building tests' \
--replace-fail 'include(Benchmarks)' '# Not building benchmark test'
'';
strictDeps = true;
@ -49,53 +53,77 @@ stdenv.mkDerivation rec {
pkg-config
];
buildInputs = lib.optionals stdenv.hostPlatform.isLinux [
libX11
libXrandr
libXinerama
libXext
libXcursor
freetype
alsa-lib
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
apple-sdk_11
];
buildInputs =
lib.optionals stdenv.hostPlatform.isLinux [
libX11
libXrandr
libXinerama
libXext
libXcursor
freetype
alsa-lib
]
++ lib.optionals stdenv.hostPlatform.isDarwin [ apple-sdk_11 ];
cmakeFlags = [
(lib.cmakeBool "FETCHCONTENT_FULLY_DISCONNECTED" true)
(lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_CATCH2" "${catch2_3.src}")
];
installPhase = let
pathMappings = [
{ from = "LV2"; to = "${placeholder "out"}/${if stdenv.hostPlatform.isDarwin then "Library/Audio/Plug-Ins/LV2" else "lib/lv2"}"; }
{ from = "VST3"; to = "${placeholder "out"}/${if stdenv.hostPlatform.isDarwin then "Library/Audio/Plug-Ins/VST3" else "lib/vst3"}"; }
# this one's a guess, don't know where ppl have agreed to put them yet
{ from = "CLAP"; to = "${placeholder "out"}/${if stdenv.hostPlatform.isDarwin then "Library/Audio/Plug-Ins/CLAP" else "lib/clap"}"; }
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
{ from = "AU"; to = "${placeholder "out"}/Library/Audio/Plug-Ins/Components"; }
];
in ''
runHook preInstall
installPhase =
let
pathMappings =
[
{
from = "LV2";
to = "${placeholder "out"}/${
if stdenv.hostPlatform.isDarwin then "Library/Audio/Plug-Ins/LV2" else "lib/lv2"
}";
}
{
from = "VST3";
to = "${placeholder "out"}/${
if stdenv.hostPlatform.isDarwin then "Library/Audio/Plug-Ins/VST3" else "lib/vst3"
}";
}
# this one's a guess, don't know where ppl have agreed to put them yet
{
from = "CLAP";
to = "${placeholder "out"}/${
if stdenv.hostPlatform.isDarwin then "Library/Audio/Plug-Ins/CLAP" else "lib/clap"
}";
}
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
{
from = "AU";
to = "${placeholder "out"}/Library/Audio/Plug-Ins/Components";
}
];
in
''
runHook preInstall
'' + lib.strings.concatMapStringsSep "\n" (entry: ''
mkdir -p ${entry.to}
# Exact path of the build artefact depends on used CMAKE_BUILD_TYPE
cp -r Fire_artefacts/*/${entry.from}/* ${entry.to}/
'') pathMappings + ''
''
+ lib.strings.concatMapStringsSep "\n" (entry: ''
mkdir -p ${entry.to}
# Exact path of the build artefact depends on used CMAKE_BUILD_TYPE
cp -r Fire_artefacts/*/${entry.from}/* ${entry.to}/
'') pathMappings
+ ''
runHook postInstall
'';
runHook postInstall
'';
doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
passthru.updateScript = unstableGitUpdater { tagPrefix = "v"; };
meta = with lib; {
meta = {
description = "Multi-band distortion plugin by Wings";
homepage = "https://github.com/jerryuhoo/Fire";
license = licenses.agpl3Only; # Not clarified if Only or Plus
platforms = platforms.unix;
maintainers = with maintainers; [ OPNA2608 ];
license = lib.licenses.agpl3Only; # Not clarified if Only or Plus
platforms = lib.platforms.unix;
maintainers = with lib.maintainers; [ OPNA2608 ];
};
}
})