Skip to content

Commit 58f37a3

Browse files
authored
electron: simplify usage of headers (#385341)
2 parents bd759ce + 6da0232 commit 58f37a3

File tree

10 files changed

+22
-51
lines changed

10 files changed

+22
-51
lines changed

doc/release-notes/rl-2505.section.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
- The hand written `perlPackages.SearchXapian` bindings have been dropped in favor of the (mostly compatible)
5656
`perlPackages.Xapian`.
5757

58+
- The `electron` packages will now provide their headers (available via `electron.headers`) in extracted form instead of in a tarball.
59+
5860
- [testers.shellcheck](https://nixos.org/manual/nixpkgs/unstable/#tester-shellcheck) now warns when `name` is not provided.
5961
The `name` argument will become mandatory in a future release.
6062

pkgs/applications/editors/rstudio/default.nix

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,6 @@ let
4444
# need to be updated every time the latest electron gets a new abi version number
4545
electron = electron_33;
4646

47-
# unpack tarball containing electron's headers
48-
electron-headers = runCommand "electron-headers" { } ''
49-
mkdir -p $out
50-
tar -C $out --strip-components=1 -xvf ${electron.headers}
51-
'';
52-
5347
mathJaxSrc = fetchzip {
5448
url = "https://s3.amazonaws.com/rstudio-buildtools/mathjax-27.zip";
5549
hash = "sha256-J7SZK/9q3HcXTD7WFHxvh++ttuCd89Vc4SEBrUEU0AI=";
@@ -241,7 +235,7 @@ stdenv.mkDerivation rec {
241235
--replace-fail "npm ci && " ""
242236
243237
# use electron's headers to make node-gyp compile against the electron ABI
244-
export npm_config_nodedir="${electron-headers}"
238+
export npm_config_nodedir="${electron.headers}"
245239
246240
### override the detected electron version
247241
substituteInPlace node_modules/@electron-forge/core-utils/dist/electron-version.js \

pkgs/by-name/an/anytype/package.nix

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@ let
3131
rev = "687106c4e37297f86fab79f77ef83599b61ab65c";
3232
hash = "sha256-Y0irD0jzqYobnjtD2M1+hTDRUUYnuygUx9+tE1gUoTw=";
3333
};
34-
35-
electron-headers = runCommand "electron-headers" { } ''
36-
mkdir -p $out
37-
tar -C $out --strip-components=1 -xvf ${electron.headers}
38-
'';
39-
4034
in
4135
buildNpmPackage {
4236
inherit pname version src;
@@ -55,7 +49,7 @@ buildNpmPackage {
5549

5650
npmFlags = [
5751
# keytar needs to be built against electron's ABI
58-
"--nodedir=${electron-headers}"
52+
"--nodedir=${electron.headers}"
5953
];
6054

6155
buildPhase = ''

pkgs/by-name/el/element-desktop/keytar/default.nix

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,10 @@
1111
fetchNpmDeps,
1212
npmHooks,
1313
electron,
14-
runCommand,
1514
}:
1615

1716
let
1817
pinData = lib.importJSON ./pin.json;
19-
20-
electron-headers = runCommand "electron-headers" { } ''
21-
mkdir -p $out
22-
tar -C $out --strip-components=1 -xvf ${electron.headers}
23-
'';
24-
2518
in
2619
stdenv.mkDerivation rec {
2720
pname = "keytar-forked";
@@ -57,7 +50,7 @@ stdenv.mkDerivation rec {
5750

5851
npmFlags = [
5952
# Make sure the native modules are built against electron's ABI
60-
"--nodedir=${electron-headers}"
53+
"--nodedir=${electron.headers}"
6154
# https://nodejs.org/api/os.html#osarch
6255
"--arch=${
6356
if stdenv.hostPlatform.parsed.cpu.name == "i686" then

pkgs/by-name/lo/logseq/package.nix

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,6 @@
2424
git,
2525
}:
2626

27-
let
28-
# unpack tarball containing electron's headers
29-
electron-headers = runCommand "electron-headers" { } ''
30-
mkdir -p $out
31-
tar -C $out --strip-components=1 -xvf ${electron.headers}
32-
'';
33-
in
34-
3527
stdenv.mkDerivation (finalAttrs: {
3628
pname = "logseq";
3729
version = "0.10.9-unstable-2025-03-11";
@@ -202,21 +194,21 @@ stdenv.mkDerivation (finalAttrs: {
202194
npm rebuild --verbose
203195
popd
204196
205-
export npm_config_nodedir=${electron-headers}
197+
export npm_config_nodedir=${electron.headers}
206198
207199
pushd static
208200
209201
# we want to use our own git, don't try downloading it
210202
substituteInPlace node_modules/dugite/package.json \
211203
--replace-fail '"postinstall"' '"_postinstall"'
212204
213-
# this doesn't seem to build with electron-headers
205+
# this doesn't seem to build with electron.headers
214206
rm node_modules/macos-alias/binding.gyp
215207
216208
# the electron-rebuild command deadlocks for some reason, let's just use normal npm rebuild (since we overrode the nodedir anyways)
217209
npm rebuild --verbose
218210
219-
# remove most references to electron-headers
211+
# remove most references to electron.headers
220212
# TODO: track down the remaining references
221213
find node_modules -type f \( -name "*.target.mk" -o -name "config.gypi" -o -name "Makefile" \) -delete
222214

pkgs/by-name/si/signal-desktop-source/package.nix

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
makeWrapper,
99
callPackage,
1010
fetchFromGitHub,
11-
runCommand,
1211
jq,
1312
makeDesktopItem,
1413
copyDesktopItems,
@@ -39,11 +38,6 @@ let
3938
.${stdenv.hostPlatform.parsed.cpu.name}
4039
or (throw "unsupported platform ${stdenv.hostPlatform.parsed.cpu.name}");
4140

42-
electron-headers = runCommand "electron-headers" { } ''
43-
mkdir -p $out
44-
tar -C $out --strip-components=1 -xvf ${electron.headers}
45-
'';
46-
4741
libsignal-node = callPackage ./libsignal-node.nix { inherit nodejs; };
4842

4943
webrtc = callPackage ./webrtc.nix { };
@@ -179,7 +173,7 @@ stdenv.mkDerivation (finalAttrs: {
179173
buildPhase = ''
180174
runHook preBuild
181175
182-
export npm_config_nodedir=${electron-headers}
176+
export npm_config_nodedir=${electron.headers}
183177
cp -r ${electron.dist} electron-dist
184178
chmod -R u+w electron-dist
185179
cp -r ${sticker-creator} sticker-creator/dist

pkgs/development/tools/electron/binary/generic.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
stdenv,
44
makeWrapper,
55
fetchurl,
6+
fetchzip,
67
wrapGAppsHook3,
78
glib,
89
gtk3,
@@ -69,7 +70,8 @@ let
6970

7071
headersFetcher =
7172
vers: hash:
72-
fetchurl {
73+
fetchzip {
74+
name = "electron-${vers}-headers";
7375
url = "https://artifacts.electronjs.org/headers/dist/v${vers}/node-v${vers}-headers.tar.gz";
7476
sha256 = hash;
7577
};

pkgs/development/tools/electron/binary/info.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"aarch64-darwin": "67e5f8ce2c395b6b5a4c896ee1f2558b0003d0a54a7f4aef3b7760409ffc5825",
55
"aarch64-linux": "6b18f435855284852be2b2c1b49e58df380a56784d78b358a13ea77bbace4a8a",
66
"armv7l-linux": "a067329d55cc6648e9f783fd8b01b93da45ac21892b8096d758b30a87505c1a7",
7-
"headers": "0pb06wlx5zz0asrh05c90q0np14c4swkvhzrcqmcyfz7ihczqh5a",
7+
"headers": "13all8fl0zafswszd6lwlhd7bvflglawpglhwal68vliz5sz0p9a",
88
"x86_64-darwin": "0499216feffc2ba56438d8c4ac89cf40117baee6335099f5b12457d339f465a6",
99
"x86_64-linux": "0e1f1540492e48e3b8805f87c5096c3b99995c4c1b581ee57e9c836538bae813"
1010
},
@@ -15,7 +15,7 @@
1515
"aarch64-darwin": "b1425938a053b47bdf1c3c28abd146defb7372a8e645adb0a2f2a9650ca6a36d",
1616
"aarch64-linux": "0f7350d2aa0d03b4e57aced4cc921a71fa15a0a5528ee463651771cb415e0381",
1717
"armv7l-linux": "153938fe15bf90e2ff6429d1f7db19144b01b8ec12a00a351fdb9fee56c585c3",
18-
"headers": "1ji9mxjh2pigx1ldvp6m9ydlkcyvl6mrrpqsbvzvxd2spppzih0d",
18+
"headers": "0gwin292x5ryx41kw0c801b4ipin9q1agnigdv31vcd4y0na2p3s",
1919
"x86_64-darwin": "38d247a3540650e21ee8d99a8e07b3c9f40439ad09cc176628adb2af948070f6",
2020
"x86_64-linux": "ae5cb348d7697f4acfb6d19dddc4ffc9fae1a687be5bee66684279a82fd8621b"
2121
},
@@ -26,7 +26,7 @@
2626
"aarch64-darwin": "5a142772493b25ad22dda774a1d4da78887024adae8e83b0e74ad0ba64a7f55a",
2727
"aarch64-linux": "d22f1778894393414d7da01aa3f85d6f11f2cb5a5c7623d9d8339bcd824df4cb",
2828
"armv7l-linux": "29af72e24c74da70c85bfdce1ed6492b7efbe85f88cfb3da642844b51e5d7259",
29-
"headers": "175n6wkz5gyj7plbjbcd6nkhbc108i2ng8ms2wvjya042mshzlqi",
29+
"headers": "1jyc5riakfry5gmlcx7nmvl29iq6a01013k7zcfrcmijpkdw0p9z",
3030
"x86_64-darwin": "618156b4c923adcc2bf3d0a81d82dc874f27129893b7b3c349d0ca13651619e8",
3131
"x86_64-linux": "18ebcf0d2b681e273eb003ea0d77bb4fb91ed891f39778ad9c22b41972ed1975"
3232
},
@@ -37,7 +37,7 @@
3737
"aarch64-darwin": "ad701bedd2b969eddad8676c8dfa69a21d18896ae58fbd7310a358dd21c7d0eb",
3838
"aarch64-linux": "a1a71be2bb826b59a1da726a59895025481ee335896c175fcffdc2fcfc432675",
3939
"armv7l-linux": "28186a0edb4e83c9d7afeb32923f26794d26c39f28a3706462a060d4b0e3bc5f",
40-
"headers": "1y6d1nygfg6hdcjlzzgdz12hvh8j3xihhg9sg7p6fkmqkll4fyyb",
40+
"headers": "1la2xfr8lyvq7dc4mxllj3qksrrwxmz3nc2fnr2h0l08bfn2y1ay",
4141
"x86_64-darwin": "858f17d67ea811711802b209d041cfca8caa14e6c8f0960de48df14892a0c632",
4242
"x86_64-linux": "ab6d4bceff76a070ebf3264ee516a3f96a040947f462d26ba202aa754e54d852"
4343
},

pkgs/development/tools/electron/binary/update.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ def get_headers(version: str) -> str:
8181
called_process: subprocess.CompletedProcess = subprocess.run(
8282
[
8383
"nix-prefetch-url",
84+
"--unpack",
8485
f"https://artifacts.electronjs.org/headers/dist/v{version}/node-v{version}-headers.tar.gz",
8586
],
8687
capture_output=True,

pkgs/development/tools/electron/common.nix

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
yarn,
1111
libnotify,
1212
unzip,
13-
pkgs,
1413
pkgsBuildHost,
1514
pipewire,
1615
libsecret,
@@ -37,6 +36,9 @@ in
3736
"headers"
3837
];
3938

39+
# don't automatically move the include directory from $headers back into $out
40+
moveToDev = false;
41+
4042
nativeBuildInputs = base.nativeBuildInputs ++ [
4143
nodejs
4244
yarn
@@ -213,11 +215,8 @@ in
213215
mkdir -p $libExecPath
214216
unzip -d $libExecPath out/Release/dist.zip
215217
216-
# Create reproducible tarball, per instructions at https://reproducible-builds.org/docs/archives/
217-
tar --sort=name \
218-
--mtime="@$SOURCE_DATE_EPOCH" \
219-
--owner=0 --group=0 --numeric-owner \
220-
-czf $headers -C out/Release/gen node_headers
218+
mkdir -p $headers
219+
cp -r out/Release/gen/node_headers/* $headers/
221220
222221
runHook postInstall
223222
'';

0 commit comments

Comments
 (0)