Skip to content

Commit 1155de3

Browse files
committed
[DDW-1213] Upgrade Electron to 24.2, and Node.js to 18.×
1 parent e467c4b commit 1155de3

File tree

11 files changed

+387
-201
lines changed

11 files changed

+387
-201
lines changed

nix/any-darwin.nix

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,6 @@ in rec {
7777
find . -type f -name '*.node' -not -path '*/@swc*/*' -exec rm -vf {} ';'
7878
7979
patchShebangs . >/dev/null # a real lot of paths to patch, no need to litter logs
80-
sed -r 's#/bin/sh#sh#' -i node_modules/lzma-native/node_modules/node-gyp-build/bin.js
81-
82-
# GNU sed is a bit different:
83-
sed -r "s#sed -i '''#sed -i#" -i node_modules/lzma-native/liblzma-config.sh
8480
8581
# And now, with correct shebangs, run the install scripts (we have to do that
8682
# semi-manually, because another `yarn install` will overwrite those shebangs…):

nix/new-common.nix

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ rec {
3030
# patches = pkgs.lib.optional pkgs.stdenv.isDarwin (njPath + "/bypass-xcodebuild.diff");
3131
# };
3232

33-
nodejs = pkgs.nodejs-14_x.overrideAttrs (drv: {
33+
nodejs = pkgs.nodejs-18_x.overrideAttrs (drv: {
3434
# XXX: we don’t want `bypass-xcodebuild.diff`, rather we supply
3535
# the pure `xcbuild` – without that, `blake2` doesn’t build,
3636
# cf. <https://github.com/NixOS/nixpkgs/blob/29ae6a1f3d7a8886b3772df4dc42a13817875c7d/pkgs/development/web/nodejs/bypass-xcodebuild.diff>
3737
patches = [];
3838
});
3939

40-
nodePackages = pkgs.nodePackages.override { nodejs = nodejs; };
40+
nodePackages = pkgs.nodePackages.override { inherit nodejs; };
4141

4242
yarn = (pkgs.yarn.override { inherit nodejs; }).overrideAttrs (drv: {
4343
# XXX: otherwise, unable to run our package.json scripts in Nix sandbox (patchShebangs doesn’t catch this)
@@ -50,8 +50,8 @@ rec {
5050
# Nixpkgs master @ 2022-07-18
5151
# Why → newer `yarn2nix` uses `deep-equal` to see if anything changed in the lockfile, we need that.
5252
source = pkgs.fetchzip {
53-
url = "https://github.com/NixOS/nixpkgs/archive/qe4d49de45a3b5dbcb881656b4e3986e666141ea9.tar.gz";
54-
sha256 = "0y0c9ybkcfmjgrl93wzzlk7ii95kh2fb4v5ac5w6rmcsq2ff3yaz";
53+
url = "https://github.com/NixOS/nixpkgs/archive/e4d49de45a3b5dbcb881656b4e3986e666141ea9.tar.gz";
54+
hash = "sha256-X/nhnMCa1Wx4YapsspyAs6QYz6T/85FofrI6NpdPDHg=";
5555
};
5656
subdir = builtins.path { path = source + "/pkgs/development/tools/yarn2nix-moretea/yarn2nix"; };
5757
in
@@ -135,7 +135,7 @@ rec {
135135
# XXX: don’t use fetchzip, we need the raw .tar.gz in `patchElectronRebuild` below
136136
src = pkgs.fetchurl {
137137
url = "https://electronjs.org/headers/v${electronVersion}/node-v${electronVersion}-headers.tar.gz";
138-
hash = "sha256-+FZ1EYV6tiZZUFulFYtq1pr861EhBaMlHRgP5H9ENmw=";
138+
hash = "sha256-er08CKt3fwotSjYxqdzpm8Q0YjvD1PhfNBDZ3Jozsvk=";
139139
};
140140
} ''
141141
tar -xf $src
@@ -144,16 +144,18 @@ rec {
144144
'';
145145

146146
electronShaSums = pkgs.fetchurl {
147+
name = "electronShaSums-${electronVersion}"; # cache invalidation
147148
url = "https://github.com/electron/electron/releases/download/v${electronVersion}/SHASUMS256.txt";
148-
hash = "sha256-NiUplP/dqmynH2ZN97kJVqMkzSLOLi3JR1T/OWHiOiA=";
149+
hash = "sha256-75bNqt2c7u/fm0P2Ha6NvkbGThEifIHXl2x5UCdy4fM=";
149150
};
150151

151152
electronCacheHash = builtins.hashString "sha256"
152153
"https://github.com/electron/electron/releases/download/v${electronVersion}";
153154

154155
electronChromedriverShaSums = pkgs.fetchurl {
156+
name = "electronChromedriverShaSums-${electronChromedriverVersion}"; # cache invalidation
155157
url = "https://github.com/electron/electron/releases/download/v${electronChromedriverVersion}/SHASUMS256.txt";
156-
sha256 = "07xxam8dvn1aixvx39gd5x3yc1bs6i599ywxwi5cbkpf957ilpcx";
158+
hash = "sha256-nV0aT0nuzsVK5J37lEo0egXmRy/tpdF3jyrY3VBVvR8=";
157159
};
158160

159161
electronChromedriverCacheHash = builtins.hashString "sha256"
@@ -176,15 +178,7 @@ rec {
176178
patchElectronRebuild = pkgs.writeShellScriptBin "patch-electron-rebuild" ''
177179
echo 'Patching electron-rebuild to force our Node.js headers…'
178180
179-
nodeGypJs=lib/src/module-type/node-gyp.js
180-
if [ ! -e $nodeGypJs ] ; then
181-
# makes it work both here, and in shell.nix:
182-
nodeGypJs="node_modules/electron-rebuild/$nodeGypJs"
183-
fi
184-
if [ ! -e $nodeGypJs ] ; then
185-
echo >&2 'fatal: shouldn’t happen unless electron-rebuild changes'
186-
exit 1
187-
fi
181+
nodeGypJs="node_modules/@electron/rebuild/lib/module-type/node-gyp/node-gyp.js"
188182
189183
# Patch idempotently (matters in repetitive shell.nix):
190184
if ! grep -qF ${commonSources.electronHeaders.src} $nodeGypJs ; then

nix/x86_64-linux.nix

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ in rec {
5757
find . -type f -name '*.node' -not -path '*/@swc*/*' -exec rm -vf {} ';'
5858
5959
patchShebangs . >/dev/null # a real lot of paths to patch, no need to litter logs
60-
sed -r 's#/bin/sh#sh#' -i node_modules/lzma-native/node_modules/node-gyp-build/bin.js
6160
6261
# And now, with correct shebangs, run the install scripts (we have to do that
6362
# semi-manually, because another `yarn install` will overwrite those shebangs…):
@@ -102,7 +101,7 @@ in rec {
102101
patchedPackageJson = pkgs.writeText "package.json" (builtins.toJSON (
103102
pkgs.lib.recursiveUpdate originalPackageJson {
104103
productName = oldCode.launcherConfigs.installerConfig.spacedName;
105-
main = "main/index.js";
104+
main = "dist/main/index.js";
106105
}
107106
));
108107
buildPhase = ''
@@ -119,6 +118,9 @@ in rec {
119118
cp -R dist/. $out/share/daedalus/.
120119
cp $patchedPackageJson $out/share/daedalus/package.json
121120
121+
chmod +w $out/share/daedalus/package.json
122+
sed -r 's,"dist/main/index.js","main/index.js",g' -i $out/share/daedalus/package.json
123+
122124
# XXX: the webpack utils embed the original source paths into map files, which causes the derivation
123125
# to depend on the original inputs at the nix layer, and double the size of the linux installs.
124126
# this will just replace all storepaths with an invalid one:
@@ -309,7 +311,7 @@ in rec {
309311
linuxSources = {
310312
electron = pkgs.fetchurl {
311313
url = "https://github.com/electron/electron/releases/download/v${electronVersion}/electron-v${electronVersion}-linux-x64.zip";
312-
hash = "sha256-dgdCKkuoDNpL1/77L74vTguac9uS4egtwBASqFtdDSs=";
314+
hash = "sha256-jXeA3Sr8/l6Uos9XT0+hCiosaRIndx/KSQUcUkrGdRM=";
313315
};
314316

315317
electronChromedriver = pkgs.fetchurl {

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@
124124
"electron-connect": "0.6.3",
125125
"electron-devtools-installer": "3.2.0",
126126
"electron-mock-ipc": "0.3.12",
127-
"electron-packager": "15.4.0",
128-
"electron-rebuild": "3.2.7",
127+
"electron-packager": "17.1.1",
128+
"@electron/rebuild": "3.2.13",
129129
"electron-reloader": "1.2.1",
130130
"eslint": "8.13.0",
131131
"eslint-config-airbnb": "19.0.4",
@@ -219,7 +219,7 @@
219219
"classnames": "2.2.6",
220220
"csv-stringify": "5.5.1",
221221
"cucumber-html-reporter": "5.2.0",
222-
"electron": "13.6.3",
222+
"electron": "24.2.0",
223223
"electron-log-daedalus": "2.2.21",
224224
"electron-store": "8.0.1",
225225
"es6-error": "4.1.1",
@@ -311,6 +311,8 @@
311311
"**/**/usb": "1.7.2",
312312
"**/**/prismjs": "1.27.0",
313313
"**/**/prebuild-install": "^6.1.4",
314+
"**/**/node-abi": "^3.40.0",
315+
"**/**/nan": "^2.17.0",
314316
"prebuild-install": "^6.1.4",
315317
"pbkdf2": "3.1.2"
316318
}

scripts/rebuild-native-modules.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ find . -type f -name '*.node' -not -path '*/@swc*/*' -exec rm -vf {} ';'
1717
# doesn’t work reliably.
1818
nix run -L .#internal.mainnet.newCommon.patchElectronRebuild
1919

20+
# XXX: Electron 24.2 requires c++17:
21+
sed -r 's,std=c\+\+14,std=c++17,g' -i node_modules/usb/binding.gyp
22+
2023
# TODO: do we really need to run `electron-rebuild` 3×?
2124

2225
electron-rebuild --force

source/main/cardano/CardanoNode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -738,14 +738,14 @@ export class CardanoNode {
738738
ca: '' as any,
739739
key: '' as any,
740740
cert: '' as any,
741-
hostname: 'localhost',
741+
hostname: '127.0.0.1', // “localhost” breaks under new electron, which prefers ::1 (IPv6)
742742
port,
743743
}
744744
: {
745745
ca: _actions.readFileSync(`${tlsPath}/client/ca.crt`),
746746
key: _actions.readFileSync(`${tlsPath}/client/client.key`),
747747
cert: _actions.readFileSync(`${tlsPath}/client/client.pem`),
748-
hostname: 'localhost',
748+
hostname: '127.0.0.1', // “localhost” breaks under new electron, which prefers ::1 (IPv6)
749749
port,
750750
};
751751

source/main/cardano/CardanoSelfnodeLauncher.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ const CARDANO_WALLET_START_TIMEOUT = 60 * 1000; // 60 seconds | unit: millisecon
3131
const CARDANO_WALLET_START_CHECK_INTERVAL = 500; // 500 ms | unit: milliseconds
3232

3333
const TOKEN_METADATA_SERVER_PORT = 65432;
34-
const TOKEN_METADATA_SERVER = `http://localhost:${TOKEN_METADATA_SERVER_PORT}/`;
34+
// “localhost” breaks under new electron, which prefers ::1 (IPv6)
35+
const TOKEN_METADATA_SERVER = `http://127.0.0.1:${TOKEN_METADATA_SERVER_PORT}/`;
3536
const TOKEN_METADATA_SERVER_PROCESS_NAME = environment.isWindows
3637
? 'mock-token-metadata-server.exe'
3738
: 'mock-token-metadata-server';

source/main/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ export const FALLBACK_TOKEN_METADATA_SERVER_URL =
178178
export const MINIMUM_AMOUNT_OF_RAM_FOR_RTS_FLAGS = 16 * 1024 * 1024 * 1024; // 16gb RAM
179179

180180
// Used by mock-token-metadata-server
181-
export const MOCK_TOKEN_METADATA_SERVER_URL = 'http://localhost';
181+
// “localhost” breaks under new electron, which prefers ::1 (IPv6)
182+
export const MOCK_TOKEN_METADATA_SERVER_URL = 'http://127.0.0.1';
182183
export const MOCK_TOKEN_METADATA_SERVER_PORT =
183184
process.env.MOCK_TOKEN_METADATA_SERVER_PORT || 0;
184185
export const RTS_FLAGS = ['-c'];

source/main/windows/main.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export const createMainWindow = (
5555
// TODO: change to ipc
5656
enableRemoteModule: isTest,
5757
preload: path.join(__dirname, './preload.js'),
58+
nodeIntegration: true,
5859
additionalArguments: isBlankScreenFixActive ? ['--safe-mode'] : [],
5960
},
6061
};
@@ -81,7 +82,7 @@ export const createMainWindow = (
8182
window.close();
8283
});
8384
if (isDev) {
84-
window.loadURL(`http://localhost:8080`);
85+
window.loadURL(`http://127.0.0.1:8080`);
8586
} else {
8687
window.loadURL(`file://${__dirname}/../renderer/index.html`);
8788
}

source/renderer/app/api/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export type Api = {
99

1010
export const setupApi = (isTest: boolean): Api => ({
1111
ada: new AdaApi(isTest, {
12-
hostname: 'localhost',
12+
hostname: '127.0.0.1', // “localhost” breaks under new electron, which prefers ::1 (IPv6)
1313
port: 8090,
1414
ca: Uint8Array.from([]),
1515
key: Uint8Array.from([]),

0 commit comments

Comments
 (0)