tenacity: add darwin support

This commit is contained in:
Niklas Korz
2025-07-03 15:54:28 +02:00
parent 28db7596a9
commit 68c5024601
+45 -15
View File
@@ -3,6 +3,7 @@
lib,
fetchFromGitea,
cmake,
ninja,
wxGTK32,
gtk3,
pkg-config,
@@ -60,16 +61,42 @@ stdenv.mkDerivation (finalAttrs: {
hash = "sha256-2gndOwgEJK2zDSbjcZigbhEpGv301/ygrf+EQhKp8PI=";
};
postPatch = ''
mkdir -p build/src/private
touch build/src/private/RevisionIdent.h
postPatch =
''
# GIT_DESCRIBE is used for the version string and can't be passed in
# as an option, so we substitute it instead.
substituteInPlace CMakeLists.txt \
--replace-fail 'set( GIT_DESCRIBE "unknown" )' 'set( GIT_DESCRIBE "${finalAttrs.version}" )'
''
+ lib.optionalString stdenv.hostPlatform.isLinux ''
substituteInPlace libraries/lib-files/FileNames.cpp \
--replace-fail /usr/include/linux/magic.h ${linuxHeaders}/include/linux/magic.h
''
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
# Tenacity has special handling for ffmpeg library search on darwin,
# looking only in a few specific directories.
# Make sure it searches for our version of ffmpeg in the nix store.
substituteInPlace libraries/lib-ffmpeg-support/FFmpegFunctions.cpp \
--replace-fail /usr/local/lib/tenacity ${lib.getLib ffmpeg}/lib
'';
substituteInPlace libraries/lib-files/FileNames.cpp \
--replace /usr/include/linux/magic.h \
${linuxHeaders}/include/linux/magic.h
postInstall = lib.optionalString stdenv.hostPlatform.isDarwin ''
mkdir $out/{bin,Applications}
mv $out/{,Applications/}Tenacity.app
# Symlinking the binary is insufficient as it would be unable to
# find the bundle resources
cat << EOF > "$out/bin/tenacity"
#!${stdenv.shell}
open -na "$out/Applications/Tenacity.app" --args "\$@"
EOF
chmod +x "$out/bin/tenacity"
# Only contains a static library that is already linked into the tenacity binary
rm -r $out/lib
'';
postFixup = ''
postFixup = lib.optionalString stdenv.hostPlatform.isLinux ''
wrapProgram "$out/bin/tenacity" \
--suffix AUDACITY_PATH : "$out/share/tenacity" \
--suffix AUDACITY_MODULES_PATH : "$out/lib/tenacity/modules" \
@@ -77,10 +104,9 @@ stdenv.mkDerivation (finalAttrs: {
--prefix XDG_DATA_DIRS : "$out/share:$GSETTINGS_SCHEMAS_PATH"
'';
env.NIX_CFLAGS_COMPILE = "-D GIT_DESCRIBE=\"\"";
# tenacity only looks for ffmpeg at runtime, so we need to link it in manually
NIX_LDFLAGS = toString [
# Tenacity only looks for ffmpeg at runtime, so we need to link it in manually.
# On darwin, these are ignored by the ffmpeg search even when linked.
NIX_LDFLAGS = lib.optionalString stdenv.hostPlatform.isLinux (toString [
"-lavcodec"
"-lavdevice"
"-lavfilter"
@@ -89,23 +115,23 @@ stdenv.mkDerivation (finalAttrs: {
"-lpostproc"
"-lswresample"
"-lswscale"
];
]);
nativeBuildInputs =
[
cmake
ninja
gettext
makeWrapper
pkg-config
python3
]
++ lib.optionals stdenv.hostPlatform.isLinux [
makeWrapper
linuxHeaders
];
buildInputs =
[
alsa-lib
expat
ffmpeg
file
@@ -134,6 +160,7 @@ stdenv.mkDerivation (finalAttrs: {
gtk3
]
++ lib.optionals stdenv.hostPlatform.isLinux [
alsa-lib
at-spi2-core
dbus
libepoxy
@@ -149,6 +176,9 @@ stdenv.mkDerivation (finalAttrs: {
cmakeFlags = [
# RPATH of binary /nix/store/.../bin/... contains a forbidden reference to /build/
"-DCMAKE_SKIP_BUILD_RPATH=ON"
# Disabled by default on Linux but enabled on Darwin, so we disable it explicitly for all platforms,
# as we provide dependencies from nixpkgs regardless of the target platform.
"-DVCPKG=OFF"
];
meta = {
@@ -157,6 +187,6 @@ stdenv.mkDerivation (finalAttrs: {
homepage = "https://tenacityaudio.org/";
license = lib.licenses.gpl2Plus;
maintainers = with lib.maintainers; [ irenes ];
platforms = lib.platforms.linux;
platforms = lib.platforms.unix;
};
})