Skip to content

Commit

Permalink
[DDW-1213] Try one more hack
Browse files Browse the repository at this point in the history
  • Loading branch information
michalrus committed Jun 1, 2023
1 parent a8260a9 commit b319759
Showing 1 changed file with 38 additions and 4 deletions.
42 changes: 38 additions & 4 deletions nix/x86_64-windows.nix
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ in rec {
echo ' '
echo '===================== '${pkgs.lib.escapeShellArg title}' ====================='
'';
completeHack = "rebuild-complete-hack-bnlzMmdjbXB5emozNWFndGx1bnd5dnh5";
in ''
${pkgs.xvfb-run}/bin/xvfb-run \
--server-args="-screen 0 1920x1080x24 +extension GLX +extension RENDER -ac -noreset" \
Expand Down Expand Up @@ -318,17 +319,50 @@ in rec {
${mkSection "Running @electron/rebuild"}
# XXX: we need to run the command with the Node.js env set correcty, `npm.cmd` does that:
export electron_rebuild_bin="$(winepath -w "$(readlink -f node_modules/.bin/electron-rebuild)")"
lx_electron_rebuild_bin="$(readlink -f node_modules/.bin/electron-rebuild)"
export electron_rebuild_bin="$(winepath -w "$lx_electron_rebuild_bin")"
# XXX: for some reason the build hangs (only on Cicero!) after outputting "Rebuild Complete", so let's hack around that:
sed -r '/Rebuild Complete/a require("fs").writeFileSync("${completeHack}", "");' -i "$lx_electron_rebuild_bin"
# XXX: re-enable this if you need to simulate Cicero hanging locally:
# sed -r 's/rebuildSpinner.succeed\(\);/setTimeout(function(){rebuildSpinner.succeed();},10000);/g' -i "$lx_electron_rebuild_bin"
(
while true ; do
if [ -e ${completeHack} ] ; then
echo "Found ${completeHack}, killing node.exe among:"
ps aux | cat
pkill -9 node.exe || true
break
else
sleep 2
fi
done
) &
wine_killer_pid=$!
cp ${pkgs.writeText "package.json" (builtins.toJSON (
pkgs.lib.recursiveUpdate originalPackageJson {
scripts = {
"build:electron:windows" = "node.exe %electron_rebuild_bin% -f -w usb";
};
}
))} package.json
wine npm.cmd run build:electron:windows
# XXX: We’re running in a separate namespace, so this is fine. Otherwise, builds on Cicero hang.
wine npm.cmd run build:electron:windows || {
real_ec=$?
if [ -e ${completeHack} ] ; then
echo "Wine would return $real_ec, but ${completeHack} exists"
return 0
else
return $real_ec
fi
}
kill $wine_killer_pid || true
# XXX: We’re running in a separate namespace, so this is fine.
while pgrep wine >/dev/null ; do
${mkSection "Wine is still running in the background, will try to kill it"}
echo 'All remaining processes:'
Expand Down

0 comments on commit b319759

Please sign in to comment.