From 9f26152cc3d7e90c7f2a5908de4d1aab069ed6ce Mon Sep 17 00:00:00 2001 From: Yureka Date: Wed, 13 Mar 2024 20:18:36 +0100 Subject: [PATCH] electron: small refactors - provide passthru.fetchedDeps for debugging - adapt gn args for latest electron versions - fix mechanism for applying patches for latest electron versions --- pkgs/development/tools/electron/common.nix | 49 +++++++++++++------ .../tools/electron/disable-screen-ai.patch | 16 ++++++ 2 files changed, 50 insertions(+), 15 deletions(-) create mode 100644 pkgs/development/tools/electron/disable-screen-ai.patch diff --git a/pkgs/development/tools/electron/common.nix b/pkgs/development/tools/electron/common.nix index 225b10c56915..9881c26f659e 100644 --- a/pkgs/development/tools/electron/common.nix +++ b/pkgs/development/tools/electron/common.nix @@ -22,6 +22,8 @@ let opts = removeAttrs dep ["fetcher"]; in pkgs.${dep.fetcher} opts; + fetchedDeps = lib.mapAttrs (name: fetchdep) info.deps; + in (chromium.override { upstream-info = info.chromium; }).mkDerivation (base: { packageName = "electron"; inherit (info) version; @@ -31,11 +33,11 @@ in (chromium.override { upstream-info = info.chromium; }).mkDerivation (base: { buildInputs = base.buildInputs ++ [ libnotify ]; electronOfflineCache = fetchYarnDeps { - yarnLock = (fetchdep info.deps."src/electron") + "/yarn.lock"; + yarnLock = fetchedDeps."src/electron" + "/yarn.lock"; sha256 = info.electron_yarn_hash; }; npmDeps = fetchNpmDeps rec { - src = fetchdep info.deps."src"; + src = fetchedDeps."src"; # Assume that the fetcher always unpack the source, # based on update.py sourceRoot = "${src.name}/third_party/node"; @@ -44,14 +46,23 @@ in (chromium.override { upstream-info = info.chromium; }).mkDerivation (base: { src = null; + patches = base.patches ++ lib.optional (lib.versionAtLeast info.version "29") + (substituteAll { + # disable a component that requires CIPD blobs + name = "disable-screen-ai.patch"; + src = ./disable-screen-ai.patch; + inherit (info) version; + }) + ; + unpackPhase = '' runHook preUnpack '' + ( lib.concatStrings (lib.mapAttrsToList (path: dep: '' mkdir -p ${builtins.dirOf path} - cp -r ${fetchdep dep}/. ${path} + cp -r ${dep}/. ${path} chmod u+w -R ${path} - '') info.deps) + '') fetchedDeps) ) + '' sourceRoot=src runHook postUnpack @@ -109,13 +120,14 @@ in (chromium.override { upstream-info = info.chromium; }).mkDerivation (base: { cd .. PATH=$PATH:${lib.makeBinPath (with pkgsBuildHost; [ jq git ])} config=src/electron/patches/config.json - for key in $(jq -r "keys[]" $config) + for entry in $(cat $config | jq -c ".[]") do - value=$(jq -r ".\"$key\"" $config) - for patch in $(cat $key/.patches) + patch_dir=$(echo $entry | jq -r ".patch_dir") + repo=$(echo $entry | jq -r ".repo") + for patch in $(cat $patch_dir/.patches) do - echo applying in $value: $patch - git apply -p1 --directory=$value --exclude='src/third_party/blink/web_tests/*' $key/$patch + echo applying in $repo: $patch + git apply -p1 --directory=$repo --exclude='src/third_party/blink/web_tests/*' $patch_dir/$patch done done ) @@ -142,7 +154,6 @@ in (chromium.override { upstream-info = info.chromium; }).mkDerivation (base: { v8_promise_internal_field_count = 1; v8_embedder_string = "-electron.0"; v8_enable_snapshot_native_code_counters = false; - v8_scriptormodule_legacy_lifetime = true; v8_enable_javascript_promise_hooks = true; enable_cdm_host_verification = false; proprietary_codecs = true; @@ -155,10 +166,18 @@ in (chromium.override { upstream-info = info.chromium; }).mkDerivation (base: { enable_cet_shadow_stack = false; is_cfi = false; use_qt = false; - - enable_widevine = false; use_perfetto_client_library = false; - enable_check_raw_ptr_fields = false; + v8_builtins_profiling_log_file = ""; + enable_dangling_raw_ptr_checks = false; + } // lib.optionalAttrs (lib.versionAtLeast info.version "28") { + dawn_use_built_dxc = false; + v8_enable_private_mapping_fork_optimization = true; + } // lib.optionalAttrs (lib.versionAtLeast info.version "29") { + v8_expose_public_symbols = true; + } // { + + # other + enable_widevine = false; override_electron_version = info.version; }; @@ -174,11 +193,11 @@ in (chromium.override { upstream-info = info.chromium; }).mkDerivation (base: { requiredSystemFeatures = [ "big-parallel" ]; passthru = { - inherit info; + inherit info fetchedDeps; headers = stdenv.mkDerivation rec { name = "node-v${info.node}-headers.tar.gz"; nativeBuildInputs = [ python3 ]; - src = fetchdep info.deps."src/third_party/electron_node"; + src = fetchedDeps."src/third_party/electron_node"; buildPhase = '' runHook preBuild make tar-headers diff --git a/pkgs/development/tools/electron/disable-screen-ai.patch b/pkgs/development/tools/electron/disable-screen-ai.patch new file mode 100644 index 000000000000..0738942fded0 --- /dev/null +++ b/pkgs/development/tools/electron/disable-screen-ai.patch @@ -0,0 +1,16 @@ +--- a/chrome/test/BUILD.gn ++++ b/chrome/test/BUILD.gn +@@ -3114,13 +3114,6 @@ if (!is_android && !is_fuchsia) { + "//pdf/loader", + ] + +- if (is_linux) { +- # Add a data dependency for pdf_extension_accessibility_test.cc to +- # notify testing builders that this test needs this library, which will +- # need to be downloaded from CIPD as defined in //DEPS. +- data_deps += [ "//third_party/screen-ai:screen_ai_linux" ] +- } +- + if (enable_printing) { + sources += [ "../browser/pdf/pdf_extension_printing_test.cc" ] +