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