tuxguitar: build from source, add darwin support, update to 2.0.1 (#458083)

This commit is contained in:
Doron Behar
2026-02-02 10:34:35 +00:00
committed by GitHub
2 changed files with 218 additions and 39 deletions
@@ -0,0 +1,24 @@
diff -Naur tuxguitar/desktop/TuxGuitar-synth-lv2/src/main/cxx/LV2.h tuxguitar-patched/desktop/TuxGuitar-synth-lv2/src/main/cxx/LV2.h
--- tuxguitar/desktop/TuxGuitar-synth-lv2/src/main/cxx/LV2.h 2025-11-03 22:30:10.315511003 +1100
+++ tuxguitar-patched/desktop/TuxGuitar-synth-lv2/src/main/cxx/LV2.h 2025-11-03 22:36:06.444389423 +1100
@@ -1,7 +1,7 @@
#ifndef _Included_LV2
#define _Included_LV2
-#include <lilv.h>
+#include <lilv-0/lilv/lilv.h>
#include <lv2/lv2plug.in/ns/extensions/ui/ui.h>
#include <lv2/lv2plug.in/ns/ext/state/state.h>
#include <lv2/lv2plug.in/ns/ext/options/options.h>
diff -Naur tuxguitar/desktop/TuxGuitar-synth-lv2/src/main/cxx/LV2UI.h tuxguitar-patched/desktop/TuxGuitar-synth-lv2/src/main/cxx/LV2UI.h
--- tuxguitar/desktop/TuxGuitar-synth-lv2/src/main/cxx/LV2UI.h 2025-11-03 22:30:10.315511003 +1100
+++ tuxguitar-patched/desktop/TuxGuitar-synth-lv2/src/main/cxx/LV2UI.h 2025-11-03 22:39:40.376479709 +1100
@@ -1,7 +1,7 @@
#ifndef _Included_LV2UI
#define _Included_LV2UI
-#include <suil.h>
+#include <suil-0/suil/suil.h>
void LV2UI_malloc(LV2UI **handle, LV2Feature *feature, LV2Instance *instance, LV2Lock* lock);
+194 -39
View File
@@ -1,70 +1,223 @@
{
lib,
stdenv,
fetchurl,
fetchFromGitHub,
maven,
swt,
jdk,
jre,
makeWrapper,
makeBinaryWrapper,
pkg-config,
alsa-lib,
jack2,
fluidsynth,
libpulseaudio,
lilv,
suil,
qt5,
which,
wrapGAppsHook3,
nixosTests,
fetchpatch,
}:
stdenv.mkDerivation (finalAttrs: {
version = "1.6.6";
let
swtArtifactId =
"org.eclipse.swt." + (if stdenv.hostPlatform.isDarwin then "cocoa.macosx" else "gtk.linux");
buildDir =
"desktop/build-scripts/tuxguitar-"
+ (if stdenv.hostPlatform.isDarwin then "macosx-swt-cocoa" else "linux-swt");
buildScript = "${buildDir}/pom.xml";
mvnParams = lib.escapeShellArgs [
"-f"
buildScript
"-P"
"native-modules"
"-Dmaven.test.skip=true"
];
ldLibVar = if stdenv.hostPlatform.isDarwin then "DYLD_LIBRARY_PATH" else "LD_LIBRARY_PATH";
classpath = [
"${swt}/jars/swt.jar"
]
++ lib.optionals stdenv.hostPlatform.isLinux [
"$out/lib/tuxguitar.jar"
"$out/lib/itext.jar"
];
libraryPath = [
"$out/lib"
fluidsynth
lilv
]
++ lib.optionals stdenv.hostPlatform.isLinux [
swt
alsa-lib
jack2
libpulseaudio
];
wrapperPaths = [
jre
which
];
# FIXME: Makes hash stable across platforms and convert to a single hash.
mvnHashByPlatform = {
"x86_64-linux" = "sha256-7UDFGuOMERvY74mkneusJyuAHfF3U6b4qV4MPHGQYdM=";
"aarch64-linux" = "sha256-7UDFGuOMERvY74mkneusJyuAHfF3U6b4qV4MPHGQYdM=";
"aarch64-darwin" = "sha256-lfO2YH+yKZWzh3MeQ7baESGmmW7zPdTLs8CjZ/FtLu0=";
};
wrapperArgs = [
"\${gappsWrapperArgs[@]}"
"--prefix"
"PATH"
":"
(lib.makeBinPath wrapperPaths)
"--prefix"
ldLibVar
":"
(lib.makeLibraryPath libraryPath)
"--prefix"
"CLASSPATH"
":"
(lib.concatStringsSep ":" classpath)
];
version = "2.0.1";
in
maven.buildMavenPackage {
pname = "tuxguitar";
inherit version;
src = fetchurl {
url = "https://github.com/helge17/tuxguitar/releases/download/${finalAttrs.version}/tuxguitar-${finalAttrs.version}-linux-swt-amd64.tar.gz";
hash = "sha256-kfPk+IIg5Q4Fc9HMS0kxxCarlbJjVKluIvz8KpDjJLM=";
src = fetchFromGitHub {
owner = "helge17";
repo = "tuxguitar";
tag = version;
hash = "sha256-USdYj8ebosXkiZpDqyN5J+g1kjyWm225iQlx/szXmLA=";
};
patches = [
./fix-include.patch
# Helps a little bit with https://github.com/helge17/tuxguitar/issues/961
(fetchpatch {
name = "create-new-file";
url = "https://github.com/helge17/tuxguitar/commit/3dc828a9b92e932952c2b33d8ee41db734f2fcc0.patch";
hash = "sha256-umZlCSCTWqj3tgR+qFcPucEDv5vpaC6zHbDJg/W5KUI=";
})
];
buildOffline = true;
mvnJdk = jdk;
mvnHash = (
mvnHashByPlatform.${stdenv.system}
or (lib.warn "Missing mvnHash for ${stdenv.system}, using lib.fakeHash" lib.fakeHash)
);
mvnParameters = mvnParams;
mvnDepsParameters = mvnParams;
mvnFetchExtraArgs = {
dontWrapQtApps = true;
dontWrapGApps = true;
preBuild = ''
mkdir -p $out/.m2
mvn install:install-file \
-Dfile=${swt}/jars/swt.jar \
-DgroupId=org.eclipse.swt \
-DartifactId=${swtArtifactId} \
-Dpackaging=jar \
-Dversion=4.36 \
-Dmaven.repo.local=$out/.m2
'';
postInstall = ''
rm -rf $out/.m2/repository/org/eclipse/swt
find $out -type f -name "maven-metadata-*.xml" -delete
'';
};
afterDepsSetup = ''
mvn install:install-file \
-Dfile=${swt}/jars/swt.jar \
-DgroupId=org.eclipse.swt \
-DartifactId=${swtArtifactId} \
-Dpackaging=jar \
-Dversion=4.36 \
-Dmaven.repo.local=$mvnDeps/.m2
'';
nativeBuildInputs = [
makeWrapper
makeBinaryWrapper
jdk
pkg-config
]
++ lib.optionals stdenv.hostPlatform.isLinux [
wrapGAppsHook3
];
buildInputs = [
swt
fluidsynth
lilv
]
++ lib.optionals stdenv.hostPlatform.isLinux [
alsa-lib
jack2
libpulseaudio
suil
qt5.qtbase
];
dontWrapQtApps = true;
dontWrapGApps = true;
installPhase = ''
runHook preInstall
cd ${buildDir}
''
# macOS: The build creates tuxguitar-VERSION-macosx-swt-cocoa.app directly
# This directory name already ends with .app and IS the app bundle
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
mkdir -p $out/Applications
cp -r target/tuxguitar-9.99-SNAPSHOT-macosx-swt-cocoa.app $out/Applications/TuxGuitar.app
# Fix the launch script to use the Nix JRE instead of bundled JRE
substituteInPlace $out/Applications/TuxGuitar.app/Contents/MacOS/tuxguitar.sh \
--replace-fail 'JAVA="./jre/bin/java"' 'JAVA="${jre}/bin/java"'
# Ensure the main executable has execute permissions
chmod +x $out/Applications/TuxGuitar.app/Contents/MacOS/tuxguitar.sh
# Symlink doesn't work. We have to create a wrapper script instead
mkdir -p $out/bin
cp -r dist lib share $out/
cp tuxguitar.sh $out/bin/tuxguitar
makeWrapper "$out/Applications/TuxGuitar.app/Contents/MacOS/tuxguitar.sh" \
"$out/bin/tuxguitar"
''
# Linux: Install traditional layout
+ lib.optionalString stdenv.hostPlatform.isLinux ''
TUXGUITAR_DIR=target/tuxguitar-9.99-SNAPSHOT-linux-swt
mkdir -p $out/{bin,lib}
cp -r $TUXGUITAR_DIR $out/lib/tuxguitar
ln -s $out/lib/tuxguitar/tuxguitar.sh $out/bin/tuxguitar
ln -s $out/dist $out/bin/dist
ln -s $out/lib $out/bin/lib
ln -s $out/share $out/bin/share
mkdir -p $out/share
ln -s $out/lib/tuxguitar/share/{applications,man,metainfo,mime,pixmaps} -t $out/share/
# See https://github.com/helge17/tuxguitar/issues/961
mkdir -p $out/share/templates/.source
ln -s $out/lib/tuxguitar/share/templates/ $out/share/templates/.source/tuxguitar
cp /build/source/desktop/build-scripts/common-resources/common-linux/share/templates/tuxguitar.desktop $out/share/templates/
''
+ ''
runHook postInstall
'';
postFixup = ''
wrapProgram $out/bin/tuxguitar \
"''${gappsWrapperArgs[@]}" \
--prefix PATH : ${
lib.makeBinPath [
jre
which
]
} \
--prefix LD_LIBRARY_PATH : "$out/lib/:${
lib.makeLibraryPath [
swt
alsa-lib
jack2
fluidsynth
libpulseaudio
lilv
]
}" \
--prefix CLASSPATH : "${swt}/jars/swt.jar:$out/lib/tuxguitar.jar:$out/lib/itext.jar"
postFixup = lib.optionalString stdenv.hostPlatform.isLinux ''
wrapProgram $out/bin/tuxguitar ${lib.concatStringsSep " " wrapperArgs}
'';
passthru.tests = {
nixos = nixosTests.tuxguitar;
passthru = {
tests.nixos = nixosTests.tuxguitar;
};
meta = {
@@ -74,10 +227,12 @@ stdenv.mkDerivation (finalAttrs: {
in Java-SWT. It can open GuitarPro, PowerTab and TablEdit files.
'';
homepage = "https://github.com/helge17/tuxguitar";
sourceProvenance = with lib.sourceTypes; [ binaryBytecode ];
license = lib.licenses.lgpl21Plus;
maintainers = with lib.maintainers; [ ardumont ];
platforms = [ "x86_64-linux" ];
maintainers = with lib.maintainers; [
ardumont
mio
];
platforms = builtins.attrNames mvnHashByPlatform;
mainProgram = "tuxguitar";
};
})
}