Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport release-24.05] chromium: fetch src, {ungoogled-,}chromium,chromedriver: 130.0.6723.116 -> 131.0.6778.85, chromedriver: build from source #357925

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkgs/applications/networking/browsers/chromium/browser.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ lib, mkChromiumDerivation
, channel, chromiumVersionAtLeast
, chromiumVersionAtLeast
, enableWideVine, ungoogled
}:

Expand Down Expand Up @@ -90,7 +90,7 @@ mkChromiumDerivation (base: rec {
license = if enableWideVine then lib.licenses.unfree else lib.licenses.bsd3;
platforms = lib.platforms.linux;
mainProgram = "chromium";
hydraPlatforms = lib.optionals (channel == "stable" || channel == "ungoogled-chromium") ["aarch64-linux" "x86_64-linux"];
hydraPlatforms = ["aarch64-linux" "x86_64-linux"];
timeout = 172800; # 48 hours (increased from the Hydra default of 10h)
};
})
115 changes: 100 additions & 15 deletions pkgs/applications/networking/browsers/chromium/common.nix
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
{ stdenv, lib, fetchpatch
, recompressTarball
, zstd
, fetchFromGitiles
, fetchNpmDeps
, buildPackages
, buildPlatform
, pkgsBuildBuild
, pkgsBuildTarget
# Channel data:
, channel, upstream-info
, upstream-info
# Helper functions:
, chromiumVersionAtLeast, versionRange

# Native build inputs:
, ninja, pkg-config
, python3, perl
, nodejs
, npmHooks
, which
, llvmPackages_attrName
, libuuid
, overrideCC
# postPatch:
Expand Down Expand Up @@ -126,7 +128,7 @@ let
# https://github.com/NixOS/nixpkgs/issues/142901
buildPlatformLlvmStdenv =
let
llvmPackages = pkgsBuildBuild.${llvmPackages_attrName};
llvmPackages = pkgsBuildBuild.rustc.llvmPackages;
in
overrideCC llvmPackages.stdenv
(llvmPackages.stdenv.cc.override {
Expand All @@ -148,19 +150,74 @@ let
else throw "no chromium Rosetta Stone entry for os: ${platform.config}";
};

isElectron = packageName == "electron";

chromiumDeps = lib.mapAttrs (path: args: fetchFromGitiles (removeAttrs args [ "recompress" ] // lib.optionalAttrs args.recompress or false {
name = "source.tar.zstd";
downloadToTemp = false;
passthru.unpack = true;
postFetch = ''
tar \
--use-compress-program="${lib.getExe zstd} -T$NIX_BUILD_CORES" \
--sort=name \
--mtime="1970-01-01" \
--owner=root --group=root \
--numeric-owner --mode=go=rX,u+rw,a-s \
--remove-files \
--directory="$out" \
-cf "$TMPDIR/source.zstd" .
mv "$TMPDIR/source.zstd" "$out"
'';
})) upstream-info.DEPS;

unpackPhaseSnippet = lib.concatStrings (lib.mapAttrsToList (path: dep:
(if dep.unpack or false
then ''
mkdir -p ${path}
pushd ${path}
unpackFile ${dep}
popd
''
else ''
mkdir -p ${builtins.dirOf path}
cp -r ${dep}/. ${path}
''
) + ''
chmod u+w -R ${path}
'') chromiumDeps);

base = rec {
pname = "${lib.optionalString ungoogled "ungoogled-"}${packageName}-unwrapped";
inherit (upstream-info) version;
inherit packageName buildType buildPath;

src = recompressTarball { inherit version; inherit (upstream-info) hash; };
unpackPhase = ''
runHook preUnpack

${unpackPhaseSnippet}
sourceRoot=src

runHook postUnpack
'';

npmRoot = "third_party/node";
npmDeps = (fetchNpmDeps {
src = chromiumDeps."src";
sourceRoot = npmRoot;
hash = upstream-info.deps.npmHash;
}).overrideAttrs (p: {
nativeBuildInputs = p.nativeBuildInputs or [ ] ++ [ zstd ];
});

nativeBuildInputs = [
ninja pkg-config
python3WithPackages perl
which
buildPackages.${llvmPackages_attrName}.bintools
buildPackages.rustc.llvmPackages.bintools
bison gperf
] ++ lib.optionals (!isElectron) [
nodejs
npmHooks.npmConfigHook
];

depsBuildBuild = [
Expand Down Expand Up @@ -295,7 +352,32 @@ let
})
];

postPatch = ''
postPatch = lib.optionalString (!isElectron) ''
ln -s ${./files/gclient_args.gni} build/config/gclient_args.gni

echo 'LASTCHANGE=${upstream-info.DEPS."src".rev}-refs/tags/${version}@{#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 "${upstream-info.DEPS."src".rev}"
#endif // GPU_CONFIG_GPU_LISTS_VERSION_H_
EOF

