1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2019, 2020 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 store)
25 #:use-module (guix monads)
26 #:use-module (guix download)
27 #:use-module (guix git-download)
28 #:use-module (guix utils)
29 #:use-module (guix build-system gnu)
30 #:use-module (gnu packages)
31 #:use-module (gnu packages assembly)
32 #:use-module (gnu packages base)
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 tls)
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/adobe/flash/flapper_version.h" ;no license, trivial
95 "third_party/angle" ;BSD-3
96 "third_party/angle/src/common/third_party/base" ;BSD-3
97 "third_party/angle/src/common/third_party/smhasher" ;Public domain
98 "third_party/angle/src/common/third_party/xxhash" ;BSD-2
99 "third_party/angle/src/third_party/compiler" ;BSD-2
100 "third_party/angle/src/third_party/libXNVCtrl" ;Expat
101 "third_party/angle/src/third_party/trace_event" ;BSD-3
102 "third_party/angle/src/third_party/volk" ;Expat
103 "third_party/angle/third_party/vulkan-headers" ;ASL2.0
104 "third_party/angle/third_party/vulkan-loader" ;ASL2.0
105 "third_party/angle/third_party/vulkan-tools" ;ASL2.0
106 "third_party/angle/third_party/vulkan-validation-layers" ;ASL2.0
107 "third_party/apple_apsl" ;APSL2.0
108 "third_party/axe-core" ;MPL2.0
109 "third_party/blink" ;BSD-3, LGPL2+
110 "third_party/boringssl" ;OpenSSL/ISC (Google additions are ISC)
111 "third_party/boringssl/src/third_party/fiat" ;Expat
112 "third_party/breakpad" ;BSD-3
113 "third_party/brotli" ;Expat
114 "third_party/cacheinvalidation" ;ASL2.0
115 "third_party/catapult" ;BSD-3
116 "third_party/catapult/common/py_vulcanize/third_party/rcssmin" ;ASL2.0
117 "third_party/catapult/common/py_vulcanize/third_party/rjsmin" ;ASL2.0
118 "third_party/catapult/third_party/polymer" ;BSD-3
119 ;; XXX: This is a minified version of <https://d3js.org/>.
120 "third_party/catapult/tracing/third_party/d3" ;BSD-3
121 "third_party/catapult/tracing/third_party/gl-matrix" ;Expat
122 "third_party/catapult/tracing/third_party/jpeg-js" ;ASL2.0
123 ;; XXX: Minified version of <https://github.com/Stuk/jszip>.
124 "third_party/catapult/tracing/third_party/jszip" ;Expat or GPL3
125 "third_party/catapult/tracing/third_party/mannwhitneyu" ;Expat
126 "third_party/catapult/tracing/third_party/oboe" ;BSD-2
127 ;; XXX: Minified version of <https://github.com/nodeca/pako>.
128 "third_party/catapult/tracing/third_party/pako" ;Expat
129 "third_party/ced" ;BSD-3
130 "third_party/cld_3" ;ASL2.0
131 "third_party/closure_compiler" ;ASL2.0
132 "third_party/crashpad" ;ASL2.0
133 "third_party/crashpad/crashpad/third_party/lss" ;ASL2.0
134 "third_party/crashpad/crashpad/third_party/zlib/zlib_crashpad.h" ;Zlib
135 "third_party/crc32c" ;BSD-3
136 "third_party/cros_system_api" ;BSD-3
137 "third_party/dav1d" ;BSD-2
138 "third_party/dawn" ;ASL2.0
139 "third_party/depot_tools/owners.py" ;BSD-3
140 "third_party/devtools-frontend" ;BSD-3
141 "third_party/devtools-frontend/src/front_end/third_party/acorn" ;Expat
142 "third_party/devtools-frontend/src/front_end/third_party/codemirror" ;Expat
143 "third_party/devtools-frontend/src/front_end/third_party/fabricjs" ;Expat
144 "third_party/devtools-frontend/src/front_end/third_party/lighthouse" ;ASL2.0
145 "third_party/devtools-frontend/src/front_end/third_party/wasmparser" ;ASL2.0
146 "third_party/devtools-frontend/src/third_party/axe-core" ;MPL2.0
147 "third_party/devtools-frontend/src/third_party/pyjson5" ;ASL2.0
148 "third_party/devtools-frontend/src/third_party/typescript" ;ASL2.0
149 "third_party/dom_distiller_js" ;BSD-3
150 "third_party/emoji-segmenter" ;ASL2.0
151 "third_party/flatbuffers" ;ASL2.0
152 "third_party/glslang" ;BSD-3, Expat, ASL2.0
153 "third_party/google_input_tools" ;ASL2.0
154 "third_party/google_input_tools/third_party/closure_library" ;ASL2.0
155 "third_party/google_input_tools/third_party/closure_library/third_party/closure" ;Expat
156 "third_party/googletest" ;BSD-3
157 "third_party/harfbuzz-ng" ;Expat
158 "third_party/hunspell" ;MPL1.1/GPL2+/LGPL2.1+
159 "third_party/iccjpeg" ;IJG
160 "third_party/inspector_protocol" ;BSD-3
161 "third_party/jinja2" ;BSD-3
162 "third_party/jstemplate" ;ASL2.0
163 "third_party/khronos" ;Expat, SGI
164 "third_party/leveldatabase" ;BSD-3
165 "third_party/libavif" ;BSD-2
166 "third_party/libXNVCtrl" ;Expat
167 "third_party/libaddressinput" ;ASL2.0
168 "third_party/libaom" ;BSD-2 or "Alliance for Open Media Patent License 1.0"
169 "third_party/libaom/source/libaom/third_party/vector" ;Expat
170 "third_party/libaom/source/libaom/third_party/x86inc" ;ISC
171 "third_party/libgifcodec" ;MPL1.1/GPL2+/LGPL2.1+, BSD-3, BSD-2
172 "third_party/libjingle_xmpp" ;BSD-3
173 "third_party/libphonenumber" ;ASL2.0
174 "third_party/libsecret" ;LGPL2.1+
175 "third_party/libsrtp" ;BSD-3
176 "third_party/libsync" ;ASL2.0
177 "third_party/libudev" ;LGPL2.1+
178 "third_party/libwebm" ;BSD-3
179 "third_party/libxml/chromium" ;BSD-3
180 "third_party/libyuv" ;BSD-3
181 "third_party/lottie" ;Expat
182 "third_party/lss" ;BSD-3
183 "third_party/mako" ;Expat
184 "third_party/markupsafe" ;BSD-3
185 "third_party/mesa_headers" ;Expat, SGI
186 "third_party/metrics_proto" ;BSD-3
187 "third_party/modp_b64" ;BSD-3
188 "third_party/nasm" ;BSD-2
189 "third_party/node" ;Expat
190 "third_party/node/node_modules/polymer-bundler/lib/third_party/UglifyJS2" ;BSD-2
191 "third_party/one_euro_filter" ;BSD-3
192 "third_party/openscreen" ;BSD-3
193 "third_party/openscreen/src/third_party/tinycbor" ;Expat
194 "third_party/openscreen/src/third_party/mozilla" ;MPL1.1/GPL2+/LGPL2.1+, BSD-3
195 "third_party/ots" ;BSD-3
196 "third_party/pdfium" ;BSD-3
197 "third_party/pdfium/third_party/agg23" ;Expat
198 "third_party/pdfium/third_party/base" ;BSD-3
199 "third_party/pdfium/third_party/bigint" ;Public domain, BSD-3
200 "third_party/pdfium/third_party/skia_shared" ;BSD-3
201 "third_party/pdfium/third_party/freetype/include/pstables.h" ;FreeType
202 "third_party/perfetto" ;ASL2.0
203 "third_party/pffft" ;the "FFTPACK" license, similar to BSD-3
204 "third_party/ply" ;BSD-3
205 "third_party/polymer" ;BSD-3
206 "third_party/private-join-and-compute" ;ASL2.0
207 "third_party/protobuf" ;BSD-3
208 "third_party/protobuf/third_party/six" ;Expat
209 "third_party/pyjson5" ;ASL2.0
210 "third_party/qcms" ;Expat
211 "third_party/rnnoise" ;BSD-3
212 "third_party/s2cellid" ;ASL2.0
213 "third_party/schema_org" ;CC-BY-SA3.0
214 "third_party/skia" ;BSD-3
215 "third_party/skia/include/third_party/skcms" ;BSD-3
216 "third_party/skia/third_party/skcms" ;BSD-3
217 "third_party/skia/third_party/vulkanmemoryallocator" ;BSD-3, Expat
218 "third_party/smhasher" ;Expat, public domain
219 "third_party/speech-dispatcher" ;GPL2+
220 "third_party/spirv-headers" ;ASL2.0
221 "third_party/SPIRV-Tools" ;ASL2.0
222 "third_party/sqlite" ;Public domain
223 "third_party/swiftshader" ;ASL2.0
224 "third_party/swiftshader/third_party/astc-encoder" ;ASL2.0
225 "third_party/swiftshader/third_party/llvm-7.0" ;NCSA
226 "third_party/swiftshader/third_party/llvm-subzero" ;NCSA
227 "third_party/swiftshader/third_party/marl" ;ASL2.0
228 "third_party/swiftshader/third_party/subzero" ;NCSA
229 "third_party/swiftshader/third_party/SPIRV-Headers" ;X11-style
230 "third_party/tcmalloc/chromium" ;BSD-3
231 "third_party/usb_ids" ;BSD-3
232 "third_party/usrsctp" ;BSD-2
233 "third_party/vulkan_memory_allocator" ;Expat
234 "third_party/wayland/wayland_scanner_wrapper.py" ;BSD-3
235 "third_party/wayland-protocols" ;Expat
236 "third_party/web-animations-js" ;ASL2.0
237 "third_party/webdriver" ;ASL2.0
238 "third_party/webrtc" ;BSD-3
239 "third_party/webrtc/common_audio/third_party/ooura" ;Non-copyleft
240 "third_party/webrtc/common_audio/third_party/spl_sqrt_floor" ;Public domain
241 "third_party/webrtc/modules/third_party/fft" ;Non-copyleft
242 "third_party/webrtc/modules/third_party/g711" ;Public domain
243 "third_party/webrtc/modules/third_party/g722" ;Public domain
244 "third_party/webrtc/rtc_base/third_party/base64" ;Non-copyleft
245 "third_party/webrtc/rtc_base/third_party/sigslot" ;Public domain
246 "third_party/widevine/cdm/widevine_cdm_version.h" ;BSD-3
247 "third_party/widevine/cdm/widevine_cdm_common.h" ;BSD-3
248 "third_party/woff2" ;ASL2.0
249 "third_party/xdg-utils" ;Expat
250 "third_party/zlib/google" ;BSD-3
251 "url/third_party/mozilla" ;BSD-3, MPL1.1/GPL2+/LGPL2.1+
252 "v8/src/third_party/siphash" ;Public domain
253 "v8/src/third_party/utf8-decoder" ;Expat
254 "v8/src/third_party/valgrind" ;BSD-4
255 "v8/third_party/inspector_protocol" ;BSD-3
256 "v8/third_party/v8/builtins")) ;PSFL
258 (define %blacklisted-files
259 ;; 'third_party/blink/perf_tests/resources/svg/HarveyRayner.svg' carries a
260 ;; nonfree license according to LICENSES in the same directory. As we don't
261 ;; run the Blink performance tests, just remove everything to save ~24MiB.
262 '("third_party/blink/perf_tests"))
264 (define (gentoo-patch name revision hash)
267 (uri (string-append "https://gitweb.gentoo.org/repo/gentoo.git/plain"
268 "/www-client/chromium/files/" name "?id=" revision))
269 (file-name (string-append "ungoogled-" name))
270 (sha256 (base32 hash))))
272 ;; This repository contains libstdc++ compatibility patches for Chromium.
273 (define (chromium-gcc-patchset commit hash)
277 (url "https://github.com/stha09/chromium-patches")
279 (file-name (git-file-name "chromium-gcc-patches" commit))
280 (sha256 (base32 hash))))
282 (define (debian-patch name revision hash)
285 (uri (string-append "https://salsa.debian.org/chromium-team/chromium/-/raw/"
286 revision "/debian/patches/" name))
287 (file-name (match (string-split name #\/)
289 (string-append "ungoogled-chromium-" category "-" name))))
290 (sha256 (base32 hash))))
292 (define %ungoogled-revision "57244cdfc21dc05910862152d91cc528103c988a")
293 (define %debian-revision "debian/83.0.4103.116-3")
294 (define %gentoo-revision "f3f649046d31ebdbc8c4a302b2384504eff78027")
296 (define %gentoo-patches
297 ;; This patch is necessary for compatibility with FFmpeg 4.3.
298 (list (gentoo-patch "chromium-84-mediaalloc.patch" %gentoo-revision
299 "0snxdc4nb8ykzncz62vpsl8hgxpy24m17mycx67i2gckmrpslzzv")))
301 (define %chromium-gcc-patches
302 (chromium-gcc-patchset
303 "chromium-84-patchset-3"
304 "0l05gx3pn703n47anjwsl5sjcqw8kaxmivf7llax97kj3k6d127v"))
306 (define %debian-patches
307 (list (debian-patch "system/zlib.patch" %debian-revision
308 "0bp2vh1cgmwjrn1zkpphkd3bs662s23xwdhy3abm9cfjvwrj117n")
309 (debian-patch "system/jsoncpp.patch" %debian-revision
310 "0d95brl4a5y5w142yd0rvf59z513h7chsz0vnm034d6lqf22ahwf")
311 (debian-patch "system/openjpeg.patch" %debian-revision
312 "0zd6v5njx1pc7i0y6mslxvpx5j4cq01mmyx55qcqx8qzkm0gm48j")))
314 (define %arch-patches
317 (uri "https://git.archlinux.org/svntogit/packages.git/plain/trunk/\
318 chromium-fix-vaapi-on-intel.patch?h=packages/chromium\
319 &id=93b5b90621b4827084288197c6e0e09b987b372a")
320 (file-name "ungoogled-chromium-fix-vaapi-on-intel.patch")
323 "16jbjjf4d9jp52rdrrxx5vm69nx3w0qrijgjpwapnmcif13z55g4")))))
325 (define %ungoogled-origin
328 (uri (git-reference (url "https://github.com/Eloston/ungoogled-chromium")
329 (commit %ungoogled-revision)))
330 (file-name (git-file-name "ungoogled-chromium"
331 (string-take %ungoogled-revision 7)))
334 "15a1xpmabdxr1mn61m0jm9a5l987rxdji8b1b6zy39mr636vcwfi"))))
336 ;; This is a source 'snippet' that does the following:
337 ;; *) Applies various patches for unbundling purposes and libstdc++ compatibility.
338 ;; *) Runs the ungoogled patch-, domain substitution-, and scrubbing scripts.
339 ;; *) Prunes all third_party directories that are not explicitly preserved.
340 ;; *) Adjusts "GN" build files such that system libraries are preferred.
341 (define ungoogled-chromium-snippet
342 ;; Note: delay to cope with cyclic module imports at the top level.
345 (let ((chromium-dir (getcwd)))
346 (set-path-environment-variable
348 (list #+patch #+python-wrapper #+xz))
350 ;; Apply patches before running the ungoogled scripts because
351 ;; domain substitution may break some of the patches.
352 (format #t "Applying assorted build fixes...~%")
354 (for-each (lambda (patch)
355 (invoke "patch" "-p1" "--force" "--input"
356 patch "--no-backup-if-mismatch"))
358 '#+%gentoo-patches '#+%debian-patches '#+%arch-patches
359 (find-files #$%chromium-gcc-patches "\\.patch$")
362 "ungoogled-chromium-system-nspr.patch")))))
364 (with-directory-excursion #+%ungoogled-origin
365 (format #t "Ungooglifying...~%")
367 (invoke "python" "utils/prune_binaries.py" chromium-dir
369 (invoke "python" "utils/patches.py" "apply"
370 chromium-dir "patches")
371 (invoke "python" "utils/domain_substitution.py" "apply" "-r"
372 "domain_regex.list" "-f" "domain_substitution.list"
373 "-c" "/tmp/domainscache.tar.gz" chromium-dir))
375 ;; Run after the ungoogled scripts to avoid interfering with
376 ;; patches or file lists.
377 (format #t "Removing blacklisted files...~%")
379 (for-each delete-file-recursively '#$%blacklisted-files)
381 (format #t "Pruning third party files...~%")
383 (apply invoke (string-append #+python-2 "/bin/python")
384 "build/linux/unbundle/remove_bundled_libraries.py"
385 "--do-remove" '#$%preserved-third-party-files)
387 (format #t "Replacing GN files...~%")
389 (substitute* "tools/generate_shim_headers/generate_shim_headers.py"
390 ;; The "is_official_build" configure option enables certain
391 ;; release optimizations like those used in the commercial
392 ;; Chrome browser. Unfortunately it also requires using the
393 ;; bundled libraries: lose that restriction.
394 (("#if defined\\(OFFICIAL_BUILD\\)")
396 (invoke "python" "build/linux/unbundle/replace_gn_files.py"
397 "--system-libraries" "ffmpeg" "flac" "fontconfig"
398 "freetype" "harfbuzz-ng" "icu" "libdrm" "libevent"
399 "libjpeg" "libpng" "libvpx" "libwebp" "libxml"
400 "libxslt" "openh264" "opus" "re2" "snappy" "zlib")
404 (package/inherit opus
407 (substitute-keyword-arguments (package-arguments opus)
408 ((#:configure-flags flags ''())
409 ;; Opus Custom is an optional extension of the Opus
410 ;; specification that allows for unsupported frame
411 ;; sizes. Chromium requires that this is enabled.
412 `(cons "--enable-custom-modes"
415 ;; Chromium still has Python2-only code, so we need this special Python 2
416 ;; variant of xcb-proto.
417 (define xcb-proto/python2
420 (name "python2-xcb-proto")
422 `(("pkg-config" ,pkg-config)
423 ("python" ,python-2)))))
425 ;; 'make-ld-wrapper' can only work with an 'ld' executable, so we need
426 ;; this trick to make it wrap 'lld'.
427 (define (make-lld-wrapper lld)
429 (computed-file "lld-ld"
432 (mkdir (string-append #$output "/bin"))
433 (symlink #$(file-append lld "/bin/lld")
434 (string-append #$output "/bin/ld")))))
436 ;; Create a wrapper for LLD that inserts appropriate -rpath entries.
438 (make-ld-wrapper "lld-wrapper"
439 #:binutils lld-as-ld))
441 ;; Clang looks for an 'ld.lld' executable, so we need to symlink it back.
442 (computed-file "lld-wrapped"
445 (mkdir (string-append #$output "/bin"))
446 (symlink #$(file-append lld-wrapper "/bin/ld")
447 (string-append #$output "/bin/lld"))
448 (symlink "lld" (string-append #$output "/bin/ld.lld")))))
450 (define-public ungoogled-chromium
452 (name "ungoogled-chromium")
453 (version (string-append "84.0.4147.125-0."
454 (string-take %ungoogled-revision 7)))
455 (synopsis "Graphical web browser")
458 (uri (string-append "https://commondatastorage.googleapis.com"
459 "/chromium-browser-official/chromium-"
460 (car (string-split version #\-)) ".tar.xz"))
463 "1xdg9pnnvbzasmra09rl7wdrir61rfcqml46jj7kv39drwk9chwq"))
464 (modules '((guix build utils)))
465 (snippet (force ungoogled-chromium-snippet))))
466 (build-system gnu-build-system)
469 ;; FIXME: Chromiums RUNPATH lacks entries for some libraries.
470 #:validate-runpath? #f
471 #:modules ((guix build gnu-build-system)
477 ;; See tools/gn/docs/cookbook.md and
478 ;; https://www.chromium.org/developers/gn-build-configuration
479 ;; for usage. Run "./gn args . --list" in the Release
480 ;; directory for an exhaustive list of supported flags.
481 ;; (Note: The 'configure' phase will do that for you.)
482 (list "is_debug=false"
483 ;; Use the "official" release optimizations, as opposed to
484 ;; a developer build.
485 "is_official_build=true"
486 (string-append "max_jobs_per_link="
487 (number->string (parallel-job-count)))
488 "clang_use_chrome_plugins=false"
489 "use_custom_libcxx=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 "closure_compile=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 (string-append "xcbproto_path=\""
516 (assoc-ref %build-inputs "xcb-proto") "/share/xcb\"")
518 ;; Prefer system libraries.
519 "use_system_freetype=true"
520 "use_system_harfbuzz=true"
521 "use_system_lcms2=true"
522 "use_system_libdrm=true"
523 "use_system_libjpeg=true"
524 "use_system_libopenjpeg2=true"
525 "use_system_libpng=true"
526 "use_system_zlib=true"
527 "use_gnome_keyring=false" ;deprecated by libsecret
529 "use_pulseaudio=true"
530 "link_pulseaudio=true"
531 "icu_use_data_file=false"
533 ;; FIXME: Using system protobuf with "is_official_build" causes an
534 ;; invalid opcode and "protoc-gen-plugin: Plugin killed by signal 4".
535 ;;"perfetto_use_system_protobuf=true"
537 ;; VA-API acceleration is currently only supported on x86_64-linux.
538 ,@(if (string-prefix? "x86_64" (or (%current-target-system)
543 ;; Do not artifically restrict formats supported by system ffmpeg.
544 "proprietary_codecs=true"
545 "ffmpeg_branding=\"Chrome\""
549 ;; Don't use bundled sources.
550 "rtc_build_json=false"
551 "rtc_build_libevent=false"
552 "rtc_build_libvpx=false"
553 "rtc_build_opus=false"
554 "rtc_build_ssl=false"
555 "rtc_build_libsrtp=true" ;FIXME: fails to find headers
556 "rtc_build_usrsctp=true" ;TODO: package this
557 (string-append "rtc_jsoncpp_root=\""
558 (assoc-ref %build-inputs "jsoncpp")
559 "/include/jsoncpp/json\"")
560 (string-append "rtc_ssl_root=\""
561 (assoc-ref %build-inputs "openssl")
562 "/include/openssl\""))
564 (modify-phases %standard-phases
565 (add-after 'unpack 'patch-stuff
567 ;; Fix build with newer re2. Taken from:
568 ;; https://chromium-review.googlesource.com/c/chromium/src/+/2145261
569 (substitute* "components/autofill/core/browser/address_rewriter.cc"
570 (("options\\.set_utf8\\(true\\)")
571 "options.set_encoding(RE2::Options::EncodingUTF8)"))
574 '("base/process/launch_posix.cc"
575 "base/third_party/dynamic_annotations/dynamic_annotations.c"
576 "sandbox/linux/seccomp-bpf/sandbox_bpf.cc"
577 "sandbox/linux/services/credentials.cc"
578 "sandbox/linux/services/namespace_utils.cc"
579 "sandbox/linux/services/syscall_wrappers.cc"
580 "sandbox/linux/syscall_broker/broker_host.cc")
581 (("include \"base/third_party/valgrind/") "include \"valgrind/"))
583 (for-each (lambda (file)
585 ;; Fix opus include path.
586 ;; Do not substitute opus_private.h.
587 (("#include \"opus\\.h\"")
588 "#include \"opus/opus.h\"")
589 (("#include \"opus_custom\\.h\"")
590 "#include \"opus/opus_custom.h\"")
591 (("#include \"opus_defines\\.h\"")
592 "#include \"opus/opus_defines.h\"")
593 (("#include \"opus_multistream\\.h\"")
594 "#include \"opus/opus_multistream.h\"")
595 (("#include \"opus_types\\.h\"")
596 "#include \"opus/opus_types.h\"")))
597 (find-files (string-append "third_party/webrtc/modules"
598 "/audio_coding/codecs/opus")))
600 (substitute* "chrome/common/chrome_paths.cc"
601 (("/usr/share/chromium/extensions")
602 ;; TODO: Add ~/.guix-profile.
603 "/run/current-system/profile/share/chromium/extensions"))
605 ;; Many files try to include ICU headers from "third_party/icu/...".
606 ;; Remove the "third_party/" prefix to use system headers instead.
607 (substitute* (find-files "chrome" "\\.cc$")
608 (("third_party/icu/source/(common|i18n)/")
611 ;; XXX: Should be unnecessary when use_system_lcms2=true.
612 (substitute* "third_party/pdfium/core/fxcodec/icc/iccmodule.h"
613 (("include \"third_party/lcms/include/lcms2\\.h\"")
614 "include \"lcms2.h\""))
617 "third_party/breakpad/breakpad/src/common/linux/libcurl_wrapper.h"
618 (("include \"third_party/curl") "include \"curl"))
620 (substitute* "third_party/webrtc/rtc_base/strings/json.h"
621 (("#include \"third_party/jsoncpp/") "#include \"json/"))
623 (substitute* '("components/viz/common/gpu/vulkan_context_provider.h"
624 "components/viz/common/resources/resource_format_utils.h"
625 "gpu/config/gpu_util.cc")
626 (("third_party/vulkan_headers/include/") ""))
628 (substitute* "third_party/skia/include/gpu/vk/GrVkVulkan.h"
629 (("include/third_party/vulkan/") ""))
631 ;; Building chromedriver embeds some files using the ZIP
632 ;; format which doesn't support timestamps before
633 ;; 1980. Therefore, advance the timestamps of the files
634 ;; which are included so that building chromedriver
636 (let ((circa-1980 (* 10 366 24 60 60)))
637 (for-each (lambda (file)
638 (utime file circa-1980 circa-1980))
639 '("chrome/test/chromedriver/extension/background.js"
640 "chrome/test/chromedriver/extension/manifest.json")))
643 (add-after 'patch-stuff 'add-absolute-references
644 (lambda* (#:key inputs #:allow-other-keys)
645 (let ((cups (assoc-ref inputs "cups"))
646 (nss (assoc-ref inputs "nss"))
647 (mesa (assoc-ref inputs "mesa"))
648 (udev (assoc-ref inputs "udev")))
649 (substitute* "printing/cups_config_helper.py"
651 (string-append "cups_config = '" cups
652 "/bin/cups-config'\n")))
653 (substitute* "crypto/nss_util.cc"
655 (string-append nss "/lib/nss/libnssckbi.so")))
656 (substitute* "device/udev_linux/udev1_loader.cc"
657 (("libudev\\.so\\.1")
658 (string-append udev "/lib/libudev.so.1")))
660 (add-before 'configure 'prepare-build-environment
661 (lambda* (#:key inputs #:allow-other-keys)
663 ;; Make sure the right build tools are used.
664 (setenv "AR" "llvm-ar") (setenv "NM" "llvm-nm")
665 (setenv "CC" "clang") (setenv "CXX" "clang++")
669 '(;; Do not optimize away null pointer safety checks.
670 "-fno-delete-null-pointer-checks"
671 ;; Disable warnings about unknown warnings that require
672 ;; Clang plugins or newer versions.
673 "-Wno-unknown-warning-option")))
675 (setenv "CFLAGS" "-Wno-unknown-warning-option")
677 ;; TODO: pre-compile instead. Avoids a race condition.
678 (setenv "PYTHONDONTWRITEBYTECODE" "1")
680 ;; XXX: How portable is this.
681 (mkdir-p "third_party/node/linux/node-linux-x64")
682 (symlink (string-append (assoc-ref inputs "node") "/bin")
683 "third_party/node/linux/node-linux-x64/bin")
687 (lambda* (#:key configure-flags #:allow-other-keys)
688 (let ((args (string-join configure-flags " ")))
689 ;; Generate ninja build files.
690 (invoke "gn" "gen" "out/Release"
691 (string-append "--args=" args))
693 ;; Print the full list of supported arguments as well as
694 ;; their current status for convenience.
695 (format #t "Dumping configure flags...\n")
696 (invoke "gn" "args" "out/Release" "--list"))))
697 (add-before 'build 'increase-resource-limits
699 ;; XXX: Chromiums linking step requires a lot of simultaneous file
700 ;; accesses. Having a too low ulimit will result in bogus linker
701 ;; errors such as "foo.a: error adding symbols: malformed archive".
703 ;; Try increasing the soft resource limit of max open files to 2048,
704 ;; or equal to the hard limit, whichever is lower.
705 (call-with-values (lambda () (getrlimit 'nofile))
707 (when (and soft (< soft 2048))
709 (setrlimit 'nofile (min hard 2048) hard)
710 (setrlimit 'nofile 2048 #f))
712 "increased maximum number of open files from ~d to ~d~%"
713 soft (if hard (min hard 2048) 2048)))))
716 (lambda* (#:key (parallel-build? #t) #:allow-other-keys)
717 (invoke "ninja" "-C" "out/Release"
718 "-j" (if parallel-build?
719 (number->string (parallel-job-count))
724 (lambda* (#:key inputs outputs #:allow-other-keys)
725 (let* ((out (assoc-ref outputs "out"))
726 (bin (string-append out "/bin"))
727 (exe (string-append bin "/chromium"))
728 (lib (string-append out "/lib"))
729 (man (string-append out "/share/man/man1"))
730 (applications (string-append out "/share/applications"))
731 (install-regexp (make-regexp "\\.(bin|pak|so)$"))
732 (locales (string-append lib "/locales"))
733 (resources (string-append lib "/resources"))
734 (preferences (assoc-ref inputs "master-preferences"))
735 (gtk+ (assoc-ref inputs "gtk+"))
738 (substitute* '("chrome/app/resources/manpage.1.in"
739 "chrome/installer/linux/common/desktop.template")
740 (("@@MENUNAME@@") "Chromium")
741 (("@@PACKAGE@@") "chromium")
742 (("/usr/bin/@@USR_BIN_SYMLINK_NAME@@") exe))
745 (copy-file "chrome/app/resources/manpage.1.in"
746 (string-append man "/chromium.1"))
748 (mkdir-p applications)
749 (copy-file "chrome/installer/linux/common/desktop.template"
750 (string-append applications "/chromium.desktop"))
753 (copy-file preferences (string-append lib "/master_preferences"))
755 (with-directory-excursion "out/Release"
756 (for-each (lambda (file)
757 (install-file file lib))
758 (scandir "." (cut regexp-exec install-regexp <>)))
759 (copy-file "chrome" (string-append lib "/chromium"))
761 (copy-recursively "locales" locales)
762 (copy-recursively "resources" resources)
765 (symlink "../lib/chromium" exe)
766 (install-file "chromedriver" bin)
768 (for-each (lambda (so)
769 (install-file so (string-append lib "/swiftshader")))
770 (find-files "swiftshader" "\\.so$"))
773 ;; Avoid file manager crash. See <https://bugs.gnu.org/26593>.
774 `("XDG_DATA_DIRS" ":" prefix (,(string-append gtk+ "/share")))))
776 (with-directory-excursion "chrome/app/theme/chromium"
779 (let ((icons (string-append out "/share/icons/hicolor/"
780 size "x" size "/apps")))
782 (copy-file (string-append "product_logo_" size ".png")
783 (string-append icons "/chromium.png"))))
784 '("24" "48" "64" "128" "256")))
791 ("ld-wrapper" ,(make-lld-wrapper lld))
794 ("pkg-config" ,pkg-config)
797 ;; This file contains defaults for new user profiles.
798 ("master-preferences" ,(local-file "aux-files/chromium/master-preferences.json"))
800 ("python-beautifulsoup4" ,python2-beautifulsoup4)
801 ("python-html5lib" ,python2-html5lib)
802 ("python" ,python-2)))
804 `(("alsa-lib" ,alsa-lib)
809 ("dbus-glib" ,dbus-glib)
813 ("fontconfig" ,fontconfig)
814 ("freetype" ,freetype)
815 ("gdk-pixbuf" ,gdk-pixbuf)
818 ("harfbuzz" ,harfbuzz)
822 ("libevent" ,libevent)
824 ("libjpeg-turbo" ,libjpeg-turbo)
831 ("libxcomposite" ,libxcomposite)
832 ("libxcursor" ,libxcursor)
833 ("libxdamage" ,libxdamage)
835 ("libxfixes" ,libxfixes)
838 ("libxrandr" ,libxrandr)
839 ("libxrender" ,libxrender)
840 ("libxscrnsaver" ,libxscrnsaver)
845 ("mit-krb5" ,mit-krb5)
847 ("openh264" ,openh264)
848 ("openjpeg" ,openjpeg) ;PDFium only
850 ("opus" ,opus+custom)
852 ("pciutils" ,pciutils)
853 ("pulseaudio" ,pulseaudio)
856 ("speech-dispatcher" ,speech-dispatcher)
858 ("valgrind" ,valgrind)
859 ("vulkan-headers" ,vulkan-headers)
860 ("xcb-proto" ,xcb-proto/python2)))
862 ;; Building Chromium takes ... a very long time. On a single core, a busy
863 ;; mid-end x86 system may need more than 24 hours to complete the build.
864 (properties '((timeout . 144000) ;40 hours
865 ;; The linking step may take more than an hour on some hardware.
866 (max-silent-time . 7200)
867 (cpe-name . "chrome")))
869 (home-page "https://github.com/Eloston/ungoogled-chromium")
871 "Ungoogled-Chromium is the Chromium web browser, with some functionality
872 disabled in order to protect the users privacy.")
873 ;; Chromium is developed as BSD-3, but bundles a large number of third-party
874 ;; components with other licenses. For full information, see chrome://credits.
875 (license (list license:bsd-3
881 license:public-domain
883 (license:non-copyleft "chrome://credits"
884 "See chrome://credits for more information.")
887 (define-public ungoogled-chromium/wayland
888 (package/inherit ungoogled-chromium
889 (name "ungoogled-chromium-wayland")
891 `(("wayland" ,wayland)
892 ("wayland-protocols" ,wayland-protocols)
893 ,@(package-inputs ungoogled-chromium)))
895 (substitute-keyword-arguments (package-arguments ungoogled-chromium)
896 ((#:configure-flags flags)
897 `(append (list "use_ozone=true"
898 "ozone_platform_wayland=true"
899 "ozone_platform_x11=true"
900 "ozone_auto_platforms=false"
901 "ozone_platform=\"wayland\""
903 "use_system_minigbm=true"
904 "use_system_libwayland=true"
905 (string-append "system_wayland_scanner_path=\""
906 (assoc-ref %build-inputs "wayland")
907 "/bin/wayland-scanner\""))
908 (delete "use_vaapi=true" ,flags)))))))