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