From 6a493053c0ee08397494021702fd9a9b3ceb2b44 Mon Sep 17 00:00:00 2001 From: Daniel Poelzleithner Date: Wed, 29 Apr 2026 04:08:39 +0200 Subject: [PATCH] onlykey: fix broken gui Root cause: NW.js 0.102 in Chrome-packaged-app mode never advances document.readyState past loading, so DOMContentLoaded and load events never fire. The previous init(); patch was placed inside the DOMContentLoaded handler, so it never executed. fixes #386751 Second bug was node modules that needed rebuilding. --- pkgs/by-name/on/onlykey/package.nix | 32 +++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/pkgs/by-name/on/onlykey/package.nix b/pkgs/by-name/on/onlykey/package.nix index 8ae4619a7ab9..98220dd8dd2d 100644 --- a/pkgs/by-name/on/onlykey/package.nix +++ b/pkgs/by-name/on/onlykey/package.nix @@ -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 \ + '' \ + ' + ' + + # 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"