@@ -1,345 +0,0 @@
1−{ stdenv, lib, llvmPackages, gnChromium, ninja, which, nodejs, fetchpatch, fetchurl
2−
3−# default dependencies
4−, gnutar, bzip2, flac, speex, libopus
5−, libevent, expat, libjpeg, snappy
6−, libpng, libcap
7−, xdg_utils, yasm, nasm, minizip, libwebp
8−, libusb1, pciutils, nss, re2
9−
10−, python2Packages, perl, pkgconfig
11−, nspr, systemd, kerberos
12−, util-linux, alsaLib
13−, bison, gperf
14−, glib, gtk3, dbus-glib
15−, glibc
16−, libXScrnSaver, libXcursor, libXtst, libGLU, libGL
17−, protobuf, speechd, libXdamage, cups
18−, ffmpeg, libxslt, libxml2, at-spi2-core
19−, jre8
20−, pipewire_0_2
21−, libva
22−
23−# optional dependencies
24−, libgcrypt ? null # gnomeSupport || cupsSupport
25−, libdrm ? null, wayland ? null, mesa ? null, libxkbcommon ? null # useOzone
26−
27−# package customization
28−, useOzone ? true
29−, gnomeSupport ? false, gnome ? null
30−, gnomeKeyringSupport ? false, libgnome-keyring3 ? null
31−, proprietaryCodecs ? true
32−, cupsSupport ? true
33−, pulseSupport ? false, libpulseaudio ? null
34−, ungoogled-chromium
35−, ungoogled ? false
36−
37−, channel
38−, upstream-info
39−}:
40−
41−buildFun:
42−
43−with stdenv.lib;
44−
45−let
46− jre = jre8; # TODO: remove override https://github.com/NixOS/nixpkgs/pull/89731
47−
48− # The additional attributes for creating derivations based on the chromium
49− # source tree.
50− extraAttrs = buildFun base;
51−
52− githubPatch = commit: sha256: fetchpatch {
53− url = "https://github.com/chromium/chromium/commit/${commit}.patch";
54− inherit sha256;
55− };
56−
57− mkGnFlags =
58− let
59− # Serialize Nix types into GN types according to this document:
60− # https://source.chromium.org/gn/gn/+/master:docs/language.md
61− mkGnString = value: "\"${escape ["\"" "$" "\\"] value}\"";
62− sanitize = value:
63− if value == true then "true"
64− else if value == false then "false"
65− else if isList value then "[${concatMapStringsSep ", " sanitize value}]"
66− else if isInt value then toString value
67− else if isString value then mkGnString value
68− else throw "Unsupported type for GN value `${value}'.";
69− toFlag = key: value: "${key}=${sanitize value}";
70− in attrs: concatStringsSep " " (attrValues (mapAttrs toFlag attrs));
71−
72− # https://source.chromium.org/chromium/chromium/src/+/master:build/linux/unbundle/replace_gn_files.py
73− gnSystemLibraries = [
74− "ffmpeg"
75− "flac"
76− "libjpeg"
77− "libpng"
78− "libwebp"
79− "libxslt"
80− "opus"
81− "snappy"
82− "zlib"
83− ];
84−
85− opusWithCustomModes = libopus.override {
86− withCustomModes = true;
87− };
88−
89− defaultDependencies = [
90− bzip2 flac speex opusWithCustomModes
91− libevent expat libjpeg snappy
92− libpng libcap
93− xdg_utils minizip libwebp
94− libusb1 re2
95− ffmpeg libxslt libxml2
96− nasm
97− ];
98−
99− # build paths and release info
100− packageName = extraAttrs.packageName or extraAttrs.name;
101− buildType = "Release";
102− buildPath = "out/${buildType}";
103− libExecPath = "$out/libexec/${packageName}";
104−
105− versionRange = min-version: upto-version:
106− let inherit (upstream-info) version;
107− result = versionAtLeast version min-version && versionOlder version upto-version;
108− stable-version = (importJSON ./upstream-info.json).stable.version;
109− in if versionAtLeast stable-version upto-version
110− then warn "chromium: stable version ${stable-version} is newer than a patchset bounded at ${upto-version}. You can safely delete it."
111− result
112− else result;
113−
114− ungoogler =
115− let versionEntry = (import ./ungoogled-src.nix)."${upstream-info.version}";
116− in ungoogled-chromium {
117− inherit (versionEntry) rev sha256;
118− };
119− base = rec {
120− name = "${packageName}-unwrapped-${version}";
121− inherit (upstream-info) version;
122− inherit channel packageName buildType buildPath;
123−
124− src = fetchurl {
125− url = "https://commondatastorage.googleapis.com/chromium-browser-official/chromium-${version}.tar.xz";
126− inherit (upstream-info) sha256;
127− };
128−
129− nativeBuildInputs = [
130− llvmPackages.lldClang.bintools
131− ninja which python2Packages.python perl pkgconfig
132− python2Packages.ply python2Packages.jinja2 nodejs
133− gnutar python2Packages.setuptools
134− ];
135−
136− buildInputs = defaultDependencies ++ [
137− nspr nss systemd
138− util-linux alsaLib
139− bison gperf kerberos
140− glib gtk3 dbus-glib
141− libXScrnSaver libXcursor libXtst libGLU libGL
142− pciutils protobuf speechd libXdamage at-spi2-core
143− jre
144− pipewire_0_2
145− libva
146− ] ++ optional gnomeKeyringSupport libgnome-keyring3
147− ++ optionals gnomeSupport [ gnome.GConf libgcrypt ]
148− ++ optionals cupsSupport [ libgcrypt cups ]
149− ++ optional pulseSupport libpulseaudio
150− ++ optionals useOzone [ libdrm wayland mesa.drivers libxkbcommon ];
151−
152− patches = [
153− ./patches/no-build-timestamps.patch # Optional patch to use SOURCE_DATE_EPOCH in compute_build_timestamp.py (should be upstreamed)
154− ./patches/widevine-79.patch # For bundling Widevine (DRM), might be replaceable via bundle_widevine_cdm=true in gnFlags
155− # ++ optional (versionRange "68" "72") ( githubPatch "<patch>" "0000000000000000000000000000000000000000000000000000000000000000" )
156− ];
157−
158− postPatch = ''
159− # remove unused third-party
160− for lib in ${toString gnSystemLibraries}; do
161− if [ -d "third_party/$lib" ]; then
162− find "third_party/$lib" -type f \
163− \! -path "third_party/$lib/chromium/*" \
164− \! -path "third_party/$lib/google/*" \
165− \! -path "third_party/harfbuzz-ng/utils/hb_scoped.h" \
166− \! -regex '.*\.\(gn\|gni\|isolate\)' \
167− -delete
168− fi
169− done
170−
171− # Required for patchShebangs (unsupported interpreter directive, basename: invalid option -- '*', etc.):
172− substituteInPlace native_client/SConstruct --replace "#! -*- python -*-" ""
173− if [ -e third_party/harfbuzz-ng/src/src/update-unicode-tables.make ]; then
174− substituteInPlace third_party/harfbuzz-ng/src/src/update-unicode-tables.make \
175− --replace "/usr/bin/env -S make -f" "/usr/bin/make -f"
176− fi
177−
178− # We want to be able to specify where the sandbox is via CHROME_DEVEL_SANDBOX
179− substituteInPlace sandbox/linux/suid/client/setuid_sandbox_host.cc \
180− --replace \
181− 'return sandbox_binary;' \
182− 'return base::FilePath(GetDevelSandboxPath());'
183−
184− substituteInPlace services/audio/audio_sandbox_hook_linux.cc \
185− --replace \
186− '/usr/share/alsa/' \
187− '${alsaLib}/share/alsa/' \
188− --replace \
189− '/usr/lib/x86_64-linux-gnu/gconv/' \
190− '${glibc}/lib/gconv/' \
191− --replace \
192− '/usr/share/locale/' \
193− '${glibc}/share/locale/'
194−
195− sed -i -e 's@"\(#!\)\?.*xdg-@"\1${xdg_utils}/bin/xdg-@' \
196− chrome/browser/shell_integration_linux.cc
197−
198− sed -i -e '/lib_loader.*Load/s!"\(libudev\.so\)!"${lib.getLib systemd}/lib/\1!' \
199− device/udev_linux/udev?_loader.cc
200−
201− sed -i -e '/libpci_loader.*Load/s!"\(libpci\.so\)!"${pciutils}/lib/\1!' \
202− gpu/config/gpu_info_collector_linux.cc
203−
204− # Allow to put extensions into the system-path.
205− sed -i -e 's,/usr,/run/current-system/sw,' chrome/common/chrome_paths.cc
206−
207− patchShebangs .
208− # use our own nodejs
209− mkdir -p third_party/node/linux/node-linux-x64/bin
210− ln -s "$(command -v node)" third_party/node/linux/node-linux-x64/bin/node
211−
212− # Allow building against system libraries in official builds
213− sed -i 's/OFFICIAL_BUILD/GOOGLE_CHROME_BUILD/' tools/generate_shim_headers/generate_shim_headers.py
214−
215− '' + optionalString stdenv.isAarch64 ''
216− substituteInPlace build/toolchain/linux/BUILD.gn \
217− --replace 'toolprefix = "aarch64-linux-gnu-"' 'toolprefix = ""'
218− '' + optionalString ungoogled ''
219− ${ungoogler}/utils/prune_binaries.py . ${ungoogler}/pruning.list || echo "some errors"
220− ${ungoogler}/utils/patches.py . ${ungoogler}/patches
221− ${ungoogler}/utils/domain_substitution.py apply -r ${ungoogler}/domain_regex.list -f ${ungoogler}/domain_substitution.list -c ./ungoogled-domsubcache.tar.gz .
222− '';
223−
224− gnFlags = mkGnFlags ({
225− custom_toolchain = "//build/toolchain/linux/unbundle:default";
226− host_toolchain = "//build/toolchain/linux/unbundle:default";
227− is_official_build = true;
228−
229− use_vaapi = !stdenv.isAarch64; # TODO: Remove once M88 is released
230− use_sysroot = false;
231− use_gnome_keyring = gnomeKeyringSupport;
232− use_gio = gnomeSupport;
233− # ninja: error: '../../native_client/toolchain/linux_x86/pnacl_newlib/bin/x86_64-nacl-objcopy',
234− # needed by 'nacl_irt_x86_64.nexe', missing and no known rule to make it
235− enable_nacl = false;
236− # Enabling the Widevine component here doesn't affect whether we can
237− # redistribute the chromium package; the Widevine component is either
238− # added later in the wrapped -wv build or downloaded from Google.
239− enable_widevine = true;
240− use_cups = cupsSupport;
241− # Provides the enable-webrtc-pipewire-capturer flag to support Wayland screen capture.
242− rtc_use_pipewire = true;
243−
244− treat_warnings_as_errors = false;
245− clang_use_chrome_plugins = false;
246− blink_symbol_level = 0;
247− symbol_level = 0;
248− fieldtrial_testing_like_official_build = true;
249−
250− # Google API keys, see:
251− # http://www.chromium.org/developers/how-tos/api-keys
252− # Note: These are for NixOS/nixpkgs use ONLY. For your own distribution,
253− # please get your own set of keys.
254− google_api_key = "AIzaSyDGi15Zwl11UNe6Y-5XW_upsfyw31qwZPI";
255− google_default_client_id = "404761575300.apps.googleusercontent.com";
256− google_default_client_secret = "9rIFQjfnkykEmqb6FfjJQD1D";
257− } // optionalAttrs proprietaryCodecs {
258− # enable support for the H.264 codec
259− proprietary_codecs = true;
260− enable_hangout_services_extension = true;
261− ffmpeg_branding = "Chrome";
262− } // optionalAttrs pulseSupport {
263− use_pulseaudio = true;
264− link_pulseaudio = true;
265− } // optionalAttrs useOzone {
266− use_ozone = true;
267− use_xkbcommon = true;
268− use_glib = true;
269− use_gtk = true;
270− use_system_libwayland = true;
271− use_system_minigbm = true;
272− use_system_libdrm = true;
273− system_wayland_scanner_path = "${wayland}/bin/wayland-scanner";
274− } // optionalAttrs ungoogled {
275− chrome_pgo_phase = 0;
276− enable_hangout_services_extension = false;
277− enable_js_type_check = false;
278− enable_mdns = false;
279− enable_nacl_nonsfi = false;
280− enable_one_click_signin = false;
281− enable_reading_list = false;
282− enable_remoting = false;
283− enable_reporting = false;
284− enable_service_discovery = false;
285− exclude_unwind_tables = true;
286− google_api_key = "";
287− google_default_client_id = "";
288− google_default_client_secret = "";
289− safe_browsing_mode = 0;
290− use_official_google_api_keys = false;
291− use_unofficial_version_number = false;
292− } // (extraAttrs.gnFlags or {}));
293−
294− configurePhase = ''
295− runHook preConfigure
296−
297− # This is to ensure expansion of $out.
298− libExecPath="${libExecPath}"
299− python build/linux/unbundle/replace_gn_files.py --system-libraries ${toString gnSystemLibraries}
300− ${gnChromium}/bin/gn gen --args=${escapeShellArg gnFlags} out/Release | tee gn-gen-outputs.txt
301−
302− # Fail if `gn gen` contains a WARNING.
303− grep -o WARNING gn-gen-outputs.txt && echo "Found gn WARNING, exiting nix build" && exit 1
304−
305− runHook postConfigure
306− '';
307−
308− # Don't spam warnings about unknown warning options. This is useful because
309− # our Clang is always older than Chromium's and the build logs have a size
310− # of approx. 25 MB without this option (and this saves e.g. 66 %).
311− NIX_CFLAGS_COMPILE = "-Wno-unknown-warning-option";
312−
313− buildPhase = let
314− buildCommand = target: ''
315− ninja -C "${buildPath}" -j$NIX_BUILD_CORES -l$NIX_BUILD_CORES "${target}"
316− (
317− source chrome/installer/linux/common/installer.include
318− PACKAGE=$packageName
319− MENUNAME="Chromium"
320− process_template chrome/app/resources/manpage.1.in "${buildPath}/chrome.1"
321− )
322− '';
323− targets = extraAttrs.buildTargets or [];
324− commands = map buildCommand targets;
325− in concatStringsSep "\n" commands;
326−
327− postFixup = ''
328− # Make sure that libGLESv2 is found by dlopen (if using EGL).
329− chromiumBinary="$libExecPath/$packageName"
330− origRpath="$(patchelf --print-rpath "$chromiumBinary")"
331− patchelf --set-rpath "${libGL}/lib:$origRpath" "$chromiumBinary"
332− '';
333−
334− passthru = {
335− updateScript = ./update.py;
336− chromiumDeps = {
337− gn = gnChromium;
338− };
339− };
340− };
341−
342−# Remove some extraAttrs we supplied to the base attributes already.
343−in stdenv.mkDerivation (base // removeAttrs extraAttrs [
344− "name" "gnFlags" "buildTargets"
345−] // { passthru = base.passthru // (extraAttrs.passthru or {}); })