opentrack: 2026.1.0-unstable-2026-06-18 -> 2026.1.0-unstable-2026-07-09, add macOS support (#540739)

This commit is contained in:
Peder Bergebakken Sundt
2026-07-14 00:51:30 +00:00
committed by GitHub
2 changed files with 88 additions and 16 deletions
+73 -16
View File
@@ -12,8 +12,11 @@
opencv4,
procps,
eigen,
imagemagick,
libxdmcp,
libevdev,
libicns,
llvmPackages,
makeDesktopItem,
wineWow64Packages,
onnxruntime,
@@ -21,15 +24,18 @@
v4l-utils,
withWine ? stdenv.targetPlatform.isx86_64,
}:
let
inherit (stdenv.hostPlatform) isLinux isDarwin;
in
stdenv.mkDerivation (finalAttrs: {
pname = "opentrack";
version = "2026.1.0-unstable-2026-06-18";
version = "2026.1.0-unstable-2026-07-09";
src = fetchFromGitHub {
owner = "opentrack";
repo = "opentrack";
rev = "3661aa28bb9489a798d9c42eb1c0ccf30876c848";
hash = "sha256-CClUz8g/fSL+NZzikKZuZx4pZsGhIdH70ax6clSG2xk=";
rev = "5ce3de85301c9cdb0e2c2e024f03d94cb42bfd62";
hash = "sha256-k4uAdsEIVYgHPrfl5m2CezQwi4ZGlItgq/e0cHd1TzY=";
};
aruco = callPackage ./aruco.nix { };
@@ -51,6 +57,8 @@ stdenv.mkDerivation (finalAttrs: {
patches = [
# calls `app.setDesktopFileName("opentrack");` - distros that don't wrap the binary apparently don't need this.
./desktop-filename.patch
# disables the upstream macOS .app artifact script
./remove_app_bundle_script.patch
];
strictDeps = true;
@@ -62,40 +70,89 @@ stdenv.mkDerivation (finalAttrs: {
pkg-config
qt6.wrapQtAppsHook
]
++ lib.optionals isDarwin [
libicns
imagemagick
]
++ lib.optionals withWine [ wineWow64Packages.stable ];
buildInputs = [
finalAttrs.aruco
eigen
libxdmcp
libevdev
onnxruntime
opencv4
procps
qt6.qtbase
qt6.qttools
];
]
++ lib.optionals isLinux [
finalAttrs.aruco
libevdev
]
++ lib.optionals isDarwin [
qt6.qtmultimedia
]
# <omp.h> is available-by-default on gcc
++ lib.optionals stdenv.cc.isClang [ llvmPackages.openmp ];
cmakeFlags = [
(lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_AHRSFUSION" "${finalAttrs.fusion}")
(lib.cmakeFeature "OPENTRACK_COMMIT" "opentrack-${finalAttrs.version}")
(lib.cmakeBool "SDK_WINE" withWine)
(lib.cmakeFeature "SDK_ARUCO_LIBPATH" "${finalAttrs.aruco}/lib/libaruco.a")
(lib.cmakeFeature "SDK_XPLANE" finalAttrs.xplaneSdk.outPath)
]
++ lib.optionals isLinux [
(lib.cmakeFeature "SDK_ARUCO_LIBPATH" "${finalAttrs.aruco}/lib/libaruco.a")
];
postInstall = ''
install -Dt $out/share/icons/hicolor/256x256/apps ../gui/images/opentrack.png
'';
postInstall =
lib.optionalString isLinux ''
install -Dt $out/share/icons/hicolor/256x256/apps ../gui/images/opentrack.png
''
+ lib.optionalString isDarwin ''
mkdir -p $out/Applications
mv $out/opentrack.app $out/Applications/
chmod -R +w "$out/Applications/opentrack.app"
# use upstream Info.plist for correct permissions etc.
cp "../macosx/Info.plist" "$out/Applications/opentrack.app/Contents/"
substituteInPlace "$out/Applications/opentrack.app/Contents/Info.plist" \
--subst-var-by "OPENTRACK-VERSION" "${finalAttrs.version}"
cp "../macosx/PkgInfo" "$out/Applications/opentrack.app/Contents/"
mv "$out/Plugins" "$out/Applications/opentrack.app/Contents/MacOS/Plugins"
# create the macOS iconset
tmp="$(mktemp -d)"
files=""
for size in 16 32 64 128 256 512; do
outfile="$tmp/opentrack_''${size}x''${size}.png"
magick "../gui/images/opentrack.png" -filter triangle -resize "''${size}x''${size}" "$outfile"
files="$files $outfile"
done
png2icns "$out/Applications/opentrack.app/Contents/Resources/opentrack.icns" $files
rm -rf "$tmp"
'';
# manually wrap just the main binary
dontWrapQtApps = true;
preFixup = ''
wrapQtApp $out/bin/opentrack \
--prefix PATH : ${lib.makeBinPath [ v4l-utils ]}
'';
qtWrapperArgs =
lib.optionals isLinux [
"--prefix PATH : ${lib.makeBinPath [ v4l-utils ]}"
]
++ lib.optionals isDarwin [
"--set DYLD_LIBRARY_PATH ${placeholder "out"}/Library"
];
preFixup =
lib.optionalString isLinux ''
wrapQtApp $out/bin/opentrack
''
+ lib.optionalString isDarwin ''
wrapQtApp $out/Applications/opentrack.app/Contents/MacOS/opentrack
'';
desktopItems = [
desktopItems = lib.optionals isLinux [
(makeDesktopItem {
name = "opentrack";
exec = "opentrack";
@@ -124,6 +181,6 @@ stdenv.mkDerivation (finalAttrs: {
lib.maintainers.nekowinston
lib.maintainers.zaninime
];
platforms = lib.platforms.linux;
platforms = lib.platforms.unix;
};
})
@@ -0,0 +1,15 @@
diff --git a/macosx/CMakeLists.txt b/macosx/CMakeLists.txt
index 8520e9e9..6428e91e 100644
--- a/macosx/CMakeLists.txt
+++ b/macosx/CMakeLists.txt
@@ -2,10 +2,4 @@ if(APPLE)
otr_escape_string(srcdir "${CMAKE_SOURCE_DIR}")
otr_escape_string(instdir "${CMAKE_INSTALL_PREFIX}")
otr_escape_string(commit "${OPENTRACK_COMMIT}")
- install(CODE "
- execute_process(COMMAND /bin/sh \"${srcdir}/macosx/make-app-bundle.sh\"
- \"${srcdir}/macosx\"
- \"${instdir}\"
- \"${commit}\")
- ")
endif()