Skip to content

Commit 6f6076c

Browse files
authored
[Backport release-24.05] chromium: fetch src, {ungoogled-,}chromium,chromedriver: 130.0.6723.116 -> 131.0.6778.85, chromedriver: build from source (#357925)
2 parents cf8dc5c + 2891716 commit 6f6076c

File tree

15 files changed

+2132
-509
lines changed

15 files changed

+2132
-509
lines changed

pkgs/applications/networking/browsers/chromium/browser.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{ lib, mkChromiumDerivation
2-
, channel, chromiumVersionAtLeast
2+
, chromiumVersionAtLeast
33
, enableWideVine, ungoogled
44
}:
55

@@ -90,7 +90,7 @@ mkChromiumDerivation (base: rec {
9090
license = if enableWideVine then lib.licenses.unfree else lib.licenses.bsd3;
9191
platforms = lib.platforms.linux;
9292
mainProgram = "chromium";
93-
hydraPlatforms = lib.optionals (channel == "stable" || channel == "ungoogled-chromium") ["aarch64-linux" "x86_64-linux"];
93+
hydraPlatforms = ["aarch64-linux" "x86_64-linux"];
9494
timeout = 172800; # 48 hours (increased from the Hydra default of 10h)
9595
};
9696
})

pkgs/applications/networking/browsers/chromium/common.nix

Lines changed: 100 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
{ stdenv, lib, fetchpatch
2-
, recompressTarball
2+
, zstd
3+
, fetchFromGitiles
4+
, fetchNpmDeps
35
, buildPackages
46
, buildPlatform
57
, pkgsBuildBuild
6-
, pkgsBuildTarget
78
# Channel data:
8-
, channel, upstream-info
9+
, upstream-info
910
# Helper functions:
1011
, chromiumVersionAtLeast, versionRange
1112

1213
# Native build inputs:
1314
, ninja, pkg-config
1415
, python3, perl
16+
, nodejs
17+
, npmHooks
1518
, which
16-
, llvmPackages_attrName
1719
, libuuid
1820
, overrideCC
1921
# postPatch:
@@ -126,7 +128,7 @@ let
126128
# https://github.com/NixOS/nixpkgs/issues/142901
127129
buildPlatformLlvmStdenv =
128130
let
129-
llvmPackages = pkgsBuildBuild.${llvmPackages_attrName};
131+
llvmPackages = pkgsBuildBuild.rustc.llvmPackages;
130132
in
131133
overrideCC llvmPackages.stdenv
132134
(llvmPackages.stdenv.cc.override {
@@ -148,19 +150,74 @@ let
148150
else throw "no chromium Rosetta Stone entry for os: ${platform.config}";
149151
};
150152

153+
isElectron = packageName == "electron";
154+
155+
chromiumDeps = lib.mapAttrs (path: args: fetchFromGitiles (removeAttrs args [ "recompress" ] // lib.optionalAttrs args.recompress or false {
156+
name = "source.tar.zstd";
157+
downloadToTemp = false;
158+
passthru.unpack = true;
159+
postFetch = ''
160+
tar \
161+
--use-compress-program="${lib.getExe zstd} -T$NIX_BUILD_CORES" \
162+
--sort=name \
163+
--mtime="1970-01-01" \
164+
--owner=root --group=root \
165+
--numeric-owner --mode=go=rX,u+rw,a-s \
166+
--remove-files \
167+
--directory="$out" \
168+
-cf "$TMPDIR/source.zstd" .
169+
mv "$TMPDIR/source.zstd" "$out"
170+
'';
171+
})) upstream-info.DEPS;
172+
173+
unpackPhaseSnippet = lib.concatStrings (lib.mapAttrsToList (path: dep:
174+
(if dep.unpack or false
175+
then ''
176+
mkdir -p ${path}
177+
pushd ${path}
178+
unpackFile ${dep}
179+
popd
180+
''
181+
else ''
182+
mkdir -p ${builtins.dirOf path}
183+
cp -r ${dep}/. ${path}
184+
''
185+
) + ''
186+
chmod u+w -R ${path}
187+
'') chromiumDeps);
188+
151189
base = rec {
152190
pname = "${lib.optionalString ungoogled "ungoogled-"}${packageName}-unwrapped";
153191
inherit (upstream-info) version;
154192
inherit packageName buildType buildPath;
155193

156-
src = recompressTarball { inherit version; inherit (upstream-info) hash; };
194+
unpackPhase = ''
195+
runHook preUnpack
196+
197+
${unpackPhaseSnippet}
198+
sourceRoot=src
199+
200+
runHook postUnpack
201+
'';
202+
203+
npmRoot = "third_party/node";
204+
npmDeps = (fetchNpmDeps {
205+
src = chromiumDeps."src";
206+
sourceRoot = npmRoot;
207+
hash = upstream-info.deps.npmHash;
208+
}).overrideAttrs (p: {
209+
nativeBuildInputs = p.nativeBuildInputs or [ ] ++ [ zstd ];
210+
});
157211

158212
nativeBuildInputs = [
159213
ninja pkg-config
160214
python3WithPackages perl
161215
which
162-
buildPackages.${llvmPackages_attrName}.bintools
216+
buildPackages.rustc.llvmPackages.bintools
163217
bison gperf
218+
] ++ lib.optionals (!isElectron) [
219+
nodejs
220+
npmHooks.npmConfigHook
164221
];
165222

166223
depsBuildBuild = [
@@ -295,7 +352,32 @@ let
295352
})
296353
];
297354