cat << EOF > skia/ext/skia_commit_hash.h
/* 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 "${upstream-info.DEPS."src/third_party/skia".rev}-"
#endif // SKIA_EXT_SKIA_COMMIT_HASH_H_
EOF

echo -n '${upstream-info.DEPS."src/third_party/dawn".rev}' > gpu/webgpu/DAWN_VERSION

mkdir -p third_party/jdk/current/bin
'' + ''
# Workaround/fix for https://bugs.chromium.org/p/chromium/issues/detail?id=1313361:
substituteInPlace BUILD.gn \
--replace '"//infra/orchestrator:orchestrator_all",' ""
Expand Down Expand Up @@ -384,8 +466,8 @@ let
llvmCcAndBintools = symlinkJoin {
name = "llvmCcAndBintools";
paths = [
pkgsBuildTarget.${llvmPackages_attrName}.llvm
pkgsBuildTarget.${llvmPackages_attrName}.stdenv.cc
buildPackages.rustc.llvmPackages.llvm
buildPackages.rustc.llvmPackages.stdenv.cc
];
};

Expand Down Expand Up @@ -490,6 +572,11 @@ let
# enable those features in our stable builds.
preConfigure = ''
export RUSTC_BOOTSTRAP=1
'' + lib.optionalString (!isElectron) ''
(
cd third_party/node
grep patch update_npm_deps | sh
)
'';

configurePhase = ''
Expand Down Expand Up @@ -547,11 +634,9 @@ let
'';

passthru = {
updateScript = ./update.py;
chromiumDeps = {
gn = gnChromium;
};
inherit recompressTarball;
updateScript = ./update.mjs;
} // lib.optionalAttrs (!isElectron) {
inherit chromiumDeps npmDeps;
};
}
# overwrite `version` with the exact same `version` from the same source,
Expand Down
32 changes: 13 additions & 19 deletions pkgs/applications/networking/browsers/chromium/default.nix
Original file line number Diff line number Diff line change
@@ -1,34 +1,28 @@
{ newScope, config, stdenv, fetchurl, makeWrapper
{ newScope, config, stdenv, makeWrapper
, buildPackages
, ed, gnugrep, coreutils, xdg-utils
, glib, gtk3, gtk4, gnome, gsettings-desktop-schemas, gn, fetchgit
, libva, pipewire, wayland
, gcc, nspr, nss, runCommand
, runCommand
, lib, libkrb5
, widevine-cdm
, electron-source # for warnObsoleteVersionConditional

# package customization
# Note: enable* flags should not require full rebuilds (i.e. only affect the wrapper)
, channel ? "stable"
, upstream-info ? (import ./upstream-info.nix).${channel}
, upstream-info ? (lib.importJSON ./info.json).${if !ungoogled then "chromium" else "ungoogled-chromium"}
, proprietaryCodecs ? true
, enableWideVine ? false
, ungoogled ? false # Whether to build chromium or ungoogled-chromium
, cupsSupport ? true
, pulseSupport ? config.pulseaudio or stdenv.isLinux
, commandLineArgs ? ""
, pkgsBuildTarget
, pkgsBuildBuild
, pkgs
}:

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

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

chromium = rec {
inherit stdenv llvmPackages_attrName upstream-info;
inherit stdenv upstream-info;

mkChromiumDerivation = callPackage ./common.nix ({
inherit channel chromiumVersionAtLeast versionRange;
inherit chromiumVersionAtLeast versionRange;
inherit proprietaryCodecs
cupsSupport pulseSupport ungoogled;
gnChromium = buildPackages.gn.overrideAttrs (oldAttrs: {
inherit (upstream-info.deps.gn) version;
version = if (upstream-info.deps.gn ? "version") then upstream-info.deps.gn.version else "0";
src = fetchgit {
inherit (upstream-info.deps.gn) url rev hash;
url = "https://gn.googlesource.com/gn";
inherit (upstream-info.deps.gn) rev hash;
};
} // lib.optionalAttrs (chromiumVersionAtLeast "127") {
# Relax hardening as otherwise gn unstable 2024-06-06 and later fail with:
# cc1plus: error: '-Wformat-security' ignored without '-Wformat' [-Werror=format-security]
hardeningDisable = [ "format" ];
});
recompressTarball = callPackage ./recompress-tarball.nix { inherit chromiumVersionAtLeast; };
buildPackages = buildPackages // { rustc = buildPackages.rustPackages_1_80.rustc; };
pkgsBuildBuild = pkgsBuildBuild // { rustc = pkgsBuildBuild.rustPackages_1_80.rustc; };
});

browser = callPackage ./browser.nix {
inherit channel chromiumVersionAtLeast enableWideVine ungoogled;
inherit chromiumVersionAtLeast enableWideVine ungoogled;
};

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

suffix = lib.optionalString (channel != "stable" && channel != "ungoogled-chromium") ("-" + channel);

sandboxExecutableName = chromium.browser.passthru.sandboxExecutableName;

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

in stdenv.mkDerivation {
pname = lib.optionalString ungoogled "ungoogled-"
+ "chromium${suffix}";
+ "chromium";
inherit (chromium.browser) version;

nativeBuildInputs = [
Expand Down
Loading
Loading