onlykey: fix broken gui (#514629)

This commit is contained in:
Weijia Wang
2026-05-07 10:41:25 +00:00
committed by GitHub
+32
View File
@@ -46,11 +46,43 @@ buildNpmPackage (finalAttrs: {
# should not break other things.
npmFlags = [ "--ignore-scripts" ];
postPatch = ''
# NW.js 0.102 in Chrome-packaged-app mode never advances
# document.readyState past "loading", so DOMContentLoaded and load
# events never fire and the wizard UI never initializes (the window
# only shows the page background and the "Last message received"
# footer text). Dispatch the events manually after the bottom-of-body
# scripts have registered their listeners.
substituteInPlace app/app.html \
--replace-fail \
'<script src="/scripts/dialog-links.js"></script>' \
'<script src="/scripts/dialog-links.js"></script>
<script>setTimeout(() => { document.dispatchEvent(new Event("DOMContentLoaded")); window.dispatchEvent(new Event("load")); }, 0);</script>'
# The app should not create autostart entries on first launch.
substituteInPlace app/app.js \
--replace-fail \
"} else if (!localStorage.hasOwnProperty('autoLaunch')) {" \
"} else if (false && !localStorage.hasOwnProperty('autoLaunch')) {"
'';
postBuild = ''
substituteInPlace build/package.json \
--replace-fail '"name": "OnlyKey-dev"' '"name": "OnlyKey"' \
--replace-fail '"toolbar": true' '"toolbar": false'
'';
installPhase = ''
runHook preInstall
rm -rf node_modules
npm ci --omit=dev --omit=optional --ignore-scripts
rm -rf node_modules/nw
rm -f node_modules/.bin/nw
mkdir -p "$out/share"
cp -r build "$out/share/onlykey"
cp -r node_modules "$out/share/onlykey/node_modules"
ln -s "${finalAttrs.desktopItem}/share/applications" "$out/share/applications"