audiveris
CI / Nix Flake Check (push) Successful in 53s
CI / Build Packages (default) (push) Successful in 50s
CI / Build Packages (example-b) (push) Successful in 45s
CI / Build Packages (example-a) (push) Successful in 46s
CI / Build Packages (pyzotero) (push) Successful in 55s
CI / Build Packages (pyzotero-cli) (push) Successful in 56s

This commit is contained in:
2026-06-14 21:22:36 +02:00
parent 7a33b2aa3e
commit dd986e9709
11 changed files with 260 additions and 87 deletions
+134
View File
@@ -0,0 +1,134 @@
{
lib,
stdenv,
fetchurl,
dpkg,
unzip,
zip,
patchelf,
autoPatchelfHook,
makeWrapper,
alsa-lib,
freetype,
fontconfig,
libGL,
dejavu_fonts,
xorg,
}:
let
ccLib = stdenv.cc.cc.lib;
in
stdenv.mkDerivation rec {
pname = "audiveris";
version = "5.10.2";
src = fetchurl {
url = "https://github.com/Audiveris/audiveris/releases/download/${version}/Audiveris-${version}-ubuntu24.04-x86_64.deb";
hash = "sha256-ytufr8C+IocYwvvvLoAuBHhyQRUDmHFCUbAMUeMbUZg=";
};
# The .deb bundles its own JRE and the Tesseract/Leptonica native libs (via
# JavaCPP); we only supply the GUI/system runtime libs those binaries load.
nativeBuildInputs = [
dpkg
unzip
zip
patchelf
autoPatchelfHook
makeWrapper
];
buildInputs = [
ccLib
alsa-lib
freetype
fontconfig
libGL
dejavu_fonts
xorg.libX11
xorg.libXext
xorg.libXrender
xorg.libXtst
xorg.libXi
];
dontBuild = true;
unpackPhase = ''
runHook preUnpack
dpkg-deb -x $src .
runHook postUnpack
'';
installPhase = ''
runHook preInstall
mkdir -p $out/opt $out/bin
cp -r opt/audiveris $out/opt/
# Java AWT initializes its font subsystem (and fontconfig) even in batch
# mode, so ship a fontconfig file pointing at a bundled font. Without this,
# the JVM dies with "Fontconfig head is null".
mkdir -p $out/etc/fonts
cat > $out/etc/fonts/fonts.conf <<'CONF'
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<dir>@dejavu@/share/fonts/truetype</dir>
<dir>/usr/share/fonts</dir>
<cachedir>~/.cache/fontconfig</cachedir>
</fontconfig>
CONF
substituteInPlace $out/etc/fonts/fonts.conf \
--replace-fail "@dejavu@" "${dejavu_fonts}"
# The jpackage launcher derives its layout from its own path, so relocating
# /opt/audiveris -> $out/opt/audiveris needs no path rewriting. The bundled
# JRE dlopens libfontconfig/libfreetype at runtime (not a NEEDED dep), so we
# put the runtime libs on the loader path.
makeWrapper $out/opt/audiveris/bin/Audiveris $out/bin/audiveris \
--set FONTCONFIG_FILE "$out/etc/fonts/fonts.conf" \
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath buildInputs}"
# Desktop integration with relocated paths (source .desktop ships in the deb).
mkdir -p $out/share/applications $out/share/icons/hicolor/256x256/apps
cp $out/opt/audiveris/lib/Audiveris.png \
$out/share/icons/hicolor/256x256/apps/audiveris.png
substitute $out/opt/audiveris/lib/audiveris-Audiveris.desktop \
$out/share/applications/audiveris.desktop \
--replace-fail "/opt/audiveris/bin/Audiveris" "$out/bin/audiveris" \
--replace-fail "/opt/audiveris/lib/Audiveris.png" \
"$out/share/icons/hicolor/256x256/apps/audiveris.png"
runHook postInstall
'';
# Tesseract/Leptonica native libs are zipped inside JavaCPP platform jars and
# extracted by JavaCPP at runtime, so autoPatchelfHook cannot reach them. We
# pull them out, bake an RPATH to libstdc++/libgcc_s, and repack the jars.
postInstall = ''
repack_jar() {
local jar="$1"
local tmp
tmp="$(mktemp -d)"
( cd "$tmp" && unzip -o "$jar" >/dev/null )
find "$tmp" -name '*.so*' -type f -print0 \
| xargs -0 -r ${patchelf}/bin/patchelf --add-rpath ${ccLib}/lib 2>/dev/null || true
( cd "$tmp" && zip -r -X "$jar" . >/dev/null )
rm -rf "$tmp"
}
for j in \
$out/opt/audiveris/lib/app/tesseract-5.5.1-1.5.12-linux-x86_64.jar \
$out/opt/audiveris/lib/app/leptonica-1.85.0-1.5.12-linux-x86_64.jar; do
repack_jar "$j"
done
'';
meta = {
description = "Open-source Optical Music Recognition (OMR) engine and editor";
homepage = "https://github.com/Audiveris/audiveris";
license = lib.licenses.agpl3Only;
mainProgram = "audiveris";
platforms = [ "x86_64-linux" ];
};
}