gnu: rust-traitobject-0.1: Don't hide package.
[jackhill/guix/guix.git] / gnu / packages / chromium.scm
CommitLineData
f1e9de4d 1;;; GNU Guix --- Functional package management for GNU
f8157512 2;;; Copyright © 2019, 2020 Marius Bakke <mbakke@fastmail.com>
3df7b15e 3;;; Copyright © 2019 Alex Griffin <a@ajgrf.com>
f1e9de4d
MB
4;;;
5;;; This file is part of GNU Guix.
6;;;
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.
11;;;
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.
16;;;
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/>.
19
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)
82ccfb1d 39 #:use-module (gnu packages freedesktop)
f1e9de4d
MB
40 #:use-module (gnu packages gcc)
41 #:use-module (gnu packages ghostscript)
42 #:use-module (gnu packages gl)
43 #:use-module (gnu packages glib)
44 #:use-module (gnu packages gnome)
f1e9de4d
MB
45 #:use-module (gnu packages gperf)
46 #:use-module (gnu packages gtk)
47 #:use-module (gnu packages icu4c)
48 #:use-module (gnu packages image)
49 #:use-module (gnu packages libevent)
50 #:use-module (gnu packages libffi)
51 #:use-module (gnu packages linux)
52 #:use-module (gnu packages kerberos)
53 #:use-module (gnu packages ninja)
54 #:use-module (gnu packages node)
aff0cce9 55 #:use-module (gnu packages nss)
f1e9de4d
MB
56 #:use-module (gnu packages pciutils)
57 #:use-module (gnu packages pkg-config)
58 #:use-module (gnu packages pulseaudio)
59 #:use-module (gnu packages python)
60 #:use-module (gnu packages python-web)
61 #:use-module (gnu packages python-xyz)
62 #:use-module (gnu packages regex)
63 #:use-module (gnu packages serialization)
64 #:use-module (gnu packages speech)
65 #:use-module (gnu packages tls)
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)
4cac5579
MB
72 #:use-module (gnu packages xorg)
73 #:use-module (ice-9 match))
f1e9de4d
MB
74
75(define %preserved-third-party-files
7f2e8522 76 '("base/third_party/cityhash" ;Expat
ba261f63 77 "base/third_party/double_conversion" ;BSD-3
f1e9de4d
MB
78 "base/third_party/dynamic_annotations" ;BSD-2
79 "base/third_party/icu" ;Unicode, X11-style
80 "base/third_party/superfasthash" ;BSD-3
81 "base/third_party/symbolize" ;BSD-3
82 "base/third_party/xdg_mime" ;LGPL2.0+ or Academic 2.0
83 "base/third_party/xdg_user_dirs" ;Expat
84 "chrome/third_party/mozilla_security_manager" ;MPL-1.1/GPL2+/LGPL2.1+
85 "courgette/third_party/bsdiff" ;BSD-2, BSD protection license
86 "courgette/third_party/divsufsort" ;Expat
f1e9de4d
MB
87 "net/third_party/mozilla_security_manager" ;MPL-1.1/GPL2+/LGPL2.1+
88 "net/third_party/nss" ;MPL-2.0
7f2e8522 89 "net/third_party/quiche" ;BSD-3
f1e9de4d
MB
90 "net/third_party/uri_template" ;ASL2.0
91 "third_party/abseil-cpp" ;ASL2.0
92 "third_party/adobe/flash/flapper_version.h" ;no license, trivial
93 "third_party/angle" ;BSD-3
94 "third_party/angle/src/common/third_party/base" ;BSD-3
95 "third_party/angle/src/common/third_party/smhasher" ;Public domain
96 "third_party/angle/src/common/third_party/xxhash" ;BSD-2
97 "third_party/angle/src/third_party/compiler" ;BSD-2
98 "third_party/angle/src/third_party/libXNVCtrl" ;Expat
99 "third_party/angle/src/third_party/trace_event" ;BSD-3
f1e9de4d
MB
100 "third_party/angle/third_party/vulkan-headers" ;ASL2.0
101 "third_party/angle/third_party/vulkan-loader" ;ASL2.0
102 "third_party/angle/third_party/vulkan-tools" ;ASL2.0
103 "third_party/angle/third_party/vulkan-validation-layers" ;ASL2.0
104 "third_party/apple_apsl" ;APSL2.0
136eeb0b 105 "third_party/axe-core" ;MPL2.0
f1e9de4d
MB
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
7f2e8522
MB
109 "third_party/boringssl/src/third_party/sike" ;Expat
110 ;; XXX: these files are generated by fp-$arch.pl in the above directory.
111 "third_party/boringssl/linux-aarch64/crypto/third_party/sike/asm/fp-armv8.S"
112 "third_party/boringssl/linux-x86_64/crypto/third_party/sike/asm/fp-x86_64.S"
f1e9de4d
MB
113 "third_party/breakpad" ;BSD-3
114 "third_party/brotli" ;Expat
115 "third_party/cacheinvalidation" ;ASL2.0
116 "third_party/catapult" ;BSD-3
117 "third_party/catapult/common/py_vulcanize/third_party/rcssmin" ;ASL2.0
118 "third_party/catapult/common/py_vulcanize/third_party/rjsmin" ;ASL2.0
119 "third_party/catapult/third_party/polymer" ;BSD-3
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/jszip" ;Expat or GPL3
123 "third_party/catapult/tracing/third_party/mannwhitneyu" ;Expat
124 "third_party/catapult/tracing/third_party/oboe" ;BSD-2
125 "third_party/catapult/tracing/third_party/pako" ;Expat
126 "third_party/ced" ;BSD-3
127 "third_party/cld_3" ;ASL2.0
ba261f63 128 "third_party/closure_compiler" ;ASL2.0
f1e9de4d 129 "third_party/crashpad" ;ASL2.0
136eeb0b 130 "third_party/crashpad/crashpad/third_party/lss" ;ASL2.0
f1e9de4d
MB
131 "third_party/crashpad/crashpad/third_party/zlib/zlib_crashpad.h" ;Zlib
132 "third_party/crc32c" ;BSD-3
133 "third_party/cros_system_api" ;BSD-3
af74e435 134 "third_party/dav1d" ;BSD-2
136eeb0b 135 "third_party/dawn" ;ASL2.0
ba261f63 136 "third_party/depot_tools/owners.py" ;BSD-3
f1e9de4d 137 "third_party/dom_distiller_js" ;BSD-3
af74e435 138 "third_party/emoji-segmenter" ;ASL2.0
f1e9de4d 139 "third_party/flatbuffers" ;ASL2.0
af74e435 140 "third_party/glslang" ;BSD-3, Expat, ASL2.0
f1e9de4d
MB
141 "third_party/google_input_tools" ;ASL2.0
142 "third_party/google_input_tools/third_party/closure_library" ;ASL2.0
143 "third_party/google_input_tools/third_party/closure_library/third_party/closure" ;Expat
144 "third_party/googletest" ;BSD-3
145 "third_party/hunspell" ;MPL1.1/GPL2+/LGPL2.1+
146 "third_party/iccjpeg" ;IJG
147 "third_party/inspector_protocol" ;BSD-3
148 "third_party/jinja2" ;BSD-3
149 "third_party/jstemplate" ;ASL2.0
150 "third_party/khronos" ;Expat, SGI
151 "third_party/leveldatabase" ;BSD-3
152 "third_party/libXNVCtrl" ;Expat
153 "third_party/libaddressinput" ;ASL2.0
154 "third_party/libaom" ;BSD-2 or "Alliance for Open Media Patent License 1.0"
155 "third_party/libaom/source/libaom/third_party/vector" ;Expat
156 "third_party/libaom/source/libaom/third_party/x86inc" ;ISC
157 "third_party/libjingle_xmpp" ;BSD-3
158 "third_party/libphonenumber" ;ASL2.0
159 "third_party/libsecret" ;LGPL2.1+
160 "third_party/libsrtp" ;BSD-3
161 "third_party/libsync" ;ASL2.0
162 "third_party/libudev" ;LGPL2.1+
163 "third_party/libwebm" ;BSD-3
164 "third_party/libxml/chromium" ;BSD-3
165 "third_party/libyuv" ;BSD-3
166 "third_party/lss" ;BSD-3
167 "third_party/markupsafe" ;BSD-3
168 "third_party/mesa_headers" ;Expat, SGI
169 "third_party/metrics_proto" ;BSD-3
170 "third_party/modp_b64" ;BSD-3
171 "third_party/nasm" ;BSD-2
172 "third_party/node" ;Expat
173 "third_party/node/node_modules/polymer-bundler/lib/third_party/UglifyJS2" ;BSD-2
ba261f63 174 "third_party/one_euro_filter" ;BSD-3
7f2e8522 175 "third_party/openscreen" ;BSD-3
ba261f63 176 "third_party/openscreen/src/third_party/tinycbor" ;Expat
f1e9de4d
MB
177 "third_party/ots" ;BSD-3
178 "third_party/pdfium" ;BSD-3
179 "third_party/pdfium/third_party/agg23" ;Expat
180 "third_party/pdfium/third_party/base" ;BSD-3
181 "third_party/pdfium/third_party/bigint" ;Public domain, BSD-3
182 "third_party/pdfium/third_party/skia_shared" ;BSD-3
183 "third_party/pdfium/third_party/freetype/include/pstables.h" ;FreeType
136eeb0b 184 "third_party/pffft" ;the "FFTPACK" license, similar to BSD-3
f1e9de4d
MB
185 "third_party/ply" ;BSD-3
186 "third_party/polymer" ;BSD-3
ba261f63 187 "third_party/private-join-and-compute" ;ASL2.0
f1e9de4d
MB
188 "third_party/protobuf" ;BSD-3
189 "third_party/protobuf/third_party/six" ;Expat
190 "third_party/pyjson5" ;ASL2.0
191 "third_party/qcms" ;Expat
192 "third_party/rnnoise" ;BSD-3
193 "third_party/s2cellid" ;ASL2.0
194 "third_party/sfntly" ;ASL2.0
195 "third_party/skia" ;BSD-3
7f2e8522 196 "third_party/skia/include/third_party/skcms" ;BSD-3
f1e9de4d
MB
197 "third_party/skia/third_party/gif" ;MPL1.1/GPL2+/LGPL2.1+
198 "third_party/skia/third_party/skcms" ;BSD-3
7f2e8522 199 "third_party/skia/third_party/vulkanmemoryallocator" ;BSD-3, Expat
f1e9de4d
MB
200 "third_party/smhasher" ;Expat, public domain
201 "third_party/speech-dispatcher" ;GPL2+
202 "third_party/spirv-headers" ;ASL2.0
203 "third_party/SPIRV-Tools" ;ASL2.0
204 "third_party/sqlite" ;Public domain
205 "third_party/ungoogled" ;BSD-3
206 "third_party/usb_ids" ;BSD-3
207 "third_party/usrsctp" ;BSD-2
82ccfb1d
MB
208 "third_party/wayland/wayland_scanner_wrapper.py" ;BSD-3
209 "third_party/wayland-protocols" ;Expat
f1e9de4d
MB
210 "third_party/web-animations-js" ;ASL2.0
211 "third_party/webdriver" ;ASL2.0
212 "third_party/webrtc" ;BSD-3
213 "third_party/webrtc/common_audio/third_party/fft4g" ;Non-copyleft
214 "third_party/webrtc/common_audio/third_party/spl_sqrt_floor" ;Public domain
215 "third_party/webrtc/modules/third_party/fft" ;Non-copyleft
216 "third_party/webrtc/modules/third_party/g711" ;Public domain
217 "third_party/webrtc/modules/third_party/g722" ;Public domain
218 "third_party/webrtc/rtc_base/third_party/base64" ;Non-copyleft
219 "third_party/webrtc/rtc_base/third_party/sigslot" ;Public domain
220 "third_party/widevine/cdm/widevine_cdm_version.h" ;BSD-3
221 "third_party/widevine/cdm/widevine_cdm_common.h" ;BSD-3
222 "third_party/woff2" ;ASL2.0
223 "third_party/xdg-utils" ;Expat
224 "third_party/yasm/run_yasm.py" ;BSD-2 or BSD-3
225 "third_party/zlib/google" ;BSD-3
226 "url/third_party/mozilla" ;BSD-3, MPL1.1/GPL2+/LGPL2.1+
105fa9fc 227 "v8/src/third_party/siphash" ;Public domain
f1e9de4d
MB
228 "v8/src/third_party/utf8-decoder" ;Expat
229 "v8/src/third_party/valgrind" ;BSD-4
230 "v8/third_party/inspector_protocol" ;BSD-3
231 "v8/third_party/v8/builtins")) ;PSFL
232
233(define* (computed-origin-method gexp-promise hash-algo hash
234 #:optional (name "source")
235 #:key (system (%current-system))
236 (guile (default-guile)))
237 "Return a derivation that executes the G-expression that results
238from forcing GEXP-PROMISE."
239 (mlet %store-monad ((guile (package->derivation guile system)))
240 (gexp->derivation (or name "computed-origin")
241 (force gexp-promise)
2a1ec7bc 242 #:graft? #f ;nothing to graft
f1e9de4d
MB
243 #:system system
244 #:guile-for-build guile)))
245
a7d470e4
MB
246(define %chromium-version "79.0.3945.130")
247(define %ungoogled-revision "e2fae994d786b6716fb473a47b0c880bcfdc2497")
248(define %debian-revision "debian/79.0.3945.130-2")
88115539 249(define package-revision "0")
718540d2
MB
250(define %package-version (string-append %chromium-version "-"
251 package-revision "."
252 (string-take %ungoogled-revision 7)))
f1e9de4d 253
d0804ea0
MB
254(define %chromium-origin
255 (origin
256 (method url-fetch)
257 (uri (string-append "https://commondatastorage.googleapis.com"
258 "/chromium-browser-official/chromium-"
259 %chromium-version ".tar.xz"))
260 (sha256
261 (base32
a7d470e4 262 "183vz3lf1588cr9s5vlnj65qvbmz36s8cg8k7dvr64cxmcqk86an"))))
d0804ea0
MB
263
264(define %ungoogled-origin
265 (origin
266 (method git-fetch)
267 (uri (git-reference (url "https://github.com/Eloston/ungoogled-chromium")
268 (commit %ungoogled-revision)))
269 (file-name (git-file-name "ungoogled-chromium"
270 (string-take %ungoogled-revision 7)))
271 (sha256
272 (base32
a7d470e4 273 "15vmc07iba1zmzn4j7c5n2hyvyxzwwf9hc3kyym0m4jajlsyxr5f"))))
d0804ea0
MB
274
275(define %debian-origin
276 (origin
277 (method git-fetch)
278 (uri (git-reference
279 (url "https://salsa.debian.org/chromium-team/chromium.git")
280 (commit %debian-revision)))
281 (file-name (git-file-name "debian-chromium-packaging"
4cac5579
MB
282 (match (string-split %debian-revision #\/)
283 ((_ revision) revision)
284 (_ (string-take %debian-revision 7)))))
d0804ea0
MB
285 (sha256
286 (base32
a7d470e4 287 "1rbzxcwfp7v0c6rkvn9jl9by7p363cnbdyqazwiak1z03kmw3nkz"))))
7f2e8522 288
f1e9de4d 289;; This is a "computed" origin that does the following:
105fa9fc
MB
290;; *) Runs the Ungoogled scripts on a pristine Chromium tarball.
291;; *) Applies Debians Chromium patches, for their unbundling and GCC work.
292;; *) Prunes all third_party directories that are not explicitly preserved.
293;; *) Adjusts "GN" build files such that system libraries are preferred.
f1e9de4d 294(define ungoogled-chromium-source
d0804ea0
MB
295 (let ((chromium-source %chromium-origin)
296 (ungoogled-source %ungoogled-origin)
297 (debian-source %debian-origin))
f1e9de4d
MB
298 (origin
299 (method computed-origin-method)
718540d2 300 (file-name (string-append "ungoogled-chromium-" %package-version ".tar.xz"))
f1e9de4d
MB
301 (sha256 #f)
302 (uri
303 (delay
304 (with-imported-modules '((guix build utils))
305 #~(begin
105fa9fc
MB
306 (use-modules (guix build utils)
307 (ice-9 rdelim)
308 (srfi srfi-1)
309 (srfi srfi-26))
f1e9de4d
MB
310 (let ((chromium-dir (string-append "chromium-" #$%chromium-version))
311 (preserved-files (list #$@%preserved-third-party-files)))
312
313 (set-path-environment-variable
314 "PATH" '("bin")
315 (list #+(canonical-package patch)
316 #+(canonical-package xz)
317 #+(canonical-package tar)
318 #+python-2
319 #+python))
320
321 (copy-recursively #+ungoogled-source "/tmp/ungoogled")
322
323 (with-directory-excursion "/tmp/ungoogled"
324
f1e9de4d
MB
325 (format #t "Unpacking chromium tarball...~%")
326 (force-output)
327 (invoke "tar" "xf" #+chromium-source)
328
7f2e8522
MB
329 ;; Ungoogled-Chromium contains a forked subset of the Debian
330 ;; patches. Disable those, as we apply newer versions later.
331 (substitute* "patches/series"
a7d470e4 332 ((".*/debian/.*")
7f2e8522
MB
333 ""))
334
f1e9de4d
MB
335 (format #t "Ungooglifying...~%")
336 (force-output)
105fa9fc
MB
337 (invoke "python3" "utils/prune_binaries.py" chromium-dir
338 "pruning.list")
339 (invoke "python3" "utils/patches.py" "apply"
340 chromium-dir "patches")
341 (invoke "python3" "utils/domain_substitution.py" "apply" "-r"
342 "domain_regex.list" "-f" "domain_substitution.list"
f1e9de4d
MB
343 "-c" "/tmp/domainscache.tar.gz" chromium-dir)
344
345 (with-directory-excursion chromium-dir
105fa9fc
MB
346
347 (format #t "applying Debian patches...~%")
348 (force-output)
349 (let* ((debian #+debian-source)
350 (patches (string-append debian "/debian/patches"))
7f2e8522 351 (series (string-append patches "/series")))
105fa9fc
MB
352 (with-input-from-file series
353 (lambda ()
354 (let loop ((line (read-line)))
355 (unless (eof-object? line)
356 (when (and (> (string-length line) 1)
a7d470e4 357 (not (string-prefix? "#" line))
105fa9fc
MB
358 ;; Skip the Debian-specific ones.
359 (not (string-prefix? "debianization/" line))
7f2e8522 360 (not (string-prefix? "buster/" line))
105fa9fc 361 (not (any (cute string-suffix? <> line)
ba261f63 362 ;; These conflict with Ungoogled.
105fa9fc
MB
363 '("widevine-buildflag.patch"
364 "signin.patch"
7f2e8522
MB
365 "third-party-cookies.patch"
366
ba261f63
MB
367 ;; Disable workarounds for the
368 ;; Chromium "-lite" tarball. We
369 ;; use the "full" version and don't
370 ;; need these patches.
371 "closure.patch"
372 "owners.patch"
373
7f2e8522
MB
374 ;; XXX: 'fixes/inspector.patch'
375 ;; makes v8 reuse the top-level
376 ;; third_party/inspector_protocol
377 ;; instead of its own bundled copy,
378 ;; but that does not work here for
379 ;; some reason. Ignore that patch
380 ;; and those that depend on it.
7f2e8522 381 "inspector.patch"))))
105fa9fc
MB
382 (invoke "patch" "--force" "-p1" "--input"
383 (string-append patches "/" line)
384 "--no-backup-if-mismatch"))
385 (loop (read-line)))))))
386
f1e9de4d
MB
387 (format #t "Pruning third party files...~%")
388 (force-output)
389 (apply invoke "python"
105fa9fc
MB
390 "build/linux/unbundle/remove_bundled_libraries.py"
391 "--do-remove" preserved-files)
f1e9de4d
MB
392
393 (format #t "Replacing GN files...~%")
394 (force-output)
395 (invoke "python3" "build/linux/unbundle/replace_gn_files.py"
396 "--system-libraries" "ffmpeg" "flac" "fontconfig"
397 "freetype" "harfbuzz-ng" "icu" "libdrm" "libevent"
398 "libjpeg" "libpng" "libvpx" "libwebp" "libxml"
399 "libxslt" "openh264" "opus" "re2" "snappy" "yasm"
400 "zlib"))
401
402 (format #t (string-append "Packing new ungoogled tarball ...~%"))
403 (force-output)
404 (invoke "tar" "cvfa" #$output
405 ;; Avoid non-determinism in the archive.
406 "--mtime=@0"
407 "--owner=root:0"
408 "--group=root:0"
409 "--sort=name"
410 chromium-dir)
411
412 #t)))))))))
413
414(define opus+custom
415 (package/inherit opus
416 (name "opus+custom")
417 (arguments
418 (substitute-keyword-arguments (package-arguments opus)
419 ((#:configure-flags flags ''())
420 ;; Opus Custom is an optional extension of the Opus
421 ;; specification that allows for unsupported frame
422 ;; sizes. Chromium requires that this is enabled.
423 `(cons "--enable-custom-modes"
424 ,flags))))))
425
426(define-public ungoogled-chromium
427 (package
428 (name "ungoogled-chromium")
718540d2 429 (version %package-version)
f1e9de4d
MB
430 (synopsis "Graphical web browser")
431 (source ungoogled-chromium-source)
432 (build-system gnu-build-system)
433 (arguments
434 `(#:tests? #f
f8157512 435 ;; FIXME: Chromiums RUNPATH lacks entries for some libraries.
f1e9de4d
MB
436 #:validate-runpath? #f
437 #:modules ((guix build gnu-build-system)
438 (guix build utils)
439 (ice-9 ftw)
440 (ice-9 regex)
441 (srfi srfi-26))
442 #:configure-flags
443 ;; See tools/gn/docs/cookbook.md and
444 ;; https://www.chromium.org/developers/gn-build-configuration
445 ;; for usage. Run "./gn args . --list" in the Release
446 ;; directory for an exhaustive list of supported flags.
447 ;; (Note: The 'configure' phase will do that for you.)
448 (list "is_debug=false"
449 "use_gold=false"
450 "use_lld=false"
451 "linux_use_bundled_binutils=false"
452 "use_custom_libcxx=false"
453 "use_sysroot=false"
454 "enable_precompiled_headers=false"
455 "goma_dir=\"\""
456 "enable_nacl=false"
457 "enable_nacl_nonsfi=false"
458 "use_allocator=\"none\""
459 "use_unofficial_version_number=false"
460 "treat_warnings_as_errors=false"
461 "use_official_google_api_keys=false"
462 "fieldtrial_testing_like_official_build=true"
463 "safe_browsing_mode=0"
464 "enable_mdns=false"
465 "enable_one_click_signin=false"
466 "enable_reading_list=false"
467 "enable_remoting=false"
468 "enable_reporting=false"
469 "enable_service_discovery=false"
470 "enable_swiftshader=false"
136eeb0b 471 "enable_vr=false"
78a64543 472 "enable_widevine=false"
f1e9de4d
MB
473 ;; Disable type-checking for the Web UI to avoid a Java dependency.
474 "closure_compile=false"
475
476 ;; Define a custom toolchain that simply looks up CC, AR and
477 ;; friends from the environment.
478 "custom_toolchain=\"//build/toolchain/linux/unbundle:default\""
479 "host_toolchain=\"//build/toolchain/linux/unbundle:default\""
480 ;; Don't assume it's clang.
481 "is_clang=false"
482 ;; Disable debugging features to save space. These are normally
483 ;; pulled in by "is_official_build", but that requires "is_clang".
f1e9de4d
MB
484 "enable_iterator_debugging=false"
485 "exclude_unwind_tables=true"
486 ;; Optimize for building everything at once, as opposed to
487 ;; incrementally for development. See "docs/jumbo.md".
488 "use_jumbo_build=true"
6a489839
MB
489 ;; The default file merge limit of 50 requires huge amounts of RAM.
490 ;; Cap it to make sure the build succeeds on commodity hardware.
491 "jumbo_file_merge_limit=8"
f1e9de4d
MB
492
493 ;; Prefer system libraries.
494 "use_system_freetype=true"
495 "use_system_harfbuzz=true"
496 "use_system_lcms2=true"
497 "use_system_libdrm=true"
498 "use_system_libjpeg=true"
ca86b0ba 499 "use_system_libopenjpeg2=true"
f1e9de4d
MB
500 "use_system_libpng=true"
501 "use_system_zlib=true"
502 "use_gnome_keyring=false" ;deprecated by libsecret
503 "use_openh264=true"
504 "use_pulseaudio=true"
505 "link_pulseaudio=true"
799aebd7
MB
506
507 ;; VA-API acceleration is currently only supported on x86_64-linux.
508 ,@(if (string-prefix? "x86_64" (or (%current-target-system)
509 (%current-system)))
510 '("use_vaapi=true")
511 '())
f1e9de4d 512
7f2e8522 513 ;; Do not artifically restrict formats supported by system ffmpeg.
f1e9de4d
MB
514 "proprietary_codecs=true"
515 "ffmpeg_branding=\"Chrome\""
516
517 ;; WebRTC stuff.
518 "rtc_use_h264=true"
519 ;; Don't use bundled sources.
520 "rtc_build_json=false"
521 "rtc_build_libevent=false"
522 "rtc_build_libvpx=false"
523 "rtc_build_opus=false"
524 "rtc_build_ssl=false"
525 "rtc_build_libsrtp=true" ;FIXME: fails to find headers
526 "rtc_build_usrsctp=true" ;TODO: package this
527 (string-append "rtc_jsoncpp_root=\""
528 (assoc-ref %build-inputs "jsoncpp")
529 "/include/jsoncpp/json\"")
530 (string-append "rtc_ssl_root=\""
531 (assoc-ref %build-inputs "openssl")
532 "/include/openssl\""))
533 #:phases
534 (modify-phases %standard-phases
535 (add-after 'unpack 'patch-stuff
f8157512 536 (lambda _
f1e9de4d
MB
537 (substitute*
538 '("base/process/launch_posix.cc"
539 "base/third_party/dynamic_annotations/dynamic_annotations.c"
540 "sandbox/linux/seccomp-bpf/sandbox_bpf.cc"
541 "sandbox/linux/services/credentials.cc"
542 "sandbox/linux/services/namespace_utils.cc"
543 "sandbox/linux/services/syscall_wrappers.cc"
544 "sandbox/linux/syscall_broker/broker_host.cc")
545 (("include \"base/third_party/valgrind/") "include \"valgrind/"))
546
547 (for-each (lambda (file)
548 (substitute* file
549 ;; Fix opus include path.
550 ;; Do not substitute opus_private.h.
551 (("#include \"opus\\.h\"")
552 "#include \"opus/opus.h\"")
553 (("#include \"opus_custom\\.h\"")
554 "#include \"opus/opus_custom.h\"")
555 (("#include \"opus_defines\\.h\"")
556 "#include \"opus/opus_defines.h\"")
557 (("#include \"opus_multistream\\.h\"")
558 "#include \"opus/opus_multistream.h\"")
559 (("#include \"opus_types\\.h\"")
560 "#include \"opus/opus_types.h\"")))
561 (find-files (string-append "third_party/webrtc/modules"
562 "/audio_coding/codecs/opus")))
563
564 (substitute* "chrome/common/chrome_paths.cc"
565 (("/usr/share/chromium/extensions")
566 ;; TODO: Add ~/.guix-profile.
567 "/run/current-system/profile/share/chromium/extensions"))
568
ba261f63
MB
569 ;; Many files try to include ICU headers from "third_party/icu/...".
570 ;; Remove the "third_party/" prefix to use system headers instead.
571 (substitute* (find-files "chrome" "\\.cc$")
572 (("third_party/icu/source/(common|i18n)/")
573 ""))
574
f1e9de4d 575 ;; XXX: Should be unnecessary when use_system_lcms2=true.
ba261f63 576 (substitute* "third_party/pdfium/core/fxcodec/icc/iccmodule.h"
f1e9de4d
MB
577 (("include \"third_party/lcms/include/lcms2\\.h\"")
578 "include \"lcms2.h\""))
579
580 (substitute*
581 "third_party/breakpad/breakpad/src/common/linux/libcurl_wrapper.h"
582 (("include \"third_party/curl") "include \"curl"))
583
584 (substitute* "third_party/webrtc/rtc_base/strings/json.h"
585 (("#include \"third_party/jsoncpp/") "#include \"json/"))
586
7f2e8522 587 (substitute* '("components/viz/common/gpu/vulkan_context_provider.h"
105fa9fc 588 "components/viz/common/resources/resource_format_utils.h")
f1e9de4d
MB
589 (("third_party/vulkan/include/") ""))
590
105fa9fc 591 (substitute* "third_party/skia/include/gpu/vk/GrVkVulkan.h"
7f2e8522 592 (("include/third_party/vulkan/") ""))
105fa9fc 593
f1e9de4d
MB
594 ;; Building chromedriver embeds some files using the ZIP
595 ;; format which doesn't support timestamps before
596 ;; 1980. Therefore, advance the timestamps of the files
597 ;; which are included so that building chromedriver
598 ;; works.
599 (let ((circa-1980 (* 10 366 24 60 60)))
600 (for-each (lambda (file)
601 (utime file circa-1980 circa-1980))
602 '("chrome/test/chromedriver/extension/background.js"
603 "chrome/test/chromedriver/extension/manifest.json")))
604
605 #t))
f8157512
MB
606 (add-after 'patch-stuff 'add-absolute-references
607 (lambda* (#:key inputs #:allow-other-keys)
608 (let ((cups (assoc-ref inputs "cups"))
609 (nss (assoc-ref inputs "nss"))
610 (mesa (assoc-ref inputs "mesa"))
611 (udev (assoc-ref inputs "udev")))
612 (substitute* "printing/cups_config_helper.py"
613 (("cups_config =.*")
614 (string-append "cups_config = '" cups
615 "/bin/cups-config'\n")))
616 (substitute* "crypto/nss_util.cc"
617 (("libnssckbi\\.so")
618 (string-append nss "/lib/nss/libnssckbi.so")))
619 (substitute* "device/udev_linux/udev1_loader.cc"
620 (("libudev\\.so\\.1")
621 (string-append udev "/lib/libudev.so.1")))
622 (substitute*
623 '("ui/ozone/platform/x11/gl_ozone_glx.cc"
624 "ui/ozone/common/egl_util.cc"
625 "ui/gl/init/gl_initializer_x11.cc"
626 "third_party/angle/src/libANGLE/renderer/gl/glx/FunctionsGLX.cpp")
627 (("libGL\\.so\\.1")
628 (string-append mesa "/lib/libGL.so.1"))
629 (("libEGL\\.so\\.1")
630 (string-append mesa "/lib/libEGL.so.1"))
631 (("libGLESv2\\.so\\.2")
632 (string-append mesa "/lib/libGLESv2.so.2")))
633 #t)))
f1e9de4d
MB
634 (add-before 'configure 'prepare-build-environment
635 (lambda* (#:key inputs #:allow-other-keys)
636
637 ;; Make sure the right build tools are used.
638 (setenv "AR" "ar") (setenv "NM" "nm")
639 (setenv "CC" "gcc") (setenv "CXX" "g++")
640
7f2e8522
MB
641 ;; Prevent GCC from optimizing away null pointer safety checks.
642 (setenv "CXXFLAGS" "-fno-delete-null-pointer-checks")
643
f1e9de4d
MB
644 ;; TODO: pre-compile instead. Avoids a race condition.
645 (setenv "PYTHONDONTWRITEBYTECODE" "1")
646
647 ;; XXX: How portable is this.
648 (mkdir-p "third_party/node/linux/node-linux-x64")
649 (symlink (string-append (assoc-ref inputs "node") "/bin")
650 "third_party/node/linux/node-linux-x64/bin")
651
652 #t))
653 (replace 'configure
654 (lambda* (#:key configure-flags #:allow-other-keys)
655 (let ((args (string-join configure-flags " ")))
656 ;; Generate ninja build files.
657 (invoke "gn" "gen" "out/Release"
658 (string-append "--args=" args))
659
660 ;; Print the full list of supported arguments as well as
661 ;; their current status for convenience.
662 (format #t "Dumping configure flags...\n")
663 (invoke "gn" "args" "out/Release" "--list"))))
664fa4b1
MB
664 (add-before 'build 'increase-resource-limits
665 (lambda _
ba261f63
MB
666 ;; XXX: Chromiums linking step requires a lot of simultaneous file
667 ;; accesses. Having a too low ulimit will result in bogus linker
668 ;; errors such as "foo.a: error adding symbols: malformed archive".
669
07b10725 670 ;; Try increasing the soft resource limit of max open files to 2048,
ba261f63
MB
671 ;; or equal to the hard limit, whichever is lower.
672 (call-with-values (lambda () (getrlimit 'nofile))
673 (lambda (soft hard)
07b10725 674 (when (and soft (< soft 2048))
ba261f63 675 (if hard
07b10725
MB
676 (setrlimit 'nofile (min hard 2048) hard)
677 (setrlimit 'nofile 2048 #f))
ba261f63
MB
678 (format #t
679 "increased maximum number of open files from ~d to ~d~%"
07b10725 680 soft (if hard (min hard 2048) 2048)))))
664fa4b1
MB
681 #t))
682 (replace 'build
683 (lambda* (#:key (parallel-build? #t) #:allow-other-keys)
f1e9de4d 684 (invoke "ninja" "-C" "out/Release"
9a2e5fe5
MB
685 "-j" (if parallel-build?
686 (number->string (parallel-job-count))
687 "1")
f1e9de4d
MB
688 "chrome"
689 "chromedriver")))
690 (replace 'install
691 (lambda* (#:key inputs outputs #:allow-other-keys)
692 (let* ((out (assoc-ref outputs "out"))
693 (bin (string-append out "/bin"))
694 (exe (string-append bin "/chromium"))
695 (lib (string-append out "/lib"))
696 (man (string-append out "/share/man/man1"))
697 (applications (string-append out "/share/applications"))
698 (install-regexp (make-regexp "\\.(bin|pak)$"))
699 (locales (string-append lib "/locales"))
700 (resources (string-append lib "/resources"))
701 (preferences (assoc-ref inputs "master-preferences"))
702 (gtk+ (assoc-ref inputs "gtk+"))
f1e9de4d
MB
703 (sh (which "sh")))
704
705 (substitute* '("chrome/app/resources/manpage.1.in"
706 "chrome/installer/linux/common/desktop.template")
707 (("@@MENUNAME@@") "Chromium")
708 (("@@PACKAGE@@") "chromium")
709 (("/usr/bin/@@USR_BIN_SYMLINK_NAME@@") exe))
710
711 (mkdir-p man)
712 (copy-file "chrome/app/resources/manpage.1.in"
713 (string-append man "/chromium.1"))
714
715 (mkdir-p applications)
716 (copy-file "chrome/installer/linux/common/desktop.template"
717 (string-append applications "/chromium.desktop"))
718
719 (mkdir-p lib)
720 (copy-file preferences (string-append lib "/master_preferences"))
721
722 (with-directory-excursion "out/Release"
723 (for-each (lambda (file)
724 (install-file file lib))
725 (scandir "." (cut regexp-exec install-regexp <>)))
726 (copy-file "chrome" (string-append lib "/chromium"))
727
f1e9de4d
MB
728 (copy-recursively "locales" locales)
729 (copy-recursively "resources" resources)
730
731 (mkdir-p bin)
732 (symlink "../lib/chromium" exe)
733 (install-file "chromedriver" bin)
734
735 (wrap-program exe
f1e9de4d 736 ;; Avoid file manager crash. See <https://bugs.gnu.org/26593>.
3df7b15e
AG
737 `("XDG_DATA_DIRS" ":" prefix (,(string-append gtk+ "/share")))))
738
739 (with-directory-excursion "chrome/app/theme/chromium"
740 (for-each
741 (lambda (size)
742 (let ((icons (string-append out "/share/icons/hicolor/"
743 size "x" size "/apps")))
744 (mkdir-p icons)
745 (copy-file (string-append "product_logo_" size ".png")
746 (string-append icons "/chromium.png"))))
ba261f63 747 '("24" "48" "64" "128" "256")))
3df7b15e 748 #t))))))
f1e9de4d
MB
749 (native-inputs
750 `(("bison" ,bison)
751 ("gcc" ,gcc-8)
752 ("gn" ,gn)
753 ("gperf" ,gperf)
754 ("ninja" ,ninja)
755 ("node" ,node)
756 ("pkg-config" ,pkg-config)
757 ("which" ,which)
758 ("yasm" ,yasm)
759
760 ;; This file contains defaults for new user profiles.
761 ("master-preferences" ,(local-file "aux-files/chromium/master-preferences.json"))
762
763 ("python-beautifulsoup4" ,python2-beautifulsoup4)
764 ("python-html5lib" ,python2-html5lib)
765 ("python" ,python-2)))
766 (inputs
767 `(("alsa-lib" ,alsa-lib)
768 ("atk" ,atk)
769 ("cups" ,cups)
770 ("curl" ,curl)
771 ("dbus" ,dbus)
772 ("dbus-glib" ,dbus-glib)
773 ("expat" ,expat)
774 ("flac" ,flac)
775 ("ffmpeg" ,ffmpeg)
776 ("fontconfig" ,fontconfig)
777 ("freetype" ,freetype)
778 ("gdk-pixbuf" ,gdk-pixbuf)
779 ("glib" ,glib)
780 ("gtk+" ,gtk+)
781 ("harfbuzz" ,harfbuzz)
fb82d347 782 ("icu4c" ,icu4c)
f1e9de4d
MB
783 ("jsoncpp" ,jsoncpp)
784 ("lcms" ,lcms)
785 ("libevent" ,libevent)
786 ("libffi" ,libffi)
787 ("libjpeg-turbo" ,libjpeg-turbo)
788 ("libpng" ,libpng)
789 ("libva" ,libva)
a7d470e4 790 ("libvpx" ,libvpx)
f1e9de4d
MB
791 ("libwebp" ,libwebp)
792 ("libx11" ,libx11)
793 ("libxcb" ,libxcb)
794 ("libxcomposite" ,libxcomposite)
795 ("libxcursor" ,libxcursor)
796 ("libxdamage" ,libxdamage)
797 ("libxext" ,libxext)
798 ("libxfixes" ,libxfixes)
799 ("libxi" ,libxi)
800 ("libxml2" ,libxml2)
801 ("libxrandr" ,libxrandr)
802 ("libxrender" ,libxrender)
803 ("libxscrnsaver" ,libxscrnsaver)
804 ("libxslt" ,libxslt)
805 ("libxtst" ,libxtst)
806 ("mesa" ,mesa)
807 ("minizip" ,minizip)
808 ("mit-krb5" ,mit-krb5)
809 ("nss" ,nss)
810 ("openh264" ,openh264)
811 ("openjpeg" ,openjpeg) ;PDFium only
812 ("openssl" ,openssl)
813 ("opus" ,opus+custom)
814 ("pango" ,pango)
815 ("pciutils" ,pciutils)
816 ("pulseaudio" ,pulseaudio)
817 ("re2" ,re2)
818 ("snappy" ,snappy)
819 ("speech-dispatcher" ,speech-dispatcher)
820 ("udev" ,eudev)
821 ("valgrind" ,valgrind)
822 ("vulkan-headers" ,vulkan-headers)))
c94cc6de 823
760d90cc
MB
824 ;; Building Chromium takes ... a very long time. On a single core, a busy
825 ;; mid-end x86 system may need more than 24 hours to complete the build.
ba261f63 826 (properties '((timeout . 144000))) ;40 hours
c94cc6de 827
f1e9de4d
MB
828 (home-page "https://github.com/Eloston/ungoogled-chromium")
829 (description
830 "Ungoogled-Chromium is the Chromium web browser, with some functionality
831disabled in order to protect the users privacy.")
832 ;; Chromium is developed as BSD-3, but bundles a large number of third-party
833 ;; components with other licenses. For full information, see chrome://credits.
834 (license (list license:bsd-3
835 license:bsd-2
836 license:expat
837 license:asl2.0
838 license:mpl1.1
839 license:mpl2.0
840 license:public-domain
841 license:isc
842 (license:non-copyleft "chrome://credits"
843 "See chrome://credits for more information.")
844 license:lgpl2.1+))))
82ccfb1d
MB
845
846(define-public ungoogled-chromium/wayland
847 (package/inherit ungoogled-chromium
848 (name "ungoogled-chromium-wayland")
849 (inputs
850 `(("wayland" ,wayland)
851 ("wayland-protocols" ,wayland-protocols)
ba261f63 852 ,@(package-inputs ungoogled-chromium)))
82ccfb1d
MB
853 (arguments
854 (substitute-keyword-arguments (package-arguments ungoogled-chromium)
855 ((#:configure-flags flags)
856 `(append (list "use_ozone=true"
857 "ozone_platform_wayland=true"
858 "ozone_auto_platforms=false"
a7d470e4 859 "ozone_platform=\"wayland\""
82ccfb1d
MB
860 "use_xkbcommon=true"
861 "use_system_minigbm=true"
862 "use_system_libwayland=true"
863 (string-append "system_wayland_scanner_path=\""
864 (assoc-ref %build-inputs "wayland")
865 "/bin/wayland-scanner\""))
866 (delete "use_vaapi=true" ,flags)))))))