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