298-
postPatch = ''
355+
postPatch = lib.optionalString (!isElectron) ''
356+
ln -s ${./files/gclient_args.gni} build/config/gclient_args.gni
357+
358+
echo 'LASTCHANGE=${upstream-info.DEPS."src".rev}-refs/tags/${version}@{#0}' > build/util/LASTCHANGE
359+
echo "$SOURCE_DATE_EPOCH" > build/util/LASTCHANGE.committime
360+
361+
cat << EOF > gpu/config/gpu_lists_version.h
362+
/* Generated by lastchange.py, do not edit.*/
363+
#ifndef GPU_CONFIG_GPU_LISTS_VERSION_H_
364+
#define GPU_CONFIG_GPU_LISTS_VERSION_H_
365+
#define GPU_LISTS_VERSION "${upstream-info.DEPS."src".rev}"
366+
#endif // GPU_CONFIG_GPU_LISTS_VERSION_H_
367+
EOF
368+
369+
cat << EOF > skia/ext/skia_commit_hash.h
370+
/* Generated by lastchange.py, do not edit.*/
371+
#ifndef SKIA_EXT_SKIA_COMMIT_HASH_H_
372+
#define SKIA_EXT_SKIA_COMMIT_HASH_H_
373+
#define SKIA_COMMIT_HASH "${upstream-info.DEPS."src/third_party/skia".rev}-"
374+
#endif // SKIA_EXT_SKIA_COMMIT_HASH_H_
375+
EOF
376+
377+
echo -n '${upstream-info.DEPS."src/third_party/dawn".rev}' > gpu/webgpu/DAWN_VERSION
378+
379+
mkdir -p third_party/jdk/current/bin
380+
'' + ''
299381
# Workaround/fix for https://bugs.chromium.org/p/chromium/issues/detail?id=1313361:
300382
substituteInPlace BUILD.gn \
301383
--replace '"//infra/orchestrator:orchestrator_all",' ""
@@ -384,8 +466,8 @@ let
384466
llvmCcAndBintools = symlinkJoin {
385467
name = "llvmCcAndBintools";
386468
paths = [
387-
pkgsBuildTarget.${llvmPackages_attrName}.llvm
388-
pkgsBuildTarget.${llvmPackages_attrName}.stdenv.cc
469+
buildPackages.rustc.llvmPackages.llvm
470+
buildPackages.rustc.llvmPackages.stdenv.cc
389471
];
390472
};
391473

@@ -490,6 +572,11 @@ let
490572
# enable those features in our stable builds.
491573
preConfigure = ''
492574
export RUSTC_BOOTSTRAP=1
575+
'' + lib.optionalString (!isElectron) ''
576+
(
577+
cd third_party/node
578+
grep patch update_npm_deps | sh
579+
)
493580
'';
494581

495582
configurePhase = ''
@@ -547,11 +634,9 @@ let
547634
'';
548635

549636
passthru = {
550-
updateScript = ./update.py;
551-
chromiumDeps = {
552-
gn = gnChromium;
553-
};
554-
inherit recompressTarball;
637+
updateScript = ./update.mjs;
638+
} // lib.optionalAttrs (!isElectron) {
639+
inherit chromiumDeps npmDeps;
555640
};
556641
}
557642
# overwrite `version` with the exact same `version` from the same source,

