1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2019, 2020, 2021, 2022 Marius Bakke <marius@gnu.org>
3 ;;; Copyright © 2019 Alex Griffin <a@ajgrf.com>
5 ;;; This file is part of GNU Guix.
7 ;;; GNU Guix is free software; you can redistribute it and/or modify it
8 ;;; under the terms of the GNU General Public License as published by
9 ;;; the Free Software Foundation; either version 3 of the License, or (at
10 ;;; your option) any later version.
12 ;;; GNU Guix is distributed in the hope that it will be useful, but
13 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;;; GNU General Public License for more details.
17 ;;; You should have received a copy of the GNU General Public License
18 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20 (define-module (gnu packages chromium)
21 #:use-module ((guix licenses) #:prefix license:)
22 #:use-module (guix packages)
23 #:use-module (guix gexp)
24 #:use-module (guix download)
25 #:use-module (guix git-download)
26 #:use-module (guix utils)
27 #:use-module (guix build-system gnu)
28 #:use-module (guix build-system trivial)
29 #:use-module (gnu packages)
30 #:use-module (gnu packages assembly)
31 #:use-module (gnu packages base)
32 #:use-module (gnu packages bash)
33 #:use-module (gnu packages bison)
34 #:use-module (gnu packages build-tools)
35 #:use-module (gnu packages compression)
36 #:use-module (gnu packages cups)
37 #:use-module (gnu packages curl)
38 #:use-module (gnu packages fontutils)
39 #:use-module (gnu packages freedesktop)
40 #:use-module (gnu packages ghostscript)
41 #:use-module (gnu packages gl)
42 #:use-module (gnu packages glib)
43 #:use-module (gnu packages gnome)
44 #:use-module (gnu packages gperf)
45 #:use-module (gnu packages gtk)
46 #:use-module (gnu packages icu4c)
47 #:use-module (gnu packages image)
48 #:use-module (gnu packages libevent)
49 #:use-module (gnu packages libffi)
50 #:use-module (gnu packages linux)
51 #:use-module (gnu packages llvm)
52 #:use-module (gnu packages kerberos)
53 #:use-module (gnu packages maths)
54 #:use-module (gnu packages ninja)
55 #:use-module (gnu packages node)
56 #:use-module (gnu packages nss)
57 #:use-module (gnu packages pciutils)
58 #:use-module (gnu packages pkg-config)
59 #:use-module (gnu packages protobuf)
60 #:use-module (gnu packages pulseaudio)
61 #:use-module (gnu packages python)
62 #:use-module (gnu packages python-web)
63 #:use-module (gnu packages python-xyz)
64 #:use-module (gnu packages regex)
65 #:use-module (gnu packages serialization)
66 #:use-module (gnu packages speech)
67 #:use-module (gnu packages valgrind)
68 #:use-module (gnu packages vulkan)
69 #:use-module (gnu packages video)
70 #:use-module (gnu packages xiph)
71 #:use-module (gnu packages xml)
72 #:use-module (gnu packages xdisorg)
73 #:use-module (gnu packages xorg)
74 #:use-module (ice-9 match)
75 #:use-module (srfi srfi-1))
77 (define %preserved-third-party-files
78 '("base/third_party/cityhash" ;Expat
79 "base/third_party/double_conversion" ;BSD-3
80 "base/third_party/dynamic_annotations" ;BSD-2
81 "base/third_party/icu" ;Unicode, X11-style
82 "base/third_party/superfasthash" ;BSD-3
83 "base/third_party/symbolize" ;BSD-3
84 "base/third_party/xdg_mime" ;LGPL2.0+ or Academic 2.0
85 "base/third_party/xdg_user_dirs" ;Expat
86 "chrome/third_party/mozilla_security_manager" ;MPL-1.1/GPL2+/LGPL2.1+
87 "courgette/third_party/bsdiff" ;BSD-2, BSD protection license
88 "courgette/third_party/divsufsort" ;Expat
89 "net/third_party/mozilla_security_manager" ;MPL-1.1/GPL2+/LGPL2.1+
90 "net/third_party/nss" ;MPL-2.0
91 "net/third_party/quiche" ;BSD-3
92 "net/third_party/uri_template" ;ASL2.0
93 "third_party/abseil-cpp" ;ASL2.0
94 "third_party/angle" ;BSD-3
95 "third_party/angle/src/common/third_party/base" ;BSD-3
96 "third_party/angle/src/common/third_party/smhasher" ;Public domain
97 "third_party/angle/src/common/third_party/xxhash" ;BSD-2
98 "third_party/angle/src/third_party/libXNVCtrl" ;Expat
99 "third_party/angle/src/third_party/trace_event" ;BSD-3
100 "third_party/angle/src/third_party/volk" ;Expat
101 "third_party/apple_apsl" ;APSL2.0
102 "third_party/axe-core" ;MPL2.0
103 "third_party/blink" ;BSD-3, LGPL2+
104 "third_party/boringssl" ;OpenSSL/ISC (Google additions are ISC)
105 "third_party/boringssl/src/third_party/fiat" ;Expat
106 "third_party/breakpad" ;BSD-3
107 "third_party/brotli" ;Expat
108 "third_party/catapult" ;BSD-3
109 "third_party/catapult/common/py_vulcanize/third_party/rcssmin" ;ASL2.0
110 "third_party/catapult/common/py_vulcanize/third_party/rjsmin" ;ASL2.0
111 "third_party/catapult/third_party/polymer" ;BSD-3
112 "third_party/catapult/third_party/six" ;Expat
113 ;; XXX: This is a minified version of <https://d3js.org/>.
114 "third_party/catapult/tracing/third_party/d3" ;BSD-3
115 "third_party/catapult/tracing/third_party/gl-matrix" ;Expat
116 "third_party/catapult/tracing/third_party/jpeg-js" ;ASL2.0
117 ;; XXX: Minified version of <https://github.com/Stuk/jszip>.
118 "third_party/catapult/tracing/third_party/jszip" ;Expat or GPL3
119 "third_party/catapult/tracing/third_party/mannwhitneyu" ;Expat
120 "third_party/catapult/tracing/third_party/oboe" ;BSD-2
121 ;; XXX: Minified version of <https://github.com/nodeca/pako>.
122 "third_party/catapult/tracing/third_party/pako" ;Expat
123 "third_party/ced" ;BSD-3
124 "third_party/cld_3" ;ASL2.0
125 "third_party/closure_compiler" ;ASL2.0
126 "third_party/cpuinfo" ;BSD-2
127 "third_party/crashpad" ;ASL2.0
128 "third_party/crashpad/crashpad/third_party/lss" ;ASL2.0
129 "third_party/crashpad/crashpad/third_party/zlib/zlib_crashpad.h" ;Zlib
130 "third_party/crc32c" ;BSD-3
131 "third_party/cros_system_api" ;BSD-3
132 "third_party/dav1d" ;BSD-2
133 "third_party/dawn" ;ASL2.0
134 ;; TODO: can likely be unbundled when Vulkan is updated.
135 "third_party/dawn/third_party/khronos" ;ASL2.0
136 "third_party/dawn/third_party/gn/webgpu-cts" ;BSD-3
137 "third_party/depot_tools/owners.py" ;BSD-3
138 "third_party/devtools-frontend" ;BSD-3
139 "third_party/devtools-frontend/src/front_end/third_party/acorn" ;Expat
140 "third_party/devtools-frontend/src/front_end/third_party\
141 /additional_readme_paths.json" ;no explicit license; trivial
142 "third_party/devtools-frontend/src/front_end/third_party/axe-core" ;MPL2.0
143 "third_party/devtools-frontend/src/front_end/third_party/chromium" ;BSD-3
144 "third_party/devtools-frontend/src/front_end/third_party/codemirror" ;Expat
145 "third_party/devtools-frontend/src/front_end/third_party/diff" ;ASL2.0
146 "third_party/devtools-frontend/src/front_end/third_party/i18n" ;ASL2.0
147 "third_party/devtools-frontend/src/front_end/third_party/intl-messageformat" ;BSD-3
148 "third_party/devtools-frontend/src/front_end/third_party/lighthouse" ;ASL2.0
149 "third_party/devtools-frontend/src/front_end/third_party/lit-html" ;BSD-3
150 "third_party/devtools-frontend/src/front_end/third_party/lodash-isequal" ;Expat
151 "third_party/devtools-frontend/src/front_end/third_party/marked" ;Expat, BSD-3
152 "third_party/devtools-frontend/src/front_end/third_party/puppeteer" ;ASL2.0
153 "third_party/devtools-frontend/src/front_end/third_party/wasmparser" ;ASL2.0
154 "third_party/devtools-frontend/src/third_party/pyjson5" ;ASL2.0
155 "third_party/devtools-frontend/src/third_party/typescript" ;ASL2.0
156 "third_party/distributed_point_functions" ;ASL2.0
157 "third_party/dom_distiller_js" ;BSD-3
158 "third_party/eigen3" ;MPL2.0
159 "third_party/emoji-segmenter" ;ASL2.0
160 "third_party/farmhash" ;Expat
161 "third_party/fdlibm" ;non-copyleft
162 "third_party/fft2d" ;non-copyleft
163 "third_party/flatbuffers" ;ASL2.0
164 "third_party/fusejs" ;ASL2.0
165 "third_party/gemmlowp" ;ASL2.0
166 "third_party/google_input_tools" ;ASL2.0
167 "third_party/google_input_tools/third_party/closure_library" ;ASL2.0
168 "third_party/google_input_tools/third_party/closure_library/third_party/closure" ;Expat
169 "third_party/googletest" ;BSD-3
170 "third_party/harfbuzz-ng" ;Expat
171 "third_party/highway" ;ASL2.0
172 "third_party/hunspell" ;MPL1.1/GPL2+/LGPL2.1+
173 "third_party/iccjpeg" ;IJG
174 "third_party/inspector_protocol" ;BSD-3
175 "third_party/jinja2" ;BSD-3
176 "third_party/jstemplate" ;ASL2.0
177 "third_party/khronos" ;Expat, SGI
178 "third_party/leveldatabase" ;BSD-3
179 "third_party/libavif" ;BSD-2
180 "third_party/libaddressinput" ;ASL2.0
181 "third_party/libaom" ;BSD-2 or "Alliance for Open Media Patent License 1.0"
182 "third_party/libaom/source/libaom/third_party/fastfeat" ;BSD-3
183 "third_party/libaom/source/libaom/third_party/vector" ;Expat
184 "third_party/libaom/source/libaom/third_party/x86inc" ;ISC
185 "third_party/libjxl" ;ASL2.0
186 "third_party/libgav1" ;ASL2.0
187 "third_party/libgifcodec" ;MPL1.1/GPL2+/LGPL2.1+, BSD-3, BSD-2
188 "third_party/libjingle_xmpp" ;BSD-3
189 "third_party/libphonenumber" ;ASL2.0
190 "third_party/libsecret" ;LGPL2.1+
191 "third_party/libsrtp" ;BSD-3
192 "third_party/libsync" ;ASL2.0
193 "third_party/libudev" ;LGPL2.1+
194 "third_party/liburlpattern" ;Expat
195 "third_party/libva_protected_content" ;Expat
197 ;; FIXME: build/linux/unbundle/libvpx.gn does not work for all users.
198 "third_party/libvpx" ;BSD-3
199 "third_party/libvpx/source/libvpx/third_party/x86inc" ;Expat
201 "third_party/libwebm" ;BSD-3
202 "third_party/libxml/chromium" ;BSD-3
203 "third_party/libyuv" ;BSD-3
204 "third_party/libzip" ;BSD-3
205 "third_party/lottie" ;Expat
206 "third_party/lss" ;BSD-3
207 "third_party/mako" ;Expat
208 "third_party/markupsafe" ;BSD-3
209 "third_party/mesa_headers" ;Expat, SGI
210 "third_party/metrics_proto" ;BSD-3
211 "third_party/minigbm" ;BSD-3
212 "third_party/modp_b64" ;BSD-3
213 "third_party/nasm" ;BSD-2
214 "third_party/nearby" ;ASL2.0
215 "third_party/node" ;Expat
216 "third_party/node/node_modules/polymer-bundler/lib/third_party/UglifyJS2" ;BSD-2
217 "third_party/one_euro_filter" ;BSD-3
218 "third_party/openscreen" ;BSD-3
219 "third_party/openscreen/src/third_party/tinycbor" ;Expat
220 "third_party/openscreen/src/third_party/mozilla" ;MPL1.1/GPL2+/LGPL2.1+, BSD-3
221 "third_party/ots" ;BSD-3
222 "third_party/pdfium" ;BSD-3
223 "third_party/pdfium/third_party/agg23" ;Expat
224 "third_party/pdfium/third_party/base" ;BSD-3
225 "third_party/pdfium/third_party/bigint" ;Public domain, BSD-3
226 "third_party/pdfium/third_party/libtiff" ;non-copyleft
227 "third_party/pdfium/third_party/skia_shared" ;BSD-3
228 "third_party/pdfium/third_party/freetype/include/pstables.h" ;FreeType
229 "third_party/perfetto" ;ASL2.0
230 "third_party/perfetto/protos/third_party/chromium" ;BSD-3
231 "third_party/pffft" ;the "FFTPACK" license
232 "third_party/ply" ;BSD-3
233 "third_party/polymer" ;BSD-3
234 "third_party/private_membership" ;ASL2.0
235 "third_party/private-join-and-compute" ;ASL2.0
236 "third_party/protobuf" ;BSD-3
237 "third_party/protobuf/third_party/six" ;Expat
238 "third_party/pthreadpool" ;BSD-2
239 "third_party/pyjson5" ;ASL2.0
240 "third_party/qcms" ;Expat
241 "third_party/rnnoise" ;BSD-3
242 "third_party/ruy" ;ASL2.0
243 "third_party/s2cellid" ;ASL2.0
244 "third_party/securemessage" ;ASL2.0
245 "third_party/shell-encryption" ;ASL2.0
246 "third_party/skia" ;BSD-3
247 "third_party/skia/include/third_party/skcms" ;BSD-3
248 "third_party/skia/third_party/skcms" ;BSD-3
249 "third_party/skia/third_party/vulkanmemoryallocator" ;BSD-3, Expat
250 "third_party/smhasher" ;Expat, public domain
252 ;; FIXME: the snappy "replacement" shim (see replace_gn_files.py below) does
253 ;; not declare a library dependency added in M93, causing a link failure.
254 "third_party/snappy" ;BSD-3
256 "third_party/speech-dispatcher" ;GPL2+
257 "third_party/sqlite" ;Public domain
258 "third_party/swiftshader" ;ASL2.0
259 "third_party/swiftshader/third_party/astc-encoder" ;ASL2.0
260 "third_party/swiftshader/third_party/llvm-10.0" ;ASL2.0, with LLVM exception
261 "third_party/swiftshader/third_party/llvm-subzero" ;NCSA
262 "third_party/swiftshader/third_party/marl" ;ASL2.0
263 "third_party/swiftshader/third_party/subzero" ;NCSA
264 "third_party/swiftshader/third_party/SPIRV-Headers" ;X11-style
265 "third_party/swiftshader/third_party/SPIRV-Tools" ;ASL2.0
266 "third_party/tensorflow-text" ;ASL2.0
267 "third_party/tflite" ;ASL2.0
268 "third_party/tflite/src/third_party/eigen3" ;MPL2.0
269 "third_party/tflite/src/third_party/fft2d" ;ASL2.0
270 "third_party/ukey2" ;ASL2.0
271 "third_party/usb_ids" ;BSD-3
272 "third_party/utf" ;Expat
273 "third_party/vulkan-deps" ;ASL2.0, BSD-3, Expat
274 "third_party/vulkan_memory_allocator" ;Expat
275 "third_party/wayland/protocol" ;Expat
276 "third_party/wayland/stubs" ;BSD-3, Expat
277 "third_party/wayland/wayland_scanner_wrapper.py" ;BSD-3
278 "third_party/wayland-protocols" ;Expat
279 "third_party/web-animations-js" ;ASL2.0
280 "third_party/webdriver" ;ASL2.0
281 "third_party/webgpu-cts" ;BSD-3
282 "third_party/webrtc" ;BSD-3
283 "third_party/webrtc/common_audio/third_party/ooura" ;Non-copyleft
284 "third_party/webrtc/common_audio/third_party/spl_sqrt_floor" ;Public domain
285 "third_party/webrtc/modules/third_party/fft" ;Non-copyleft
286 "third_party/webrtc/modules/third_party/g711" ;Public domain
287 "third_party/webrtc/modules/third_party/g722" ;Public domain
288 "third_party/webrtc/rtc_base/third_party/base64" ;Non-copyleft
289 "third_party/webrtc/rtc_base/third_party/sigslot" ;Public domain
290 "third_party/widevine/cdm/widevine_cdm_version.h" ;BSD-3
291 "third_party/widevine/cdm/widevine_cdm_common.h" ;BSD-3
292 "third_party/woff2" ;ASL2.0
293 "third_party/wuffs" ;ASL2.0
294 "third_party/xcbproto" ;X11
295 "third_party/xdg-utils" ;Expat
296 "third_party/xnnpack" ;BSD-3
298 ;; These are forked components of the X11 keybinding code.
299 "third_party/libxcb-keysyms" ;X11
300 "third_party/libx11/src/KeyBind.c" ;X11
301 "third_party/libx11/src/xkb/XKBBind.c" ;X11
302 "third_party/x11proto/keysymdef.h" ;X11
304 "third_party/zlib/google" ;BSD-3
305 "third_party/zxcvbn-cpp" ;Expat
306 "url/third_party/mozilla" ;BSD-3, MPL1.1/GPL2+/LGPL2.1+
307 "v8/src/third_party/siphash" ;Public domain
308 "v8/src/third_party/utf8-decoder" ;Expat
309 "v8/src/third_party/valgrind" ;BSD-4
310 "v8/third_party/inspector_protocol" ;BSD-3
311 "v8/third_party/v8/builtins")) ;PSFL
313 (define %blacklisted-files
314 ;; 'third_party/blink/perf_tests/resources/svg/HarveyRayner.svg' carries a
315 ;; nonfree license according to LICENSES in the same directory. As we don't
316 ;; run the Blink performance tests, just remove everything to save ~70MiB.
317 '("third_party/blink/perf_tests"))
319 (define %chromium-version "104.0.5112.81")
320 (define %ungoogled-revision (string-append %chromium-version "-1"))
321 (define %debian-revision "debian/102.0.5005.61-1")
323 (define %ungoogled-origin
326 (uri (git-reference (url "https://github.com/Eloston/ungoogled-chromium")
327 (commit %ungoogled-revision)))
328 (file-name (git-file-name "ungoogled-chromium" %ungoogled-revision))
331 "0dvwh470h06x5a4p8kw22pi4lvch16knh90i2kh10y0wfggqz78w"))))
333 (define %debian-origin
337 (url "https://salsa.debian.org/chromium-team/chromium.git")
338 (commit %debian-revision)))
339 (file-name (git-file-name "debian-chromium-patches"
340 (match (string-split %debian-revision #\/)
341 ((_ version) version))))
344 "1ln6r1qzlr7dsgvcbssvvc34my4mpkwv9hmvlb2dhjncs7isp65j"))))
346 (define (debian-patch name)
349 #~(symlink (string-append #$%debian-origin "/debian/patches/" #$name)
352 (define %debian-patches
354 '("system/jsoncpp.patch"
356 "system/openjpeg.patch")))
358 ;; Take a patch from Arch that reverts a change which requires an unreleased
359 ;; version of ffmpeg.
360 (define %ungoogled-chromium-unroll-ffmpeg.patch
363 (uri "https://raw.githubusercontent.com/archlinux/svntogit-packages\
364 /f3225f99b900e11ac900725992ea883142d7309c/trunk/roll-src-third_party-ffmpeg.patch")
365 (file-name "ungoogled-chromium-unroll-ffmpeg.patch")
368 "0i7crn6fcwq09kd6a4smqnffaldyv61lmv2p0drcnpfrwalmkprh"))))
370 (define %guix-patches
372 (assume-valid-file-name
373 (search-patch "ungoogled-chromium-extension-search-path.patch")))
375 (assume-valid-file-name
376 (search-patch "ungoogled-chromium-RUNPATH.patch")))
378 (assume-valid-file-name
379 (search-patch "ungoogled-chromium-ffmpeg-compat.patch")))
381 (assume-valid-file-name
382 (search-patch "ungoogled-chromium-system-ffmpeg.patch")))
384 (assume-valid-file-name
385 (search-patch "ungoogled-chromium-system-nspr.patch")))))
387 ;; This is a source 'snippet' that does the following:
388 ;; *) Applies various patches for unbundling purposes and libstdc++ compatibility.
389 ;; *) Runs the ungoogled patch-, domain substitution-, and scrubbing scripts.
390 ;; *) Prunes all third_party directories that are not explicitly preserved.
391 ;; *) Adjusts "GN" build files such that system libraries are preferred.
392 (define ungoogled-chromium-snippet
393 ;; Note: delay to cope with cyclic module imports at the top level.
396 (let ((chromium-dir (getcwd)))
397 (set-path-environment-variable
399 (list #+patch #+python-wrapper #+xz))
401 ;; Apply patches before running the ungoogled scripts because
402 ;; domain substitution may break some of the patches.
403 (format #t "Applying assorted build fixes...~%")
405 (for-each (lambda (patch)
406 (invoke "patch" "-p1" "--force" "--input"
407 patch "--no-backup-if-mismatch"))
408 (append '#+%debian-patches '#+%guix-patches))
410 (invoke "patch" "-Rp1" "--force" "--input" "--no-backup-if-mismatch"
411 "--input" #$%ungoogled-chromium-unroll-ffmpeg.patch)
413 (with-directory-excursion #+%ungoogled-origin
414 (format #t "Ungooglifying...~%")
416 (invoke "python" "utils/prune_binaries.py" chromium-dir
418 (invoke "python" "utils/patches.py" "apply" chromium-dir
420 (invoke "python" "utils/domain_substitution.py" "apply" "-r"
421 "domain_regex.list" "-f" "domain_substitution.list"
422 "-c" "/tmp/domainscache.tar.gz" chromium-dir))
424 ;; Run after the ungoogled scripts to avoid interfering with
425 ;; patches or file lists.
426 (format #t "Removing blacklisted files...~%")
428 (for-each delete-file-recursively '#$%blacklisted-files)
430 (format #t "Pruning third party files...~%")
432 (apply invoke "python"
433 "build/linux/unbundle/remove_bundled_libraries.py"
434 "--do-remove" '#$%preserved-third-party-files)
436 (format #t "Replacing GN files...~%")
438 (substitute* "tools/generate_shim_headers/generate_shim_headers.py"
439 ;; The "is_official_build" configure option enables certain
440 ;; release optimizations like those used in the commercial
441 ;; Chrome browser. Unfortunately it also requires using the
442 ;; bundled libraries: lose that restriction.
443 (("#if defined\\(OFFICIAL_BUILD\\)")
445 (invoke "python" "build/linux/unbundle/replace_gn_files.py"
446 "--system-libraries" "ffmpeg" "flac" "fontconfig"
447 "freetype" "harfbuzz-ng" "icu" "libdrm" "libevent"
448 "libjpeg" "libpng" "libwebp" "libxml" "libxslt"
449 "openh264" "opus" "re2" "zlib")))))
452 (package/inherit opus
455 (substitute-keyword-arguments (package-arguments opus)
456 ((#:configure-flags flags ''())
457 ;; Opus Custom is an optional extension of the Opus
458 ;; specification that allows for unsupported frame
459 ;; sizes. Chromium requires that this is enabled.
460 `(cons "--enable-custom-modes"
463 (define-public ungoogled-chromium
465 (name "ungoogled-chromium")
466 (version (if (string-prefix? %chromium-version %ungoogled-revision)
468 ;; ungoogled-chromium version tags always have a "-1" suffix,
469 ;; so we can hijack "-0" in cases where the Chromium source
470 ;; is newer than the latest available tag.
471 (string-append %chromium-version "-0")))
472 (synopsis "Graphical web browser")
475 (uri (string-append "https://commondatastorage.googleapis.com"
476 "/chromium-browser-official/chromium-"
477 %chromium-version ".tar.xz"))
480 "0x17jzzvn2aqx3ahqyi6ijyn70sn79kg648r0ks9m5gib1bbgf0y"))
481 (modules '((guix build utils)))
482 (snippet (force ungoogled-chromium-snippet))))
483 (build-system gnu-build-system)
487 #:modules '((guix build gnu-build-system)
491 ;; See tools/gn/docs/cookbook.md and
492 ;; https://www.chromium.org/developers/gn-build-configuration
493 ;; for usage. Run "gn args . --list" in the Release
494 ;; directory for an exhaustive list of supported flags.
495 ;; (Note: The 'configure' phase will do that for you.)
496 #~(list "is_debug=false"
497 ;; Use the "official" release optimizations, as opposed to
498 ;; a developer build.
499 "is_official_build=true"
500 "clang_use_chrome_plugins=false"
501 "use_custom_libcxx=false"
506 "use_unofficial_version_number=false"
507 "treat_warnings_as_errors=false"
508 "use_official_google_api_keys=false"
509 "disable_fieldtrial_testing_config=true"
510 "safe_browsing_mode=0"
512 "enable_reading_list=false"
513 "enable_remoting=false"
514 "enable_reporting=false"
515 "enable_service_discovery=false"
517 "enable_widevine=false"
518 ;; Disable type-checking for the Web UI to avoid a Java dependency.
519 "enable_js_type_check=false"
520 ;; Disable code using TensorFlow until it has been scrutinized
521 ;; by the ungoogled project.
522 "build_with_tflite_lib=false"
523 ;; Avoid dependency on code formatting tools.
524 "blink_enable_generated_code_formatting=false"
525 ;; Don't bother building Dawn tests.
526 "build_dawn_tests=false"
528 ;; Define a custom toolchain that simply looks up CC, AR and
529 ;; friends from the environment.
530 "custom_toolchain=\"//build/toolchain/linux/unbundle:default\""
531 "host_toolchain=\"//build/toolchain/linux/unbundle:default\""
533 ;; Prefer system libraries.
534 "use_system_freetype=true"
535 "use_system_harfbuzz=true"
536 "use_system_lcms2=true"
537 "use_system_libdrm=true"
538 "use_system_libjpeg=true"
539 "use_system_libopenjpeg2=true"
540 "use_system_libpng=true"
541 "use_system_wayland_scanner=true"
542 (string-append "system_wayland_scanner_path=\""
543 (search-input-file %build-inputs
544 "/bin/wayland-scanner")
547 "use_system_zlib=true"
548 "use_gnome_keyring=false" ;deprecated by libsecret
549 "use_pulseaudio=true"
550 "link_pulseaudio=true"
551 "icu_use_data_file=false"
553 ;; FIXME: Using system protobuf with "is_official_build" causes an
554 ;; invalid opcode and "protoc-gen-plugin: Plugin killed by signal 4".
555 ;;"perfetto_use_system_protobuf=true"
557 ;; VA-API acceleration is currently only supported on x86_64-linux.
558 #$@(if (string-prefix? "x86_64" (or (%current-target-system)
563 "media_use_ffmpeg=true"
564 "media_use_libvpx=true"
565 "media_use_openh264=true"
567 ;; Do not artifically restrict formats supported by system ffmpeg.
568 "proprietary_codecs=true"
569 "ffmpeg_branding=\"Chrome\""
573 "rtc_use_pipewire=true"
574 "rtc_link_pipewire=true"
575 ;; Don't use bundled sources.
576 "rtc_build_json=false"
577 (string-append "rtc_jsoncpp_root=\""
578 (search-input-directory %build-inputs
581 "rtc_build_libevent=false"
582 ;; XXX: Use the bundled libvpx for WebRTC because unbundling
583 ;; currently fails (see above), and the versions must match.
584 "rtc_build_libvpx=true"
585 "rtc_build_opus=false"
586 "rtc_build_libsrtp=true" ;FIXME: fails to find headers
587 "rtc_build_ssl=true") ;XXX: requires BoringSSL
589 #~(modify-phases %standard-phases
590 (add-after 'unpack 'patch-stuff
591 (lambda* (#:key inputs #:allow-other-keys)
592 (let ((openjpeg (search-input-directory
593 inputs "include/openjpeg-2.4")))
594 (substitute* "third_party/pdfium/BUILD.gn"
595 ;; This include path is added by Debians openjpeg patch.
596 (("/usr/include/openjpeg-2.4") openjpeg))
598 ;; Remove contrib/ prefix from minizip header inclusions.
599 (substitute* (find-files "third_party/tflite_support\
600 /src/tensorflow_lite_support/metadata/cc")
601 (("contrib/minizip/")
605 '("base/process/launch_posix.cc"
606 "base/third_party/dynamic_annotations/dynamic_annotations.c"
607 "sandbox/linux/seccomp-bpf/sandbox_bpf.cc"
608 "sandbox/linux/services/credentials.cc"
609 "sandbox/linux/services/namespace_utils.cc"
610 "sandbox/linux/services/syscall_wrappers.cc"
611 "sandbox/linux/syscall_broker/broker_host.cc")
612 (("include \"base/third_party/valgrind/") "include \"valgrind/"))
614 (for-each (lambda (file)
616 ;; Fix opus include path.
617 ;; Do not substitute opus_private.h.
618 (("#include \"opus\\.h\"")
619 "#include \"opus/opus.h\"")
620 (("#include \"opus_custom\\.h\"")
621 "#include \"opus/opus_custom.h\"")
622 (("#include \"opus_defines\\.h\"")
623 "#include \"opus/opus_defines.h\"")
624 (("#include \"opus_multistream\\.h\"")
625 "#include \"opus/opus_multistream.h\"")
626 (("#include \"opus_types\\.h\"")
627 "#include \"opus/opus_types.h\"")))
628 (find-files (string-append "third_party/webrtc/modules"
629 "/audio_coding/codecs/opus")))
630 (substitute* "media/audio/audio_opus_encoder.h"
631 (("\"third_party/opus/src/include/opus.h\"")
634 (substitute* "third_party/webrtc/rtc_base/strings/json.h"
635 (("#include \"third_party/jsoncpp/")
638 ;; Many files try to include ICU headers from "third_party/icu/...".
639 ;; Remove the "third_party/" prefix to use system headers instead.
640 (substitute* (find-files "chrome" "\\.cc$")
641 (("third_party/icu/source/(common|i18n)/")
644 ;; XXX: Should be unnecessary when use_system_lcms2=true.
645 (substitute* "third_party/pdfium/core/fxcodec/icc/icc_transform.h"
646 (("include \"third_party/lcms/include/lcms2\\.h\"")
647 "include \"lcms2.h\""))
650 "third_party/breakpad/breakpad/src/common/linux/libcurl_wrapper.h"
651 (("include \"third_party/curl")
654 (substitute* '("components/viz/common/gpu/vulkan_context_provider.h"
655 "components/viz/common/resources/resource_format_utils.h"
656 "gpu/config/gpu_util.cc")
657 (("third_party/vulkan_headers/include/") ""))
659 (substitute* "third_party/skia/include/gpu/vk/GrVkVulkan.h"
660 (("include/third_party/vulkan/") "")))))
661 (add-after 'patch-stuff 'add-absolute-references
662 (lambda* (#:key inputs #:allow-other-keys)
663 (let ((cups-config (search-input-file inputs "/bin/cups-config"))
664 (libnssckbi.so (search-input-file inputs
665 "/lib/nss/libnssckbi.so"))
666 (libudev.so.1 (search-input-file inputs "/lib/libudev.so.1"))
667 (libvulkan.so.1 (search-input-file inputs
668 "/lib/libvulkan.so.1"))
669 (icd.d (search-input-directory inputs "share/vulkan/icd.d"))
670 (mesa-lib (dirname (search-input-file inputs
672 (gtk-libs '("libgio-2.0.so.0"
673 "libgdk_pixbuf-2.0.so.0"
676 (for-each (lambda (lib)
677 (substitute* "ui/gtk/gtk_compat.cc"
678 ((lib) (search-input-file
679 inputs (string-append "lib/" lib)))))
681 (substitute* "printing/cups_config_helper.py"
683 (string-append "cups_config = '" cups-config "'\n")))
684 (substitute* "crypto/nss_util.cc"
685 (("libnssckbi\\.so") libnssckbi.so))
686 (substitute* "device/udev_linux/udev1_loader.cc"
687 (("libudev\\.so\\.1") libudev.so.1))
689 ;; Patch libvulkan.so everywhere.
691 '("third_party/swiftshader/include/vulkan/vulkan.hpp"
692 "third_party/vulkan-deps/vulkan-tools\
693 /src/vulkaninfo/vulkaninfo.h"
694 "third_party/vulkan-deps/vulkan-headers\
695 /src/include/vulkan/vulkan.hpp"
696 "content/gpu/gpu_sandbox_hook_linux.cc"
697 "ui/ozone/platform/wayland/gpu/vulkan_implementation_wayland.cc"
698 "ui/ozone/platform/drm/gpu/vulkan_implementation_gbm.cc"
699 "ui/ozone/platform/x11/vulkan_implementation_x11.cc"
700 "third_party/skia/tools/sk_app/unix\
701 /DawnVulkanWindowContext_unix.cpp")
702 (("libvulkan\\.so\\.1") libvulkan.so.1))
703 (substitute* "content/gpu/gpu_sandbox_hook_linux.cc"
704 (("/usr/share/vulkan/icd\\.d") icd.d))
706 ;; Add the libvulkan directory to dawn built-in search paths.
707 (substitute* "third_party/dawn/src/dawn/native/Instance.cpp"
708 (("^([[:blank:]]+)mRuntimeSearchPaths\\.push_back\\(\"\"\\);"
710 (string-append indent "mRuntimeSearchPaths.push_back(\""
711 (dirname libvulkan.so.1) "/\");\n" all)))
714 '("ui/ozone/platform/x11/gl_ozone_glx.cc"
715 "ui/ozone/common/egl_util.cc"
716 "third_party/angle/src/libANGLE/renderer/gl/glx\
719 (string-append mesa-lib "/libGL.so.1"))
721 (string-append mesa-lib "/libEGL.so.1"))
722 (("libGLESv2\\.so\\.2")
723 (string-append mesa-lib "/libGLESv2.so.2"))))))
724 (add-before 'configure 'prepare-build-environment
725 (lambda* (#:key native-inputs inputs #:allow-other-keys)
726 (let ((c++ (search-input-directory (or native-inputs inputs)
728 (node (search-input-file (or native-inputs inputs)
730 ;; Define the GN toolchain.
731 (setenv "AR" "llvm-ar") (setenv "NM" "llvm-nm")
732 (setenv "CC" "clang") (setenv "CXX" "clang++")
734 ;; Disable compiler flags that require Clang 15.
735 (substitute* "build/config/compiler/BUILD.gn"
736 (("\"-no-opaque-pointers\",")
738 (("\"-Wno-unqualified-std-cast-call\"")
740 (("\"-Wno-deprecated-non-prototype\"")
743 ;; TODO: pre-compile instead. Avoids a race condition.
744 (setenv "PYTHONDONTWRITEBYTECODE" "1")
746 ;; XXX: How portable is this.
747 (mkdir-p "third_party/node/linux/node-linux-x64")
748 (symlink (dirname node)
749 "third_party/node/linux/node-linux-x64/bin"))))
751 (lambda* (#:key configure-flags #:allow-other-keys)
752 (let ((args (string-join configure-flags " ")))
753 ;; Generate ninja build files.
754 (invoke "gn" "gen" "out/Release"
755 (string-append "--args=" args))
757 ;; Print the full list of supported arguments as well as
758 ;; their current status for convenience.
759 (format #t "Dumping configure flags...\n")
760 (invoke "gn" "args" "out/Release" "--list"))))
761 (add-before 'build 'increase-resource-limits
763 ;; XXX: Chromiums linking step requires a lot of simultaneous file
764 ;; accesses. Having a too low ulimit will result in bogus linker
765 ;; errors such as "foo.a: error adding symbols: malformed archive".
767 ;; Try increasing the soft resource limit of max open files to 2048,
768 ;; or equal to the hard limit, whichever is lower.
769 (call-with-values (lambda () (getrlimit 'nofile))
771 (when (and soft (< soft 2048))
773 (setrlimit 'nofile (min hard 2048) hard)
774 (setrlimit 'nofile 2048 #f))
776 "increased maximum number of open files from ~d to ~d~%"
777 soft (if hard (min hard 2048) 2048)))))))
779 (lambda* (#:key (parallel-build? #t) #:allow-other-keys)
780 (invoke "ninja" "-C" "out/Release"
781 "-j" (if parallel-build?
782 (number->string (parallel-job-count))
787 (lambda* (#:key inputs outputs #:allow-other-keys)
788 (let* ((out (assoc-ref outputs "out"))
789 (bin (string-append out "/bin"))
790 (exe (string-append bin "/chromium"))
791 (lib (string-append out "/lib"))
792 (man (string-append out "/share/man/man1"))
793 (applications (string-append out "/share/applications"))
794 (libs '("chrome_100_percent.pak"
795 "chrome_200_percent.pak"
797 "v8_context_snapshot.bin"
800 "libvk_swiftshader.so"
801 "vk_swiftshader_icd.json"
803 ;; Chromium ships its own libGL
804 ;; implementation called ANGLE.
805 "libEGL.so" "libGLESv2.so"))
806 (locales (string-append lib "/locales"))
807 (resources (string-append lib "/resources"))
809 ;; This file contains defaults for new user profiles.
811 (search-auxiliary-file
812 "chromium/master-preferences.json")))
813 (gtk (dirname (dirname
814 (search-input-file inputs "lib/libgtk-3.so"))))
815 (xdg-utils (dirname (search-input-file inputs "bin/xdg-open"))))
817 (substitute* '("chrome/app/resources/manpage.1.in"
818 "chrome/installer/linux/common/desktop.template")
819 (("@@MENUNAME@@") "Chromium")
820 (("@@PACKAGE@@") "chromium")
821 (("/usr/bin/@@USR_BIN_SYMLINK_NAME@@") exe))
824 (copy-file "chrome/app/resources/manpage.1.in"
825 (string-append man "/chromium.1"))
827 (mkdir-p applications)
828 (copy-file "chrome/installer/linux/common/desktop.template"
829 (string-append applications "/chromium.desktop"))
832 (copy-file preferences (string-append lib "/master_preferences"))
834 (with-directory-excursion "out/Release"
835 (for-each (cut install-file <> lib) libs)
836 (copy-file "chrome" (string-append lib "/chromium"))
838 (copy-recursively "locales" locales)
839 (copy-recursively "resources" resources)
842 (symlink "../lib/chromium" exe)
843 (install-file "chromedriver" bin)
845 (for-each (lambda (so)
846 (install-file so (string-append lib "/swiftshader")))
847 (find-files "swiftshader" "\\.so$"))
850 ;; Avoid file manager crash. See <https://bugs.gnu.org/26593>.
851 `("XDG_DATA_DIRS" ":" prefix (,(string-append gtk "/share")))
852 `("PATH" ":" prefix (,xdg-utils))))
854 (with-directory-excursion "chrome/app/theme/chromium"
857 (let ((icons (string-append out "/share/icons/hicolor/"
858 size "x" size "/apps")))
860 (copy-file (string-append "product_logo_" size ".png")
861 (string-append icons "/chromium.png"))))
862 '("24" "48" "64" "128" "256")))))))))
873 python-beautifulsoup4
924 openjpeg ;PDFium only
940 (list (search-path-specification
941 (variable "CHROMIUM_EXTENSION_DIRECTORY")
942 (separator #f) ;single entry
943 (files '("share/chromium/extensions")))))
945 ;; Building Chromium takes ... a very long time. On a single core, a busy
946 ;; mid-end x86 system may need more than 24 hours to complete the build.
947 (properties '((timeout . 144000) ;40 hours
948 ;; The linking step may take more than an hour on some hardware.
949 (max-silent-time . 7200)
950 (cpe-name . "chrome")))
952 (home-page "https://github.com/Eloston/ungoogled-chromium")
954 "Ungoogled-Chromium is the Chromium web browser, with some functionality
955 disabled in order to protect the users privacy. This package also includes
956 the @command{chromedriver} command, which can be useful for automated web
958 ;; Chromium is developed as BSD-3, but bundles a large number of third-party
959 ;; components with other licenses. For full information, see chrome://credits.
960 (license (list license:bsd-3
966 license:public-domain
968 (license:non-copyleft "chrome://credits"
969 "See chrome://credits for more information.")
972 (define-public ungoogled-chromium/wayland
974 (inherit ungoogled-chromium)
975 (name "ungoogled-chromium-wayland")
978 `(("bash" ,bash-minimal)
979 ("glibc-locales" ,glibc-utf8-locales)
980 ("ungoogled-chromium" ,ungoogled-chromium)))
981 (build-system trivial-build-system)
983 '(#:modules ((guix build utils))
986 (use-modules (guix build utils))
987 (let* ((bash (assoc-ref %build-inputs "bash"))
988 (chromium (assoc-ref %build-inputs "ungoogled-chromium"))
989 (locales (assoc-ref %build-inputs "glibc-locales"))
990 (out (assoc-ref %outputs "out"))
991 (exe (string-append out "/bin/chromium")))
993 ;; Use a Unicode locale so we can substitute the file below.
994 (setenv "GUIX_LOCPATH" (string-append locales "/lib/locale"))
995 (setlocale LC_ALL "en_US.utf8")
997 (mkdir-p (dirname exe))
998 (symlink (string-append chromium "/bin/chromedriver")
999 (string-append out "/bin/chromedriver"))
1001 (call-with-output-file exe
1004 exec ~a --enable-features=UseOzonePlatform --ozone-platform=wayland $@"
1005 (string-append bash "/bin/bash")
1006 (string-append chromium "/bin/chromium"))))
1009 ;; Provide the manual and .desktop file.
1010 (copy-recursively (string-append chromium "/share")
1011 (string-append out "/share"))
1012 (substitute* (string-append
1013 out "/share/applications/chromium.desktop")