electron: use gclientUnpackHook from gclient2nix

(cherry picked from commit fbca92b00c)
This commit is contained in:
Yureka
2025-04-04 16:10:38 +02:00
committed by Yureka
parent be8d08597e
commit a2f4824d8a

View File

@@ -18,19 +18,13 @@
libpulseaudio,
speechd-minimal,
info,
gclient2nix,
}:
let
fetchdep =
dep:
let
opts = removeAttrs dep [ "fetcher" ];
in
pkgs.${dep.fetcher} opts;
fetchedDeps = lib.mapAttrs (name: fetchdep) info.deps;
gclientDeps = gclient2nix.importGclientDeps info.deps;
in
((chromium.override { upstream-info = info.chromium; }).mkDerivation (base: {
packageName = "electron";
inherit (info) version;
@@ -50,20 +44,24 @@ in
fixup-yarn-lock
unzip
npmHooks.npmConfigHook
gclient2nix.gclientUnpackHook
];
buildInputs = base.buildInputs ++ [ libnotify ];
electronOfflineCache = fetchYarnDeps {
yarnLock = fetchedDeps."src/electron" + "/yarn.lock";
yarnLock = gclientDeps."src/electron".path + "/yarn.lock";
sha256 = info.electron_yarn_hash;
};
npmDeps = fetchNpmDeps rec {
src = fetchedDeps."src";
src = gclientDeps."src".path;
# Assume that the fetcher always unpack the source,
# based on update.py
sourceRoot = "${src.name}/third_party/node";
hash = info.chromium_npm_hash;
};
inherit gclientDeps;
unpackPhase = null; # prevent chromium's unpackPhase from being used
sourceRoot = "src";
env =
base.env
@@ -90,22 +88,6 @@ in
./fix-electron-32-patch-apply-without-git-3way.patch
];
unpackPhase =
''
runHook preUnpack
''
+ (lib.concatStrings (
lib.mapAttrsToList (path: dep: ''
mkdir -p ${builtins.dirOf path}
cp -r ${dep}/. ${path}
chmod u+w -R ${path}
'') fetchedDeps
))
+ ''
sourceRoot=src
runHook postUnpack
'';
npmRoot = "third_party/node";
postPatch =
@@ -126,14 +108,14 @@ in
echo 'cros_boards_with_qemu_images = ""' >> build/config/gclient_args.gni
echo 'generate_location_tags = true' >> build/config/gclient_args.gni
echo 'LASTCHANGE=${info.deps."src".rev}-refs/heads/master@{#0}' > build/util/LASTCHANGE
echo "$SOURCE_DATE_EPOCH" > build/util/LASTCHANGE.committime
echo 'LASTCHANGE=${info.deps."src".args.rev}-refs/heads/master@{#0}' > build/util/LASTCHANGE
echo "$SOURCE_DATE_EPOCH" > build/util/LASTCHANGE.committime
cat << EOF > gpu/config/gpu_lists_version.h
/* Generated by lastchange.py, do not edit.*/
#ifndef GPU_CONFIG_GPU_LISTS_VERSION_H_
#define GPU_CONFIG_GPU_LISTS_VERSION_H_
#define GPU_LISTS_VERSION "${info.deps."src".rev}"
#define GPU_LISTS_VERSION "${info.deps."src".args.rev}"
#endif // GPU_CONFIG_GPU_LISTS_VERSION_H_
EOF
@@ -141,11 +123,11 @@ in
/* Generated by lastchange.py, do not edit.*/
#ifndef SKIA_EXT_SKIA_COMMIT_HASH_H_
#define SKIA_EXT_SKIA_COMMIT_HASH_H_
#define SKIA_COMMIT_HASH "${info.deps."src/third_party/skia".rev}-"
#define SKIA_COMMIT_HASH "${info.deps."src/third_party/skia".args.rev}-"
#endif // SKIA_EXT_SKIA_COMMIT_HASH_H_
EOF
echo -n '${info.deps."src/third_party/dawn".rev}' > gpu/webgpu/DAWN_VERSION
echo -n '${info.deps."src/third_party/dawn".args.rev}' > gpu/webgpu/DAWN_VERSION
(
cd electron
@@ -266,7 +248,7 @@ in
requiredSystemFeatures = [ "big-parallel" ];
passthru = {
inherit info fetchedDeps;
inherit info;
};
meta = with lib; {