1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2019, 2020, 2021 Marius Bakke <mbakke@fastmail.com>
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 ninja)
54 #:use-module (gnu packages node)
55 #:use-module (gnu packages nss)
56 #:use-module (gnu packages pciutils)
57 #:use-module (gnu packages pkg-config)
58 #:use-module (gnu packages protobuf)
59 #:use-module (gnu packages pulseaudio)
60 #:use-module (gnu packages python)
61 #:use-module (gnu packages python-web)
62 #:use-module (gnu packages python-xyz)
63 #:use-module (gnu packages regex)
64 #:use-module (gnu packages serialization)
65 #:use-module (gnu packages speech)
66 #:use-module (gnu packages valgrind)
67 #:use-module (gnu packages vulkan)
68 #:use-module (gnu packages video)
69 #:use-module (gnu packages xiph)
70 #:use-module (gnu packages xml)
71 #:use-module (gnu packages xdisorg)
72 #:use-module (gnu packages xorg)
73 #:use-module (ice-9 match)
74 #:use-module (srfi srfi-1))
76 (define %preserved-third-party-files
77 '("base/third_party/cityhash" ;Expat
78 "base/third_party/double_conversion" ;BSD-3
79 "base/third_party/dynamic_annotations" ;BSD-2
80 "base/third_party/icu" ;Unicode, X11-style
81 "base/third_party/superfasthash" ;BSD-3
82 "base/third_party/symbolize" ;BSD-3
83 "base/third_party/xdg_mime" ;LGPL2.0+ or Academic 2.0
84 "base/third_party/xdg_user_dirs" ;Expat
85 ;; XXX: Chromium requires a newer C++ standard library. Remove this when
86 ;; the default GCC is 9 or later.
87 "buildtools/third_party/libc++" ;ASL2.0, with LLVM exceptions
88 "chrome/third_party/mozilla_security_manager" ;MPL-1.1/GPL2+/LGPL2.1+
89 "courgette/third_party/bsdiff" ;BSD-2, BSD protection license
90 "courgette/third_party/divsufsort" ;Expat
91 "net/third_party/mozilla_security_manager" ;MPL-1.1/GPL2+/LGPL2.1+
92 "net/third_party/nss" ;MPL-2.0
93 "net/third_party/quiche" ;BSD-3
94 "net/third_party/uri_template" ;ASL2.0
95 "third_party/abseil-cpp" ;ASL2.0
96 "third_party/angle" ;BSD-3
97 "third_party/angle/src/common/third_party/base" ;BSD-3
98 "third_party/angle/src/common/third_party/smhasher" ;Public domain
99 "third_party/angle/src/common/third_party/xxhash" ;BSD-2
100 "third_party/angle/src/third_party/compiler" ;BSD-2
101 "third_party/angle/src/third_party/libXNVCtrl" ;Expat
102 "third_party/angle/src/third_party/trace_event" ;BSD-3
103 "third_party/angle/src/third_party/volk" ;Expat
104 "third_party/apple_apsl" ;APSL2.0
105 "third_party/axe-core" ;MPL2.0
106 "third_party/blink" ;BSD-3, LGPL2+
107 "third_party/boringssl" ;OpenSSL/ISC (Google additions are ISC)
108 "third_party/boringssl/src/third_party/fiat" ;Expat
109 "third_party/breakpad" ;BSD-3
110 "third_party/brotli" ;Expat
111 "third_party/catapult" ;BSD-3
112 "third_party/catapult/common/py_vulcanize/third_party/rcssmin" ;ASL2.0
113 "third_party/catapult/common/py_vulcanize/third_party/rjsmin" ;ASL2.0
114 "third_party/catapult/third_party/polymer" ;BSD-3
115 ;; XXX: This is a minified version of <https://d3js.org/>.
116 "third_party/catapult/tracing/third_party/d3" ;BSD-3
117 "third_party/catapult/tracing/third_party/gl-matrix" ;Expat
118 "third_party/catapult/tracing/third_party/jpeg-js" ;ASL2.0
119 ;; XXX: Minified version of <https://github.com/Stuk/jszip>.
120 "third_party/catapult/tracing/third_party/jszip" ;Expat or GPL3
121 "third_party/catapult/tracing/third_party/mannwhitneyu" ;Expat
122 "third_party/catapult/tracing/third_party/oboe" ;BSD-2
123 ;; XXX: Minified version of <https://github.com/nodeca/pako>.
124 "third_party/catapult/tracing/third_party/pako" ;Expat
125 "third_party/ced" ;BSD-3
126 "third_party/cld_3" ;ASL2.0
127 "third_party/closure_compiler" ;ASL2.0
128 "third_party/crashpad" ;ASL2.0
129 "third_party/crashpad/crashpad/third_party/lss" ;ASL2.0
130 "third_party/crashpad/crashpad/third_party/zlib/zlib_crashpad.h" ;Zlib
131 "third_party/crc32c" ;BSD-3
132 "third_party/cros_system_api" ;BSD-3
133 "third_party/dav1d" ;BSD-2
134 "third_party/dawn" ;ASL2.0
135 "third_party/depot_tools/owners.py" ;BSD-3
136 "third_party/devtools-frontend" ;BSD-3
137 "third_party/devtools-frontend/src/front_end/third_party/acorn" ;Expat
138 "third_party/devtools-frontend/src/front_end/third_party/axe-core" ;MPL2.0
139 "third_party/devtools-frontend/src/front_end/third_party/chromium" ;BSD-3
140 "third_party/devtools-frontend/src/front_end/third_party/codemirror" ;Expat
141 "third_party/devtools-frontend/src/front_end/third_party/fabricjs" ;Expat
142 "third_party/devtools-frontend/src/front_end/third_party/i18n" ;ASL2.0
143 "third_party/devtools-frontend/src/front_end/third_party/intl-messageformat" ;BSD-3
144 "third_party/devtools-frontend/src/front_end/third_party/lighthouse" ;ASL2.0
145 "third_party/devtools-frontend/src/front_end/third_party/lit-html" ;BSD-3
146 "third_party/devtools-frontend/src/front_end/third_party/lodash-isequal" ;Expat
147 "third_party/devtools-frontend/src/front_end/third_party/marked" ;Expat, BSD-3
148 "third_party/devtools-frontend/src/front_end/third_party/puppeteer" ;ASL2.0
149 "third_party/devtools-frontend/src/front_end/third_party/wasmparser" ;ASL2.0
150 "third_party/devtools-frontend/src/third_party/pyjson5" ;ASL2.0
151 "third_party/devtools-frontend/src/third_party/typescript" ;ASL2.0
152 "third_party/dom_distiller_js" ;BSD-3
153 "third_party/emoji-segmenter" ;ASL2.0
154 "third_party/flatbuffers" ;ASL2.0
155 "third_party/fusejs" ;ASL2.0
156 "third_party/google_input_tools" ;ASL2.0
157 "third_party/google_input_tools/third_party/closure_library" ;ASL2.0
158 "third_party/google_input_tools/third_party/closure_library/third_party/closure" ;Expat
159 "third_party/googletest" ;BSD-3
160 "third_party/harfbuzz-ng" ;Expat
161 "third_party/hunspell" ;MPL1.1/GPL2+/LGPL2.1+
162 "third_party/iccjpeg" ;IJG
163 "third_party/inspector_protocol" ;BSD-3
164 "third_party/jinja2" ;BSD-3
165 ;; XXX: Unbundle this when switching back to libstdc++.
166 "third_party/jsoncpp" ;Public Domain or Expat
167 "third_party/jstemplate" ;ASL2.0
168 "third_party/khronos" ;Expat, SGI
169 "third_party/leveldatabase" ;BSD-3
170 "third_party/libavif" ;BSD-2
171 "third_party/libXNVCtrl" ;Expat
172 "third_party/libaddressinput" ;ASL2.0
173 "third_party/libaom" ;BSD-2 or "Alliance for Open Media Patent License 1.0"
174 "third_party/libaom/source/libaom/third_party/vector" ;Expat
175 "third_party/libaom/source/libaom/third_party/x86inc" ;ISC
176 "third_party/libgifcodec" ;MPL1.1/GPL2+/LGPL2.1+, BSD-3, BSD-2
177 "third_party/libjingle_xmpp" ;BSD-3
178 "third_party/libphonenumber" ;ASL2.0
179 "third_party/libsecret" ;LGPL2.1+
180 "third_party/libsrtp" ;BSD-3
181 "third_party/libsync" ;ASL2.0
182 "third_party/libudev" ;LGPL2.1+
183 "third_party/liburlpattern" ;Expat
184 "third_party/libva_protected_content" ;Expat
186 ;; FIXME: build/linux/unbundle/libvpx.gn does not work for all users.
187 "third_party/libvpx" ;BSD-3
188 "third_party/libvpx/source/libvpx/third_party/x86inc" ;Expat
190 "third_party/libwebm" ;BSD-3
191 "third_party/libxml/chromium" ;BSD-3
192 "third_party/libyuv" ;BSD-3
193 "third_party/lottie" ;Expat
194 "third_party/lss" ;BSD-3
195 "third_party/mako" ;Expat
196 "third_party/markupsafe" ;BSD-3
197 "third_party/mesa_headers" ;Expat, SGI
198 "third_party/metrics_proto" ;BSD-3
199 "third_party/minigbm" ;BSD-3
200 "third_party/modp_b64" ;BSD-3
201 "third_party/nasm" ;BSD-2
202 "third_party/nearby" ;ASL2.0
203 "third_party/node" ;Expat
204 "third_party/node/node_modules/polymer-bundler/lib/third_party/UglifyJS2" ;BSD-2
205 "third_party/one_euro_filter" ;BSD-3
206 "third_party/openscreen" ;BSD-3
207 "third_party/openscreen/src/third_party/tinycbor" ;Expat
208 "third_party/openscreen/src/third_party/mozilla" ;MPL1.1/GPL2+/LGPL2.1+, BSD-3
209 "third_party/ots" ;BSD-3
210 "third_party/pdfium" ;BSD-3
211 "third_party/pdfium/third_party/agg23" ;Expat
212 "third_party/pdfium/third_party/base" ;BSD-3
213 "third_party/pdfium/third_party/bigint" ;Public domain, BSD-3
214 "third_party/pdfium/third_party/skia_shared" ;BSD-3
215 "third_party/pdfium/third_party/freetype/include/pstables.h" ;FreeType
216 "third_party/perfetto" ;ASL2.0
217 "third_party/perfetto/protos/third_party/chromium" ;BSD-3
218 "third_party/pffft" ;the "FFTPACK" license
219 "third_party/ply" ;BSD-3
220 "third_party/polymer" ;BSD-3
221 "third_party/private_membership" ;ASL2.0
222 "third_party/private-join-and-compute" ;ASL2.0
223 "third_party/protobuf" ;BSD-3
224 "third_party/protobuf/third_party/six" ;Expat
225 "third_party/pyjson5" ;ASL2.0
226 "third_party/qcms" ;Expat
227 ;; XXX: System re2 cannot be used when Chromium uses libc++ because the re2
228 ;; ABI relies on libstdc++ internals. See build/linux/unbundle/re2.gn.
229 "third_party/re2" ;BSD-3
230 "third_party/rnnoise" ;BSD-3
231 "third_party/s2cellid" ;ASL2.0
232 "third_party/schema_org" ;CC-BY-SA3.0
233 "third_party/securemessage" ;ASL2.0
234 "third_party/shell-encryption" ;ASL2.0
235 "third_party/skia" ;BSD-3
236 "third_party/skia/include/third_party/skcms" ;BSD-3
237 "third_party/skia/third_party/skcms" ;BSD-3
238 "third_party/skia/third_party/vulkanmemoryallocator" ;BSD-3, Expat
239 "third_party/smhasher" ;Expat, public domain
240 "third_party/speech-dispatcher" ;GPL2+
241 "third_party/sqlite" ;Public domain
242 "third_party/swiftshader" ;ASL2.0
243 "third_party/swiftshader/third_party/astc-encoder" ;ASL2.0
244 "third_party/swiftshader/third_party/llvm-10.0" ;ASL2.0, with LLVM exception
245 "third_party/swiftshader/third_party/llvm-subzero" ;NCSA
246 "third_party/swiftshader/third_party/marl" ;ASL2.0
247 "third_party/swiftshader/third_party/subzero" ;NCSA
248 "third_party/swiftshader/third_party/SPIRV-Headers" ;X11-style
249 "third_party/tcmalloc/chromium" ;BSD-3
250 "third_party/ukey2" ;ASL2.0
251 "third_party/usb_ids" ;BSD-3
252 "third_party/usrsctp" ;BSD-2
253 "third_party/vulkan-deps" ;ASL2.0, BSD-3, Expat
254 "third_party/vulkan_memory_allocator" ;Expat
255 "third_party/wayland/protocol" ;Expat
256 "third_party/wayland/stubs" ;BSD-3, Expat
257 "third_party/wayland/wayland_scanner_wrapper.py" ;BSD-3
258 "third_party/wayland-protocols" ;Expat
259 "third_party/web-animations-js" ;ASL2.0
260 "third_party/webdriver" ;ASL2.0
261 "third_party/webrtc" ;BSD-3
262 "third_party/webrtc/common_audio/third_party/ooura" ;Non-copyleft
263 "third_party/webrtc/common_audio/third_party/spl_sqrt_floor" ;Public domain
264 "third_party/webrtc/modules/third_party/fft" ;Non-copyleft
265 "third_party/webrtc/modules/third_party/g711" ;Public domain
266 "third_party/webrtc/modules/third_party/g722" ;Public domain
267 "third_party/webrtc/rtc_base/third_party/base64" ;Non-copyleft
268 "third_party/webrtc/rtc_base/third_party/sigslot" ;Public domain
269 "third_party/widevine/cdm/widevine_cdm_version.h" ;BSD-3
270 "third_party/widevine/cdm/widevine_cdm_common.h" ;BSD-3
271 "third_party/woff2" ;ASL2.0
272 "third_party/xcbproto" ;X11
273 "third_party/xdg-utils" ;Expat
275 ;; These are forked components of the X11 keybinding code.
276 "third_party/libxcb-keysyms" ;X11
277 "third_party/libx11/src/KeyBind.c" ;X11
278 "third_party/libx11/src/xkb/XKBBind.c" ;X11
279 "third_party/x11proto/keysymdef.h" ;X11
281 "third_party/zlib/google" ;BSD-3
282 "third_party/zxcvbn-cpp" ;Expat
283 "url/third_party/mozilla" ;BSD-3, MPL1.1/GPL2+/LGPL2.1+
284 "v8/src/third_party/siphash" ;Public domain
285 "v8/src/third_party/utf8-decoder" ;Expat
286 "v8/src/third_party/valgrind" ;BSD-4
287 "v8/third_party/inspector_protocol" ;BSD-3
288 "v8/third_party/v8/builtins")) ;PSFL
290 (define %blacklisted-files
291 ;; 'third_party/blink/perf_tests/resources/svg/HarveyRayner.svg' carries a
292 ;; nonfree license according to LICENSES in the same directory. As we don't
293 ;; run the Blink performance tests, just remove everything to save ~70MiB.
294 '("third_party/blink/perf_tests"))
296 (define (debian-patch name revision hash)
299 (uri (string-append "https://salsa.debian.org/chromium-team/chromium/-/raw/"
300 revision "/debian/patches/" name))
301 (file-name (match (string-split name #\/)
303 (string-append "ungoogled-chromium-" category "-" name))))
304 (sha256 (base32 hash))))
306 (define %ungoogled-revision "89.0.4389.114-1")
307 (define %debian-revision "debian/84.0.4147.105-1")
309 (define %debian-patches
310 (list (debian-patch "system/zlib.patch" %debian-revision
311 "09vqgs37w9ycc7par14wa7rnvmg9bm0z9pqg6fyl3iqvpghyjyr4")
312 (debian-patch "system/openjpeg.patch" %debian-revision
313 "0zd6v5njx1pc7i0y6mslxvpx5j4cq01mmyx55qcqx8qzkm0gm48j")))
315 (define %ungoogled-origin
318 (uri (git-reference (url "https://github.com/Eloston/ungoogled-chromium")
319 (commit %ungoogled-revision)))
320 (file-name (git-file-name "ungoogled-chromium"
321 (if (= 40 (string-length %ungoogled-revision))
322 (string-take %ungoogled-revision 7)
323 %ungoogled-revision)))
326 "0cr2i51gxhgl55c8f9w0ra3m5q2dk03sf7p2qn4bqq1l1l72hw6s"))))
328 (define %guix-patches
330 (assume-valid-file-name
331 (search-patch "ungoogled-chromium-system-nspr.patch")))
333 (assume-valid-file-name
334 (search-patch "ungoogled-chromium-system-opus.patch")))
336 (assume-valid-file-name
337 (search-patch "ungoogled-chromium-extension-search-path.patch")))))
339 ;; This is a source 'snippet' that does the following:
340 ;; *) Applies various patches for unbundling purposes and libstdc++ compatibility.
341 ;; *) Runs the ungoogled patch-, domain substitution-, and scrubbing scripts.
342 ;; *) Prunes all third_party directories that are not explicitly preserved.
343 ;; *) Adjusts "GN" build files such that system libraries are preferred.
344 (define ungoogled-chromium-snippet
345 ;; Note: delay to cope with cyclic module imports at the top level.
348 (let ((chromium-dir (getcwd)))
349 (set-path-environment-variable
351 (list #+patch #+python-wrapper #+xz))
353 ;; Apply patches before running the ungoogled scripts because
354 ;; domain substitution may break some of the patches.
355 (format #t "Applying assorted build fixes...~%")
357 (for-each (lambda (patch)
358 (invoke "patch" "-p1" "--force" "--input"
359 patch "--no-backup-if-mismatch"))
360 (append '#+%debian-patches '#+%guix-patches))
362 (with-directory-excursion #+%ungoogled-origin
363 (format #t "Ungooglifying...~%")
365 (invoke "python" "utils/prune_binaries.py" chromium-dir
367 (invoke "python" "utils/patches.py" "apply" chromium-dir
369 (invoke "python" "utils/domain_substitution.py" "apply" "-r"
370 "domain_regex.list" "-f" "domain_substitution.list"
371 "-c" "/tmp/domainscache.tar.gz" chromium-dir))
373 ;; Run after the ungoogled scripts to avoid interfering with
374 ;; patches or file lists.
375 (format #t "Removing blacklisted files...~%")
377 (for-each delete-file-recursively '#$%blacklisted-files)
379 (format #t "Pruning third party files...~%")
381 (apply invoke (string-append #+python-2 "/bin/python")
382 "build/linux/unbundle/remove_bundled_libraries.py"
383 "--do-remove" '#$%preserved-third-party-files)
385 (format #t "Replacing GN files...~%")
387 (substitute* "tools/generate_shim_headers/generate_shim_headers.py"
388 ;; The "is_official_build" configure option enables certain
389 ;; release optimizations like those used in the commercial
390 ;; Chrome browser. Unfortunately it also requires using the
391 ;; bundled libraries: lose that restriction.
392 (("#if defined\\(OFFICIAL_BUILD\\)")
394 (invoke "python" "build/linux/unbundle/replace_gn_files.py"
395 "--system-libraries" "ffmpeg" "flac" "fontconfig"
396 "freetype" "harfbuzz-ng" "icu" "libdrm" "libevent"
397 "libjpeg" "libpng" "libwebp" "libxml" "libxslt"
398 "openh264" "opus" "snappy" "zlib")
402 (package/inherit opus
405 (substitute-keyword-arguments (package-arguments opus)
406 ((#:configure-flags flags ''())
407 ;; Opus Custom is an optional extension of the Opus
408 ;; specification that allows for unsupported frame
409 ;; sizes. Chromium requires that this is enabled.
410 `(cons "--enable-custom-modes"
413 ;; WebRTC in Chromium 88 requires an unreleased version of libvpx. Use the
414 ;; commit mentioned in "third_party/libvpx/README.chromium".
415 (define libvpx/chromium
418 (version "1.9.0-104-gb5d77a48d")
420 (inherit (package-source libvpx))
422 (url "https://chromium.googlesource.com/webm/libvpx")
423 (commit (string-append "v" version))))
424 (file-name (git-file-name "libvpx" version))
427 "07nkpx8myw5nd4bkaj6l4wr5ipk2c6lg9cwirz0i5qbr659051rk"))))))
429 ;; 'make-ld-wrapper' can only work with an 'ld' executable, so we need
430 ;; this trick to make it wrap 'lld'.
431 (define (make-lld-wrapper lld)
433 (computed-file "lld-ld"
436 (mkdir (string-append #$output "/bin"))
437 (symlink #$(file-append lld "/bin/lld")
438 (string-append #$output "/bin/ld")))))
440 ;; Create a wrapper for LLD that inserts appropriate -rpath entries.
442 (make-ld-wrapper "lld-wrapper"
443 #:binutils lld-as-ld))
445 ;; Clang looks for an 'ld.lld' executable, so we need to symlink it back.
446 (computed-file "lld-wrapped"
449 (mkdir (string-append #$output "/bin"))
450 (symlink #$(file-append lld-wrapper "/bin/ld")
451 (string-append #$output "/bin/lld"))
452 (symlink "lld" (string-append #$output "/bin/ld.lld")))))
454 (define-public ungoogled-chromium
456 (name "ungoogled-chromium")
457 (version %ungoogled-revision)
458 (synopsis "Graphical web browser")
461 (uri (string-append "https://commondatastorage.googleapis.com"
462 "/chromium-browser-official/chromium-"
463 (string-drop-right %ungoogled-revision 2)
467 "007df9p78bbmk3iyfi8qn57mmn68qqrdhx6z8n2hl8ksd7lspw7j"))
468 (modules '((guix build utils)))
469 (snippet (force ungoogled-chromium-snippet))))
470 (build-system gnu-build-system)
473 ;; FIXME: Chromiums RUNPATH lacks entries for some libraries.
474 #:validate-runpath? #f
475 #:modules ((guix build gnu-build-system)
479 ;; See tools/gn/docs/cookbook.md and
480 ;; https://www.chromium.org/developers/gn-build-configuration
481 ;; for usage. Run "gn args . --list" in the Release
482 ;; directory for an exhaustive list of supported flags.
483 ;; (Note: The 'configure' phase will do that for you.)
484 (list "is_debug=false"
485 ;; Use the "official" release optimizations, as opposed to
486 ;; a developer build.
487 "is_official_build=true"
488 "clang_use_chrome_plugins=false"
493 "enable_nacl_nonsfi=false"
494 "use_unofficial_version_number=false"
495 "treat_warnings_as_errors=false"
496 "use_official_google_api_keys=false"
497 "fieldtrial_testing_like_official_build=true"
498 "safe_browsing_mode=0"
500 "enable_one_click_signin=false"
501 "enable_reading_list=false"
502 "enable_remoting=false"
503 "enable_reporting=false"
504 "enable_service_discovery=false"
506 "enable_widevine=false"
507 ;; Disable type-checking for the Web UI to avoid a Java dependency.
508 "enable_js_type_check=false"
510 ;; Define a custom toolchain that simply looks up CC, AR and
511 ;; friends from the environment.
512 "custom_toolchain=\"//build/toolchain/linux/unbundle:default\""
513 "host_toolchain=\"//build/toolchain/linux/unbundle:default\""
515 ;; Prefer system libraries.
516 "use_system_freetype=true"
517 "use_system_harfbuzz=true"
518 "use_system_lcms2=true"
519 "use_system_libdrm=true"
520 "use_system_libjpeg=true"
521 "use_system_libopenjpeg2=true"
522 "use_system_libpng=true"
523 "use_system_wayland_scanner=true"
524 (string-append "system_wayland_scanner_path=\""
525 (assoc-ref %build-inputs "wayland-scanner")
526 "/bin/wayland-scanner\"")
528 "use_system_zlib=true"
529 "use_gnome_keyring=false" ;deprecated by libsecret
530 "use_pulseaudio=true"
531 "link_pulseaudio=true"
532 "icu_use_data_file=false"
534 ;; FIXME: Using system protobuf with "is_official_build" causes an
535 ;; invalid opcode and "protoc-gen-plugin: Plugin killed by signal 4".
536 ;;"perfetto_use_system_protobuf=true"
538 ;; VA-API acceleration is currently only supported on x86_64-linux.
539 ,@(if (string-prefix? "x86_64" (or (%current-target-system)
544 "media_use_ffmpeg=true"
545 "media_use_libvpx=true"
546 "media_use_openh264=true"
548 ;; Do not artifically restrict formats supported by system ffmpeg.
549 "proprietary_codecs=true"
550 "ffmpeg_branding=\"Chrome\""
554 "rtc_use_pipewire=true"
555 "rtc_link_pipewire=true"
556 "rtc_pipewire_version=\"0.3\""
557 ;; Don't use bundled sources.
558 "rtc_build_json=true" ;FIXME: libc++ std::string ABI difference
559 "rtc_build_libevent=false"
560 "rtc_build_libvpx=false"
561 "rtc_build_opus=false"
562 "rtc_build_libsrtp=true" ;FIXME: fails to find headers
563 "rtc_build_usrsctp=true" ;TODO: package this
564 "rtc_build_ssl=true") ;XXX: the bundled BoringSSL is required?
566 (modify-phases %standard-phases
567 (add-after 'unpack 'patch-stuff
570 '("base/process/launch_posix.cc"
571 "base/third_party/dynamic_annotations/dynamic_annotations.c"
572 "sandbox/linux/seccomp-bpf/sandbox_bpf.cc"
573 "sandbox/linux/services/credentials.cc"
574 "sandbox/linux/services/namespace_utils.cc"
575 "sandbox/linux/services/syscall_wrappers.cc"
576 "sandbox/linux/syscall_broker/broker_host.cc")
577 (("include \"base/third_party/valgrind/") "include \"valgrind/"))
579 (for-each (lambda (file)
581 ;; Fix opus include path.
582 ;; Do not substitute opus_private.h.
583 (("#include \"opus\\.h\"")
584 "#include \"opus/opus.h\"")
585 (("#include \"opus_custom\\.h\"")
586 "#include \"opus/opus_custom.h\"")
587 (("#include \"opus_defines\\.h\"")
588 "#include \"opus/opus_defines.h\"")
589 (("#include \"opus_multistream\\.h\"")
590 "#include \"opus/opus_multistream.h\"")
591 (("#include \"opus_types\\.h\"")
592 "#include \"opus/opus_types.h\"")))
593 (find-files (string-append "third_party/webrtc/modules"
594 "/audio_coding/codecs/opus")))
596 ;; Many files try to include ICU headers from "third_party/icu/...".
597 ;; Remove the "third_party/" prefix to use system headers instead.
598 (substitute* (find-files "chrome" "\\.cc$")
599 (("third_party/icu/source/(common|i18n)/")
602 ;; XXX: Should be unnecessary when use_system_lcms2=true.
603 (substitute* "third_party/pdfium/core/fxcodec/icc/iccmodule.h"
604 (("include \"third_party/lcms/include/lcms2\\.h\"")
605 "include \"lcms2.h\""))
608 "third_party/breakpad/breakpad/src/common/linux/libcurl_wrapper.h"
609 (("include \"third_party/curl")
612 (substitute* '("components/viz/common/gpu/vulkan_context_provider.h"
613 "components/viz/common/resources/resource_format_utils.h"
614 "gpu/config/gpu_util.cc")
615 (("third_party/vulkan_headers/include/") ""))
617 (substitute* "third_party/skia/include/gpu/vk/GrVkVulkan.h"
618 (("include/third_party/vulkan/") ""))
621 (add-after 'patch-stuff 'add-absolute-references
622 (lambda* (#:key inputs #:allow-other-keys)
623 (let ((cups (assoc-ref inputs "cups"))
624 (nss (assoc-ref inputs "nss"))
625 (mesa (assoc-ref inputs "mesa"))
626 (udev (assoc-ref inputs "udev")))
627 (substitute* "printing/cups_config_helper.py"
629 (string-append "cups_config = '" cups
630 "/bin/cups-config'\n")))
631 (substitute* "crypto/nss_util.cc"
633 (string-append nss "/lib/nss/libnssckbi.so")))
634 (substitute* "device/udev_linux/udev1_loader.cc"
635 (("libudev\\.so\\.1")
636 (string-append udev "/lib/libudev.so.1")))
639 '("ui/ozone/platform/x11/gl_ozone_glx.cc"
640 "ui/ozone/common/egl_util.cc"
641 "ui/gl/init/gl_initializer_linux_x11.cc"
642 "third_party/angle/src/libANGLE/renderer/gl/glx/FunctionsGLX.cpp")
644 (string-append mesa "/lib/libGL.so.1"))
646 (string-append mesa "/lib/libEGL.so.1"))
647 (("libGLESv2\\.so\\.2")
648 (string-append mesa "/lib/libGLESv2.so.2")))
650 (add-before 'configure 'prepare-build-environment
651 (lambda* (#:key inputs #:allow-other-keys)
653 ;; Define the GN toolchain.
654 (setenv "AR" "llvm-ar") (setenv "NM" "llvm-nm")
655 (setenv "CC" "clang") (setenv "CXX" "clang++")
657 (let ((gcc (assoc-ref inputs "gcc")))
658 ;; Remove the default compiler from CPLUS_INCLUDE_PATH to
659 ;; prevent header conflict with the bundled libcxx.
660 (setenv "CPLUS_INCLUDE_PATH"
662 (delete (string-append gcc "/include/c++")
663 (string-split (getenv "CPLUS_INCLUDE_PATH")
667 "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
668 (getenv "CPLUS_INCLUDE_PATH")))
672 '(;; Do not optimize away null pointer safety checks.
673 "-fno-delete-null-pointer-checks"
674 ;; Disable warnings about unknown warnings that require
675 ;; Clang plugins or newer versions.
676 "-Wno-unknown-warning-option")))
678 (setenv "CFLAGS" "-Wno-unknown-warning-option")
680 ;; TODO: pre-compile instead. Avoids a race condition.
681 (setenv "PYTHONDONTWRITEBYTECODE" "1")
683 ;; XXX: How portable is this.
684 (mkdir-p "third_party/node/linux/node-linux-x64")
685 (symlink (string-append (assoc-ref inputs "node") "/bin")
686 "third_party/node/linux/node-linux-x64/bin")
690 (lambda* (#:key configure-flags #:allow-other-keys)
691 (let ((args (string-join configure-flags " ")))
692 ;; Generate ninja build files.
693 (invoke "gn" "gen" "out/Release"
694 (string-append "--args=" args))
696 ;; Print the full list of supported arguments as well as
697 ;; their current status for convenience.
698 (format #t "Dumping configure flags...\n")
699 (invoke "gn" "args" "out/Release" "--list"))))
700 (add-before 'build 'increase-resource-limits
702 ;; XXX: Chromiums linking step requires a lot of simultaneous file
703 ;; accesses. Having a too low ulimit will result in bogus linker
704 ;; errors such as "foo.a: error adding symbols: malformed archive".
706 ;; Try increasing the soft resource limit of max open files to 2048,
707 ;; or equal to the hard limit, whichever is lower.
708 (call-with-values (lambda () (getrlimit 'nofile))
710 (when (and soft (< soft 2048))
712 (setrlimit 'nofile (min hard 2048) hard)
713 (setrlimit 'nofile 2048 #f))
715 "increased maximum number of open files from ~d to ~d~%"
716 soft (if hard (min hard 2048) 2048)))))
719 (lambda* (#:key (parallel-build? #t) #:allow-other-keys)
720 (invoke "ninja" "-C" "out/Release"
721 "-j" (if parallel-build?
722 (number->string (parallel-job-count))
727 (lambda* (#:key inputs outputs #:allow-other-keys)
728 (let* ((out (assoc-ref outputs "out"))
729 (bin (string-append out "/bin"))
730 (exe (string-append bin "/chromium"))
731 (lib (string-append out "/lib"))
732 (man (string-append out "/share/man/man1"))
733 (applications (string-append out "/share/applications"))
734 (libs '("chrome_100_percent.pak"
735 "chrome_200_percent.pak"
737 "v8_context_snapshot.bin"
738 ;; Chromium ships its own libGL
739 ;; implementation called ANGLE.
740 "libEGL.so" "libGLESv2.so"))
741 (locales (string-append lib "/locales"))
742 (resources (string-append lib "/resources"))
743 (preferences (assoc-ref inputs "master-preferences"))
744 (gtk+ (assoc-ref inputs "gtk+"))
745 (xdg-utils (assoc-ref inputs "xdg-utils"))
748 (substitute* '("chrome/app/resources/manpage.1.in"
749 "chrome/installer/linux/common/desktop.template")
750 (("@@MENUNAME@@") "Chromium")
751 (("@@PACKAGE@@") "chromium")
752 (("/usr/bin/@@USR_BIN_SYMLINK_NAME@@") exe))
755 (copy-file "chrome/app/resources/manpage.1.in"
756 (string-append man "/chromium.1"))
758 (mkdir-p applications)
759 (copy-file "chrome/installer/linux/common/desktop.template"
760 (string-append applications "/chromium.desktop"))
763 (copy-file preferences (string-append lib "/master_preferences"))
765 (with-directory-excursion "out/Release"
766 (for-each (cut install-file <> lib) libs)
767 (copy-file "chrome" (string-append lib "/chromium"))
769 (copy-recursively "locales" locales)
770 (copy-recursively "resources" resources)
773 (symlink "../lib/chromium" exe)
774 (install-file "chromedriver" bin)
776 (for-each (lambda (so)
777 (install-file so (string-append lib "/swiftshader")))
778 (find-files "swiftshader" "\\.so$"))
781 ;; Avoid file manager crash. See <https://bugs.gnu.org/26593>.
782 `("XDG_DATA_DIRS" ":" prefix (,(string-append gtk+ "/share")))
783 `("PATH" ":" prefix (,(string-append xdg-utils "/bin")))))
785 (with-directory-excursion "chrome/app/theme/chromium"
788 (let ((icons (string-append out "/share/icons/hicolor/"
789 size "x" size "/apps")))
791 (copy-file (string-append "product_logo_" size ".png")
792 (string-append icons "/chromium.png"))))
793 '("24" "48" "64" "128" "256")))
800 ("ld-wrapper" ,(make-lld-wrapper lld))
803 ("pkg-config" ,pkg-config)
806 ;; This file contains defaults for new user profiles.
807 ("master-preferences" ,(local-file "aux-files/chromium/master-preferences.json"))
809 ("python-beautifulsoup4" ,python2-beautifulsoup4)
810 ("python-html5lib" ,python2-html5lib)
812 ("wayland-scanner" ,wayland)))
814 `(("alsa-lib" ,alsa-lib)
822 ("fontconfig" ,fontconfig)
823 ("freetype" ,freetype)
824 ("gdk-pixbuf" ,gdk-pixbuf)
827 ("harfbuzz" ,harfbuzz)
830 ("libevent" ,libevent)
832 ("libjpeg-turbo" ,libjpeg-turbo)
835 ("libvpx" ,libvpx/chromium)
839 ("libxcomposite" ,libxcomposite)
840 ("libxcursor" ,libxcursor)
841 ("libxdamage" ,libxdamage)
843 ("libxfixes" ,libxfixes)
846 ("libxrandr" ,libxrandr)
847 ("libxrender" ,libxrender)
848 ("libxscrnsaver" ,libxscrnsaver)
853 ("mit-krb5" ,mit-krb5)
855 ("openh264" ,openh264)
856 ("openjpeg" ,openjpeg) ;PDFium only
857 ("opus" ,opus+custom)
859 ("pciutils" ,pciutils)
860 ("pipewire" ,pipewire-0.3)
861 ("pulseaudio" ,pulseaudio)
863 ("speech-dispatcher" ,speech-dispatcher)
865 ("valgrind" ,valgrind)
866 ("vulkan-headers" ,vulkan-headers)
868 ("xdg-utils" ,xdg-utils)))
870 (list (search-path-specification
871 (variable "CHROMIUM_EXTENSION_DIRECTORY")
872 (separator #f) ;single entry
873 (files '("share/chromium/extensions")))))
875 ;; Building Chromium takes ... a very long time. On a single core, a busy
876 ;; mid-end x86 system may need more than 24 hours to complete the build.
877 (properties '((timeout . 144000) ;40 hours
878 ;; The linking step may take more than an hour on some hardware.
879 (max-silent-time . 7200)
880 (cpe-name . "chrome")))
882 (home-page "https://github.com/Eloston/ungoogled-chromium")
884 "Ungoogled-Chromium is the Chromium web browser, with some functionality
885 disabled in order to protect the users privacy.")
886 ;; Chromium is developed as BSD-3, but bundles a large number of third-party
887 ;; components with other licenses. For full information, see chrome://credits.
888 (license (list license:bsd-3
894 license:public-domain
896 (license:non-copyleft "chrome://credits"
897 "See chrome://credits for more information.")
900 (define-public ungoogled-chromium/wayland
902 (inherit ungoogled-chromium)
903 (name "ungoogled-chromium-wayland")
906 `(("bash" ,bash-minimal)
907 ("glibc-locales" ,glibc-utf8-locales)
908 ("ungoogled-chromium" ,ungoogled-chromium)))
909 (build-system trivial-build-system)
911 '(#:modules ((guix build utils))
914 (use-modules (guix build utils))
915 (let* ((bash (assoc-ref %build-inputs "bash"))
916 (chromium (assoc-ref %build-inputs "ungoogled-chromium"))
917 (locales (assoc-ref %build-inputs "glibc-locales"))
918 (out (assoc-ref %outputs "out"))
919 (exe (string-append out "/bin/chromium")))
921 ;; Use a Unicode locale so we can substitute the file below.
922 (setenv "GUIX_LOCPATH" (string-append locales "/lib/locale"))
923 (setlocale LC_ALL "en_US.utf8")
925 (mkdir-p (dirname exe))
926 (symlink (string-append chromium "/bin/chromedriver")
927 (string-append out "/bin/chromedriver"))
929 (call-with-output-file exe
932 exec ~a --enable-features=UseOzonePlatform --ozone-platform=wayland $@"
933 (string-append bash "/bin/bash")
934 (string-append chromium "/bin/chromium"))))
937 ;; Provide the manual and .desktop file.
938 (copy-recursively (string-append chromium "/share")
939 (string-append out "/share"))
940 (substitute* (string-append
941 out "/share/applications/chromium.desktop")