From dd986e97094766c6e175c5efa59ca59e8217a60f Mon Sep 17 00:00:00 2001 From: Luis Eduardo Bueso de Barrio Date: Sun, 14 Jun 2026 21:22:36 +0200 Subject: [PATCH] audiveris --- README.md | 1 + devshells/default.nix | 14 ++-- overlays/default.nix | 13 +++- pkgs/audiveris/default.nix | 134 ++++++++++++++++++++++++++++++++++ pkgs/default.nix | 1 + pkgs/dolos/default.nix | 106 +++++++++++++-------------- pkgs/eqc/default.nix | 49 ++++++++++--- pkgs/example-a/default.nix | 1 - pkgs/example-b/default.nix | 1 - pkgs/jls/default.nix | 24 +++--- pkgs/pyzotero-cli/default.nix | 3 +- 11 files changed, 260 insertions(+), 87 deletions(-) create mode 100644 pkgs/audiveris/default.nix diff --git a/README.md b/README.md index c9bbaa3..ea1209c 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ A Nix flake exposing custom packages, a development shell, checks, and a nixpkgs | Package | Version | Description | |----------------|---------|--------------------------------------------------------------| +| `audiveris` | 5.10.2 | Open-source Optical Music Recognition (OMR) engine & editor | | `example-a` | 0.1.0 | Example package A | | `example-b` | 0.1.0 | Example package B | | `pyzotero` | 1.6.11 | Python API client for the Zotero API | diff --git a/devshells/default.nix b/devshells/default.nix index 9c54474..b594c12 100644 --- a/devshells/default.nix +++ b/devshells/default.nix @@ -2,14 +2,12 @@ pkgs, }: pkgs.mkShell { - packages = - with pkgs; - [ - nixfmt-rfc-style - nil - nix-tree - nix - ]; + packages = with pkgs; [ + nixfmt-rfc-style + nil + nix-tree + nix + ]; shellHook = '' echo "Nix packages development environment" diff --git a/overlays/default.nix b/overlays/default.nix index f0d35cb..c264017 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -3,5 +3,16 @@ let packages = import ../pkgs { pkgs = prev; }; in { - inherit (packages) example-a example-b pyzotero pyzotero-cli khal-export org-zotero-export jls harper-ls eqc; + inherit (packages) + audiveris + example-a + example-b + pyzotero + pyzotero-cli + khal-export + org-zotero-export + jls + harper-ls + eqc + ; } diff --git a/pkgs/audiveris/default.nix b/pkgs/audiveris/default.nix new file mode 100644 index 0000000..7a0a369 --- /dev/null +++ b/pkgs/audiveris/default.nix @@ -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' + + + + @dejavu@/share/fonts/truetype + /usr/share/fonts + ~/.cache/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" ]; + }; +} diff --git a/pkgs/default.nix b/pkgs/default.nix index ff1331f..a72de11 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -3,6 +3,7 @@ }: let self = { + audiveris = pkgs.callPackage ./audiveris { }; dolos = pkgs.callPackage ./dolos { nodejs = pkgs.nodejs_22; }; eqc = pkgs.callPackage ./eqc { }; example-a = pkgs.callPackage ./example-a { }; diff --git a/pkgs/dolos/default.nix b/pkgs/dolos/default.nix index f7f4db0..22f0289 100644 --- a/pkgs/dolos/default.nix +++ b/pkgs/dolos/default.nix @@ -48,65 +48,65 @@ buildNpmPackage rec { ''; preBuild = '' - cp -r ${tree-sitter-elixir} parsers/elixir - chmod -R u+w parsers/elixir + cp -r ${tree-sitter-elixir} parsers/elixir + chmod -R u+w parsers/elixir - cat > parsers/elixir/binding.gyp << 'GYPEOF' -{ - "targets": [ + cat > parsers/elixir/binding.gyp << 'GYPEOF' { - "target_name": "tree_sitter_elixir_binding", - "dependencies": [ - " parsers/binding.gyp << 'GYPEOF' -{ - "includes": [ - "bash/binding.gyp", - "c/binding.gyp", - "cpp/binding.gyp", - "c_sharp/binding.gyp", - "elm/binding.gyp", - "elixir/binding.gyp", - "go/binding.gyp", - "groovy/binding.gyp", - "java/binding.gyp", - "javascript/binding.gyp", - "modelica/binding.gyp", - "ocaml/binding.gyp", - "php/binding.gyp", - "python/binding.gyp", - "r/binding.gyp", - "rust/binding.gyp", - "scala/binding.gyp", - "sql/binding.gyp", - "typescript/binding.gyp", - "verilog/binding.gyp" - ] -} -GYPEOF + cat > parsers/binding.gyp << 'GYPEOF' + { + "includes": [ + "bash/binding.gyp", + "c/binding.gyp", + "cpp/binding.gyp", + "c_sharp/binding.gyp", + "elm/binding.gyp", + "elixir/binding.gyp", + "go/binding.gyp", + "groovy/binding.gyp", + "java/binding.gyp", + "javascript/binding.gyp", + "modelica/binding.gyp", + "ocaml/binding.gyp", + "php/binding.gyp", + "python/binding.gyp", + "r/binding.gyp", + "rust/binding.gyp", + "scala/binding.gyp", + "sql/binding.gyp", + "typescript/binding.gyp", + "verilog/binding.gyp" + ] + } + GYPEOF - sed -i '/^parsers.verilog/a \ -parsers.elixir = require("./build/Release/tree_sitter_elixir_binding");\ -parsers.elixir.nodeTypeInfo = require("./elixir/src/node-types.json"); -' parsers/index.js + sed -i '/^parsers.verilog/a \ + parsers.elixir = require("./build/Release/tree_sitter_elixir_binding");\ + parsers.elixir.nodeTypeInfo = require("./elixir/src/node-types.json"); + ' parsers/index.js - npm run build -w parsers + npm run build -w parsers ''; buildPhase = '' diff --git a/pkgs/eqc/default.nix b/pkgs/eqc/default.nix index 53e9910..dbbe300 100644 --- a/pkgs/eqc/default.nix +++ b/pkgs/eqc/default.nix @@ -7,17 +7,46 @@ }: let versions = { - "28" = { eqcVersion = "1.48.3"; hash = "sha256-qWV8lsBGwCcrdgJdgpL2Blj3BU92NTfIFy3AkmkcR8o="; }; - "27" = { eqcVersion = "1.48.3"; hash = "sha256-Y/JgElZkRtIP139/f+fmTESerMlFK3g++8lyNDLuBM8="; }; - "26" = { eqcVersion = "1.48.1"; hash = "sha256-Acnm74iEEpdwYDJzFo0cBZd4DH9y9jXFtgKmodUHzBM="; }; - "25" = { eqcVersion = "1.46.2"; hash = "sha256-oGclmRf15XpdO6J9CVIiC4rF9mq84r1C7nbvve4Qgrw="; }; - "24" = { eqcVersion = "1.46.1"; hash = "sha256-crofH7OZ35Xs2JT9uONBO2YmCjTNaELkJ+dGfiGSM9c="; }; - "23" = { eqcVersion = "1.45.1"; hash = "sha256-ifObOCNvQQniQFG9jf8FkMNYT2NhH6K12AX/D14rttY="; }; - "22" = { eqcVersion = "1.45.1"; hash = "sha256-iIxI+UavRpbXWRcI6u50SX6PGzL5ZZ918rhLKyJFHqg="; }; - "21" = { eqcVersion = "1.45.1"; hash = "sha256-k57376cDfStG72Jue6sDP830lTiIkCuPsSjf2kQ4="; }; - "20" = { eqcVersion = "1.45.1"; hash = "sha256-Bi5nccILoJidDCHb7TK+Ha+YV2FRYZFiNVJ3WZFMCr0="; }; + "28" = { + eqcVersion = "1.48.3"; + hash = "sha256-qWV8lsBGwCcrdgJdgpL2Blj3BU92NTfIFy3AkmkcR8o="; + }; + "27" = { + eqcVersion = "1.48.3"; + hash = "sha256-Y/JgElZkRtIP139/f+fmTESerMlFK3g++8lyNDLuBM8="; + }; + "26" = { + eqcVersion = "1.48.1"; + hash = "sha256-Acnm74iEEpdwYDJzFo0cBZd4DH9y9jXFtgKmodUHzBM="; + }; + "25" = { + eqcVersion = "1.46.2"; + hash = "sha256-oGclmRf15XpdO6J9CVIiC4rF9mq84r1C7nbvve4Qgrw="; + }; + "24" = { + eqcVersion = "1.46.1"; + hash = "sha256-crofH7OZ35Xs2JT9uONBO2YmCjTNaELkJ+dGfiGSM9c="; + }; + "23" = { + eqcVersion = "1.45.1"; + hash = "sha256-ifObOCNvQQniQFG9jf8FkMNYT2NhH6K12AX/D14rttY="; + }; + "22" = { + eqcVersion = "1.45.1"; + hash = "sha256-iIxI+UavRpbXWRcI6u50SX6PGzL5ZZ918rhLKyJFHqg="; + }; + "21" = { + eqcVersion = "1.45.1"; + hash = "sha256-k57376cDfStG72Jue6sDP830lTiIkCuPsSjf2kQ4="; + }; + "20" = { + eqcVersion = "1.45.1"; + hash = "sha256-Bi5nccILoJidDCHb7TK+Ha+YV2FRYZFiNVJ3WZFMCr0="; + }; }; - cfg = versions.${erlangVersion} or (throw "Unsupported Erlang/OTP version: ${erlangVersion}. Supported: ${builtins.concatStringsSep ", " (builtins.attrNames versions)}"); + cfg = + versions.${erlangVersion} + or (throw "Unsupported Erlang/OTP version: ${erlangVersion}. Supported: ${builtins.concatStringsSep ", " (builtins.attrNames versions)}"); in stdenv.mkDerivation { name = "eqc"; diff --git a/pkgs/example-a/default.nix b/pkgs/example-a/default.nix index 3148dc8..3b68dee 100644 --- a/pkgs/example-a/default.nix +++ b/pkgs/example-a/default.nix @@ -1,4 +1,3 @@ - { lib, stdenv, diff --git a/pkgs/example-b/default.nix b/pkgs/example-b/default.nix index 5bdca4f..8cd5d6f 100644 --- a/pkgs/example-b/default.nix +++ b/pkgs/example-b/default.nix @@ -1,4 +1,3 @@ - { lib, stdenv, diff --git a/pkgs/jls/default.nix b/pkgs/jls/default.nix index 1eb73d9..f3e3fa1 100644 --- a/pkgs/jls/default.nix +++ b/pkgs/jls/default.nix @@ -59,22 +59,22 @@ maven.buildMavenPackage rec { ]; in '' - runHook preInstall + runHook preInstall - mkdir -p $out/share/jls $out/bin + mkdir -p $out/share/jls $out/bin - cp dist/classpath/*.jar $out/share/jls/ + cp dist/classpath/*.jar $out/share/jls/ - cat > $out/bin/jls <<'WRAPPER' -#!/bin/sh -exec @java@ ${jvmFlags} -classpath "@classpath@" org.javacs.Main "$@" -WRAPPER - chmod +x $out/bin/jls - substituteInPlace $out/bin/jls \ - --replace-fail "@java@" "${jdk}/bin/java" \ - --replace-fail "@classpath@" "$out/share/jls/*" + cat > $out/bin/jls <<'WRAPPER' + #!/bin/sh + exec @java@ ${jvmFlags} -classpath "@classpath@" org.javacs.Main "$@" + WRAPPER + chmod +x $out/bin/jls + substituteInPlace $out/bin/jls \ + --replace-fail "@java@" "${jdk}/bin/java" \ + --replace-fail "@classpath@" "$out/share/jls/*" - runHook postInstall + runHook postInstall ''; meta = { diff --git a/pkgs/pyzotero-cli/default.nix b/pkgs/pyzotero-cli/default.nix index 2e4ef1f..282249e 100644 --- a/pkgs/pyzotero-cli/default.nix +++ b/pkgs/pyzotero-cli/default.nix @@ -22,7 +22,8 @@ python3Packages.buildPythonApplication rec { dependencies = [ pyzotero - ] ++ (with python3Packages; [ + ] + ++ (with python3Packages; [ click pyyaml tabulate