pkgs/applications/networking/browsers/chromium/default.nix

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,28 @@
1-
{ newScope, config, stdenv, fetchurl, makeWrapper
1+
{ newScope, config, stdenv, makeWrapper
22
, buildPackages
33
, ed, gnugrep, coreutils, xdg-utils
44
, glib, gtk3, gtk4, gnome, gsettings-desktop-schemas, gn, fetchgit
55
, libva, pipewire, wayland
6-
, gcc, nspr, nss, runCommand
6+
, runCommand
77
, lib, libkrb5
88
, widevine-cdm
99
, electron-source # for warnObsoleteVersionConditional
1010

1111
# package customization
1212
# Note: enable* flags should not require full rebuilds (i.e. only affect the wrapper)
13-
, channel ? "stable"
14-
, upstream-info ? (import ./upstream-info.nix).${channel}
13+
, upstream-info ? (lib.importJSON ./info.json).${if !ungoogled then "chromium" else "ungoogled-chromium"}
1514
, proprietaryCodecs ? true
1615
, enableWideVine ? false
1716
, ungoogled ? false # Whether to build chromium or ungoogled-chromium
1817
, cupsSupport ? true
1918
, pulseSupport ? config.pulseaudio or stdenv.isLinux
2019
, commandLineArgs ? ""
21-
, pkgsBuildTarget
2220
, pkgsBuildBuild
2321
, pkgs
2422
}:
2523

2624
let
27-
# Sometimes we access `llvmPackages` via `pkgs`, and other times
28-
# via `pkgsFooBar`, so a string (attrname) is the only way to have
29-
# a single point of control over the LLVM version used.
30-
llvmPackages_attrName = "llvmPackages_17";
31-
stdenv = pkgs.${llvmPackages_attrName}.stdenv;
25+
stdenv = pkgs.rustPackages_1_80.rustc.llvmPackages.stdenv;
3226

3327
# Helper functions for changes that depend on specific versions:
3428
warnObsoleteVersionConditional = min-version: result:
@@ -48,27 +42,29 @@ let
4842
callPackage = newScope chromium;
4943

5044
chromium = rec {
51-
inherit stdenv llvmPackages_attrName upstream-info;
45+
inherit stdenv upstream-info;
5246

5347
mkChromiumDerivation = callPackage ./common.nix ({
54-
inherit channel chromiumVersionAtLeast versionRange;
48+
inherit chromiumVersionAtLeast versionRange;
5549
inherit proprietaryCodecs
5650
cupsSupport pulseSupport ungoogled;
5751
gnChromium = buildPackages.gn.overrideAttrs (oldAttrs: {
58-
inherit (upstream-info.deps.gn) version;
52+
version = if (upstream-info.deps.gn ? "version") then upstream-info.deps.gn.version else "0";
5953
src = fetchgit {
60-
inherit (upstream-info.deps.gn) url rev hash;
54+
url = "https://gn.googlesource.com/gn";
55+
inherit (upstream-info.deps.gn) rev hash;
6156
};
6257
} // lib.optionalAttrs (chromiumVersionAtLeast "127") {
6358
# Relax hardening as otherwise gn unstable 2024-06-06 and later fail with:
6459
# cc1plus: error: '-Wformat-security' ignored without '-Wformat' [-Werror=format-security]
6560
hardeningDisable = [ "format" ];
6661
});
67-
recompressTarball = callPackage ./recompress-tarball.nix { inherit chromiumVersionAtLeast; };
62+
buildPackages = buildPackages // { rustc = buildPackages.rustPackages_1_80.rustc; };
63+
pkgsBuildBuild = pkgsBuildBuild // { rustc = pkgsBuildBuild.rustPackages_1_80.rustc; };
6864
});
6965

7066
browser = callPackage ./browser.nix {
71-
inherit channel chromiumVersionAtLeast enableWideVine ungoogled;
67+
inherit chromiumVersionAtLeast enableWideVine ungoogled;
7268
};
7369

7470
# ungoogled-chromium is, contrary to its name, not a build of
@@ -79,8 +75,6 @@ let
7975
ungoogled-chromium = pkgsBuildBuild.callPackage ./ungoogled.nix {};
8076
};
8177

82-
suffix = lib.optionalString (channel != "stable" && channel != "ungoogled-chromium") ("-" + channel);
83-
8478
sandboxExecutableName = chromium.browser.passthru.sandboxExecutableName;
8579

8680
# We want users to be able to enableWideVine without rebuilding all of
@@ -98,7 +92,7 @@ let
9892

9993
in stdenv.mkDerivation {
10094
pname = lib.optionalString ungoogled "ungoogled-"
101-
+ "chromium${suffix}";
95+
+ "chromium";
10296
inherit (chromium.browser) version;
10397

10498
nativeBuildInputs = [

0 commit comments

Comments
 (0)