mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-04-15 09:47:55 +00:00
electron: simplify usage of headers
This commit is contained in:
parent
9bd18013d7
commit
6da0232e3c
@ -55,6 +55,8 @@
|
||||
- The hand written `perlPackages.SearchXapian` bindings have been dropped in favor of the (mostly compatible)
|
||||
`perlPackages.Xapian`.
|
||||
|
||||
- The `electron` packages will now provide their headers (available via `electron.headers`) in extracted form instead of in a tarball.
|
||||
|
||||
- [testers.shellcheck](https://nixos.org/manual/nixpkgs/unstable/#tester-shellcheck) now warns when `name` is not provided.
|
||||
The `name` argument will become mandatory in a future release.
|
||||
|
||||
|
@ -44,12 +44,6 @@ let
|
||||
# need to be updated every time the latest electron gets a new abi version number
|
||||
electron = electron_33;
|
||||
|
||||
# unpack tarball containing electron's headers
|
||||
electron-headers = runCommand "electron-headers" { } ''
|
||||
mkdir -p $out
|
||||
tar -C $out --strip-components=1 -xvf ${electron.headers}
|
||||
'';
|
||||
|
||||
mathJaxSrc = fetchzip {
|
||||
url = "https://s3.amazonaws.com/rstudio-buildtools/mathjax-27.zip";
|
||||
hash = "sha256-J7SZK/9q3HcXTD7WFHxvh++ttuCd89Vc4SEBrUEU0AI=";
|
||||
@ -241,7 +235,7 @@ stdenv.mkDerivation rec {
|
||||
--replace-fail "npm ci && " ""
|
||||
|
||||
# use electron's headers to make node-gyp compile against the electron ABI
|
||||
export npm_config_nodedir="${electron-headers}"
|
||||
export npm_config_nodedir="${electron.headers}"
|
||||
|
||||
### override the detected electron version
|
||||
substituteInPlace node_modules/@electron-forge/core-utils/dist/electron-version.js \
|
||||
|
@ -31,12 +31,6 @@ let
|
||||
rev = "687106c4e37297f86fab79f77ef83599b61ab65c";
|
||||
hash = "sha256-Y0irD0jzqYobnjtD2M1+hTDRUUYnuygUx9+tE1gUoTw=";
|
||||
};
|
||||
|
||||
electron-headers = runCommand "electron-headers" { } ''
|
||||
mkdir -p $out
|
||||
tar -C $out --strip-components=1 -xvf ${electron.headers}
|
||||
'';
|
||||
|
||||
in
|
||||
buildNpmPackage {
|
||||
inherit pname version src;
|
||||
@ -55,7 +49,7 @@ buildNpmPackage {
|
||||
|
||||
npmFlags = [
|
||||
# keytar needs to be built against electron's ABI
|
||||
"--nodedir=${electron-headers}"
|
||||
"--nodedir=${electron.headers}"
|
||||
];
|
||||
|
||||
buildPhase = ''
|
||||
|
@ -11,17 +11,10 @@
|
||||
fetchNpmDeps,
|
||||
npmHooks,
|
||||
electron,
|
||||
runCommand,
|
||||
}:
|
||||
|
||||
let
|
||||
pinData = lib.importJSON ./pin.json;
|
||||
|
||||
electron-headers = runCommand "electron-headers" { } ''
|
||||
mkdir -p $out
|
||||
tar -C $out --strip-components=1 -xvf ${electron.headers}
|
||||
'';
|
||||
|
||||
in
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "keytar-forked";
|
||||
@ -57,7 +50,7 @@ stdenv.mkDerivation rec {
|
||||
|
||||
npmFlags = [
|
||||
# Make sure the native modules are built against electron's ABI
|
||||
"--nodedir=${electron-headers}"
|
||||
"--nodedir=${electron.headers}"
|
||||
# https://nodejs.org/api/os.html#osarch
|
||||
"--arch=${
|
||||
if stdenv.hostPlatform.parsed.cpu.name == "i686" then
|
||||
|
@ -24,14 +24,6 @@
|
||||
git,
|
||||
}:
|
||||
|
||||
let
|
||||
# unpack tarball containing electron's headers
|
||||
electron-headers = runCommand "electron-headers" { } ''
|
||||
mkdir -p $out
|
||||
tar -C $out --strip-components=1 -xvf ${electron.headers}
|
||||
'';
|
||||
in
|
||||
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "logseq";
|
||||
version = "0.10.9-unstable-2025-03-11";
|
||||
@ -202,7 +194,7 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
npm rebuild --verbose
|
||||
popd
|
||||
|
||||
export npm_config_nodedir=${electron-headers}
|
||||
export npm_config_nodedir=${electron.headers}
|
||||
|
||||
pushd static
|
||||
|
||||
@ -210,13 +202,13 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
substituteInPlace node_modules/dugite/package.json \
|
||||
--replace-fail '"postinstall"' '"_postinstall"'
|
||||
|
||||
# this doesn't seem to build with electron-headers
|
||||
# this doesn't seem to build with electron.headers
|
||||
rm node_modules/macos-alias/binding.gyp
|
||||
|
||||
# the electron-rebuild command deadlocks for some reason, let's just use normal npm rebuild (since we overrode the nodedir anyways)
|
||||
npm rebuild --verbose
|
||||
|
||||
# remove most references to electron-headers
|
||||
# remove most references to electron.headers
|
||||
# TODO: track down the remaining references
|
||||
find node_modules -type f \( -name "*.target.mk" -o -name "config.gypi" -o -name "Makefile" \) -delete
|
||||
|
||||
|
@ -8,7 +8,6 @@
|
||||
makeWrapper,
|
||||
callPackage,
|
||||
fetchFromGitHub,
|
||||
runCommand,
|
||||
jq,
|
||||
makeDesktopItem,
|
||||
copyDesktopItems,
|
||||
@ -39,11 +38,6 @@ let
|
||||
.${stdenv.hostPlatform.parsed.cpu.name}
|
||||
or (throw "unsupported platform ${stdenv.hostPlatform.parsed.cpu.name}");
|
||||
|
||||
electron-headers = runCommand "electron-headers" { } ''
|
||||
mkdir -p $out
|
||||
tar -C $out --strip-components=1 -xvf ${electron.headers}
|
||||
'';
|
||||
|
||||
libsignal-node = callPackage ./libsignal-node.nix { inherit nodejs; };
|
||||
|
||||
webrtc = callPackage ./webrtc.nix { };
|
||||
@ -179,7 +173,7 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
export npm_config_nodedir=${electron-headers}
|
||||
export npm_config_nodedir=${electron.headers}
|
||||
cp -r ${electron.dist} electron-dist
|
||||
chmod -R u+w electron-dist
|
||||
cp -r ${sticker-creator} sticker-creator/dist
|
||||
|
@ -3,6 +3,7 @@
|
||||
stdenv,
|
||||
makeWrapper,
|
||||
fetchurl,
|
||||
fetchzip,
|
||||
wrapGAppsHook3,
|
||||
glib,
|
||||
gtk3,
|
||||
@ -69,7 +70,8 @@ let
|
||||
|
||||
headersFetcher =
|
||||
vers: hash:
|
||||
fetchurl {
|
||||
fetchzip {
|
||||
name = "electron-${vers}-headers";
|
||||
url = "https://artifacts.electronjs.org/headers/dist/v${vers}/node-v${vers}-headers.tar.gz";
|
||||
sha256 = hash;
|
||||
};
|
||||
|
@ -4,7 +4,7 @@
|
||||
"aarch64-darwin": "67e5f8ce2c395b6b5a4c896ee1f2558b0003d0a54a7f4aef3b7760409ffc5825",
|
||||
"aarch64-linux": "6b18f435855284852be2b2c1b49e58df380a56784d78b358a13ea77bbace4a8a",
|
||||
"armv7l-linux": "a067329d55cc6648e9f783fd8b01b93da45ac21892b8096d758b30a87505c1a7",
|
||||
"headers": "0pb06wlx5zz0asrh05c90q0np14c4swkvhzrcqmcyfz7ihczqh5a",
|
||||
"headers": "13all8fl0zafswszd6lwlhd7bvflglawpglhwal68vliz5sz0p9a",
|
||||
"x86_64-darwin": "0499216feffc2ba56438d8c4ac89cf40117baee6335099f5b12457d339f465a6",
|
||||
"x86_64-linux": "0e1f1540492e48e3b8805f87c5096c3b99995c4c1b581ee57e9c836538bae813"
|
||||
},
|
||||
@ -15,7 +15,7 @@
|
||||
"aarch64-darwin": "b1425938a053b47bdf1c3c28abd146defb7372a8e645adb0a2f2a9650ca6a36d",
|
||||
"aarch64-linux": "0f7350d2aa0d03b4e57aced4cc921a71fa15a0a5528ee463651771cb415e0381",
|
||||
"armv7l-linux": "153938fe15bf90e2ff6429d1f7db19144b01b8ec12a00a351fdb9fee56c585c3",
|
||||
"headers": "1ji9mxjh2pigx1ldvp6m9ydlkcyvl6mrrpqsbvzvxd2spppzih0d",
|
||||
"headers": "0gwin292x5ryx41kw0c801b4ipin9q1agnigdv31vcd4y0na2p3s",
|
||||
"x86_64-darwin": "38d247a3540650e21ee8d99a8e07b3c9f40439ad09cc176628adb2af948070f6",
|
||||
"x86_64-linux": "ae5cb348d7697f4acfb6d19dddc4ffc9fae1a687be5bee66684279a82fd8621b"
|
||||
},
|
||||
@ -26,7 +26,7 @@
|
||||
"aarch64-darwin": "5a142772493b25ad22dda774a1d4da78887024adae8e83b0e74ad0ba64a7f55a",
|
||||
"aarch64-linux": "d22f1778894393414d7da01aa3f85d6f11f2cb5a5c7623d9d8339bcd824df4cb",
|
||||
"armv7l-linux": "29af72e24c74da70c85bfdce1ed6492b7efbe85f88cfb3da642844b51e5d7259",
|
||||
"headers": "175n6wkz5gyj7plbjbcd6nkhbc108i2ng8ms2wvjya042mshzlqi",
|
||||
"headers": "1jyc5riakfry5gmlcx7nmvl29iq6a01013k7zcfrcmijpkdw0p9z",
|
||||
"x86_64-darwin": "618156b4c923adcc2bf3d0a81d82dc874f27129893b7b3c349d0ca13651619e8",
|
||||
"x86_64-linux": "18ebcf0d2b681e273eb003ea0d77bb4fb91ed891f39778ad9c22b41972ed1975"
|
||||
},
|
||||
@ -37,7 +37,7 @@
|
||||
"aarch64-darwin": "ad701bedd2b969eddad8676c8dfa69a21d18896ae58fbd7310a358dd21c7d0eb",
|
||||
"aarch64-linux": "a1a71be2bb826b59a1da726a59895025481ee335896c175fcffdc2fcfc432675",
|
||||
"armv7l-linux": "28186a0edb4e83c9d7afeb32923f26794d26c39f28a3706462a060d4b0e3bc5f",
|
||||
"headers": "1y6d1nygfg6hdcjlzzgdz12hvh8j3xihhg9sg7p6fkmqkll4fyyb",
|
||||
"headers": "1la2xfr8lyvq7dc4mxllj3qksrrwxmz3nc2fnr2h0l08bfn2y1ay",
|
||||
"x86_64-darwin": "858f17d67ea811711802b209d041cfca8caa14e6c8f0960de48df14892a0c632",
|
||||
"x86_64-linux": "ab6d4bceff76a070ebf3264ee516a3f96a040947f462d26ba202aa754e54d852"
|
||||
},
|
||||
|
@ -81,6 +81,7 @@ def get_headers(version: str) -> str:
|
||||
called_process: subprocess.CompletedProcess = subprocess.run(
|
||||
[
|
||||
"nix-prefetch-url",
|
||||
"--unpack",
|
||||
f"https://artifacts.electronjs.org/headers/dist/v{version}/node-v{version}-headers.tar.gz",
|
||||
],
|
||||
capture_output=True,
|
||||
|
@ -10,7 +10,6 @@
|
||||
yarn,
|
||||
libnotify,
|
||||
unzip,
|
||||
pkgs,
|
||||
pkgsBuildHost,
|
||||
pipewire,
|
||||
libsecret,
|
||||
@ -37,6 +36,9 @@ in
|
||||
"headers"
|
||||
];
|
||||
|
||||
# don't automatically move the include directory from $headers back into $out
|
||||
moveToDev = false;
|
||||
|
||||
nativeBuildInputs = base.nativeBuildInputs ++ [
|
||||
nodejs
|
||||
yarn
|
||||
@ -213,11 +215,8 @@ in
|
||||
mkdir -p $libExecPath
|
||||
unzip -d $libExecPath out/Release/dist.zip
|
||||
|
||||
# Create reproducible tarball, per instructions at https://reproducible-builds.org/docs/archives/
|
||||
tar --sort=name \
|
||||
--mtime="@$SOURCE_DATE_EPOCH" \
|
||||
--owner=0 --group=0 --numeric-owner \
|
||||
-czf $headers -C out/Release/gen node_headers
|
||||
mkdir -p $headers
|
||||
cp -r out/Release/gen/node_headers/* $headers/
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
Loading…
Reference in New Issue
Block a user