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