lmstudio: fix for Darwin (#491927)

This commit is contained in:
@mjones 2026-02-28 06:57:50 +00:00 committed by GitHub
commit e4ff769d50
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 2 deletions

View file

@ -2,6 +2,7 @@
stdenv,
fetchurl,
undmg,
darwin,
meta,
pname,
version,
@ -16,7 +17,10 @@ stdenv.mkDerivation {
inherit url hash;
};
nativeBuildInputs = [ undmg ];
nativeBuildInputs = [
undmg
darwin.sigtool
];
sourceRoot = ".";
@ -24,6 +28,19 @@ stdenv.mkDerivation {
runHook preInstall
mkdir -p $out/Applications
cp -r *.app $out/Applications
# Bypass the /Applications path check in the main index.js
# LM Studio verifies the app is running from /Applications and shows an
# error dialog + refuses to auto-update if not. Replace the '/Applications'
# string literal with '/' so that any absolute path (e.g. /nix/store/...)
# passes the startsWith check. This works across obfuscated versions because
# the literal string '/Applications' is stable even when variable names change.
local indexJs="$out/Applications/LM Studio.app/Contents/Resources/app/.webpack/main/index.js"
substituteInPlace "$indexJs" --replace-quiet "'/Applications'" "'/'"
# Re-sign the app bundle after patching, otherwise macOS reports it as damaged
codesign --force --deep --sign - "$out/Applications/LM Studio.app"
runHook postInstall
'';

View file

@ -23,7 +23,6 @@ let
"aarch64-darwin"
];
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
broken = stdenv.hostPlatform.isDarwin; # Upstream issue: https://github.com/lmstudio-ai/lmstudio-bug-tracker/issues/347
};
in
if stdenv.hostPlatform.isDarwin then