gnu: ungoogled-chromium: Update to 88.0.4324.182-0.b98f2d5.
[jackhill/guix/guix.git] / gnu / packages / chromium.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2019, 2020, 2021 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 (guix build-system trivial)
31 #:use-module (gnu packages)
32 #:use-module (gnu packages assembly)
33 #:use-module (gnu packages base)
34 #:use-module (gnu packages bash)
35 #:use-module (gnu packages bison)
36 #:use-module (gnu packages build-tools)
37 #:use-module (gnu packages compression)
38 #:use-module (gnu packages cups)
39 #:use-module (gnu packages curl)
40 #:use-module (gnu packages fontutils)
41 #:use-module (gnu packages freedesktop)
42 #:use-module (gnu packages ghostscript)
43 #:use-module (gnu packages gl)
44 #:use-module (gnu packages glib)
45 #:use-module (gnu packages gnome)
46 #:use-module (gnu packages gperf)
47 #:use-module (gnu packages gtk)
48 #:use-module (gnu packages icu4c)
49 #:use-module (gnu packages image)
50 #:use-module (gnu packages libevent)
51 #:use-module (gnu packages libffi)
52 #:use-module (gnu packages linux)
53 #:use-module (gnu packages llvm)
54 #:use-module (gnu packages kerberos)
55 #:use-module (gnu packages ninja)
56 #:use-module (gnu packages node)
57 #:use-module (gnu packages nss)
58 #:use-module (gnu packages pciutils)
59 #:use-module (gnu packages pkg-config)
60 #:use-module (gnu packages protobuf)
61 #:use-module (gnu packages pulseaudio)
62 #:use-module (gnu packages python)
63 #:use-module (gnu packages python-web)
64 #:use-module (gnu packages python-xyz)
65 #:use-module (gnu packages regex)
66 #:use-module (gnu packages serialization)
67 #:use-module (gnu packages speech)
68 #:use-module (gnu packages tls)
69 #:use-module (gnu packages valgrind)
70 #:use-module (gnu packages vulkan)
71 #:use-module (gnu packages video)
72 #:use-module (gnu packages xiph)
73 #:use-module (gnu packages xml)
74 #:use-module (gnu packages xdisorg)
75 #:use-module (gnu packages xorg)
76 #:use-module (ice-9 match)
77 #:use-module (srfi srfi-1))
78
79 (define %preserved-third-party-files
80 '("base/third_party/cityhash" ;Expat
81 "base/third_party/double_conversion" ;BSD-3
82 "base/third_party/dynamic_annotations" ;BSD-2
83 "base/third_party/icu" ;Unicode, X11-style
84 "base/third_party/superfasthash" ;BSD-3
85 "base/third_party/symbolize" ;BSD-3
86 "base/third_party/xdg_mime" ;LGPL2.0+ or Academic 2.0
87 "base/third_party/xdg_user_dirs" ;Expat
88 ;; XXX: Chromium requires a newer C++ standard library. Remove this when
89 ;; the default GCC is 9 or later.
90 "buildtools/third_party/libc++" ;ASL2.0, with LLVM exceptions
91 "chrome/third_party/mozilla_security_manager" ;MPL-1.1/GPL2+/LGPL2.1+
92 "courgette/third_party/bsdiff" ;BSD-2, BSD protection license
93 "courgette/third_party/divsufsort" ;Expat
94 "net/third_party/mozilla_security_manager" ;MPL-1.1/GPL2+/LGPL2.1+
95 "net/third_party/nss" ;MPL-2.0
96 "net/third_party/quiche" ;BSD-3
97 "net/third_party/uri_template" ;ASL2.0
98 "third_party/abseil-cpp" ;ASL2.0
99 "third_party/adobe/flash/flapper_version.h" ;no license, trivial
100 "third_party/angle" ;BSD-3
101 "third_party/angle/src/common/third_party/base" ;BSD-3
102 "third_party/angle/src/common/third_party/smhasher" ;Public domain
103 "third_party/angle/src/common/third_party/xxhash" ;BSD-2
104 "third_party/angle/src/third_party/compiler" ;BSD-2
105 "third_party/angle/src/third_party/libXNVCtrl" ;Expat
106 "third_party/angle/src/third_party/trace_event" ;BSD-3
107 "third_party/angle/src/third_party/volk" ;Expat
108 "third_party/angle/third_party/vulkan-headers" ;ASL2.0
109 "third_party/angle/third_party/vulkan-loader" ;ASL2.0
110 "third_party/angle/third_party/vulkan-tools" ;ASL2.0
111 "third_party/angle/third_party/vulkan-validation-layers" ;ASL2.0
112 "third_party/apple_apsl" ;APSL2.0
113 "third_party/axe-core" ;MPL2.0
114 "third_party/blink" ;BSD-3, LGPL2+
115 "third_party/boringssl" ;OpenSSL/ISC (Google additions are ISC)
116 "third_party/boringssl/src/third_party/fiat" ;Expat
117 "third_party/breakpad" ;BSD-3
118 "third_party/brotli" ;Expat
119 "third_party/catapult" ;BSD-3
120 "third_party/catapult/common/py_vulcanize/third_party/rcssmin" ;ASL2.0
121 "third_party/catapult/common/py_vulcanize/third_party/rjsmin" ;ASL2.0
122 "third_party/catapult/third_party/polymer" ;BSD-3
123 ;; XXX: This is a minified version of <https://d3js.org/>.
124 "third_party/catapult/tracing/third_party/d3" ;BSD-3
125 "third_party/catapult/tracing/third_party/gl-matrix" ;Expat
126 "third_party/catapult/tracing/third_party/jpeg-js" ;ASL2.0
127 ;; XXX: Minified version of <https://github.com/Stuk/jszip>.
128 "third_party/catapult/tracing/third_party/jszip" ;Expat or GPL3
129 "third_party/catapult/tracing/third_party/mannwhitneyu" ;Expat
130 "third_party/catapult/tracing/third_party/oboe" ;BSD-2
131 ;; XXX: Minified version of <https://github.com/nodeca/pako>.
132 "third_party/catapult/tracing/third_party/pako" ;Expat
133 "third_party/ced" ;BSD-3
134 "third_party/cld_3" ;ASL2.0
135 "third_party/closure_compiler" ;ASL2.0
136 "third_party/crashpad" ;ASL2.0
137 "third_party/crashpad/crashpad/third_party/lss" ;ASL2.0
138 "third_party/crashpad/crashpad/third_party/zlib/zlib_crashpad.h" ;Zlib
139 "third_party/crc32c" ;BSD-3
140 "third_party/cros_system_api" ;BSD-3
141 "third_party/dav1d" ;BSD-2
142 "third_party/dawn" ;ASL2.0
143 "third_party/depot_tools/owners.py" ;BSD-3
144 "third_party/devtools-frontend" ;BSD-3
145 "third_party/devtools-frontend/src/front_end/third_party/acorn" ;Expat
146 "third_party/devtools-frontend/src/front_end/third_party/axe-core" ;MPL2.0
147 "third_party/devtools-frontend/src/front_end/third_party/chromium" ;BSD-3
148 "third_party/devtools-frontend/src/front_end/third_party/codemirror" ;Expat
149 "third_party/devtools-frontend/src/front_end/third_party/fabricjs" ;Expat
150 "third_party/devtools-frontend/src/front_end/third_party/i18n" ;ASL2.0
151 "third_party/devtools-frontend/src/front_end/third_party/intl-messageformat" ;BSD-3
152 "third_party/devtools-frontend/src/front_end/third_party/lighthouse" ;ASL2.0
153 "third_party/devtools-frontend/src/front_end/third_party/lit-html" ;BSD-3
154 "third_party/devtools-frontend/src/front_end/third_party/lodash-isequal" ;Expat
155 "third_party/devtools-frontend/src/front_end/third_party/marked" ;Expat, BSD-3
156 "third_party/devtools-frontend/src/front_end/third_party/puppeteer" ;ASL2.0
157 "third_party/devtools-frontend/src/front_end/third_party/wasmparser" ;ASL2.0
158 "third_party/devtools-frontend/src/third_party/pyjson5" ;ASL2.0
159 "third_party/devtools-frontend/src/third_party/typescript" ;ASL2.0
160 "third_party/dom_distiller_js" ;BSD-3
161 "third_party/emoji-segmenter" ;ASL2.0
162 "third_party/flatbuffers" ;ASL2.0
163 "third_party/fusejs" ;ASL2.0
164 "third_party/glslang" ;BSD-3, Expat, ASL2.0
165 "third_party/google_input_tools" ;ASL2.0
166 "third_party/google_input_tools/third_party/closure_library" ;ASL2.0
167 "third_party/google_input_tools/third_party/closure_library/third_party/closure" ;Expat
168 "third_party/googletest" ;BSD-3
169 "third_party/harfbuzz-ng" ;Expat
170 "third_party/hunspell" ;MPL1.1/GPL2+/LGPL2.1+
171 "third_party/iccjpeg" ;IJG
172 "third_party/inspector_protocol" ;BSD-3
173 "third_party/jinja2" ;BSD-3
174 ;; XXX: Unbundle this when switching back to libstdc++.
175 "third_party/jsoncpp" ;Public Domain or Expat
176 "third_party/jstemplate" ;ASL2.0
177 "third_party/khronos" ;Expat, SGI
178 "third_party/leveldatabase" ;BSD-3
179 "third_party/libavif" ;BSD-2
180 "third_party/libXNVCtrl" ;Expat
181 "third_party/libaddressinput" ;ASL2.0
182 "third_party/libaom" ;BSD-2 or "Alliance for Open Media Patent License 1.0"
183 "third_party/libaom/source/libaom/third_party/vector" ;Expat
184 "third_party/libaom/source/libaom/third_party/x86inc" ;ISC
185 "third_party/libgifcodec" ;MPL1.1/GPL2+/LGPL2.1+, BSD-3, BSD-2
186 "third_party/libjingle_xmpp" ;BSD-3
187 "third_party/libphonenumber" ;ASL2.0
188 "third_party/libsecret" ;LGPL2.1+
189 "third_party/libsrtp" ;BSD-3
190 "third_party/libsync" ;ASL2.0
191 "third_party/libudev" ;LGPL2.1+
192
193 ;; FIXME: build/linux/unbundle/libvpx.gn does not work for all users.
194 "third_party/libvpx" ;BSD-3
195 "third_party/libvpx/source/libvpx/third_party/x86inc" ;Expat
196
197 "third_party/libwebm" ;BSD-3
198 "third_party/libxml/chromium" ;BSD-3
199 "third_party/libyuv" ;BSD-3
200 "third_party/lottie" ;Expat
201 "third_party/lss" ;BSD-3
202 "third_party/mako" ;Expat
203 "third_party/markupsafe" ;BSD-3
204 "third_party/mesa_headers" ;Expat, SGI
205 "third_party/metrics_proto" ;BSD-3
206 "third_party/modp_b64" ;BSD-3
207 "third_party/nasm" ;BSD-2
208 "third_party/nearby" ;ASL2.0
209 "third_party/node" ;Expat
210 "third_party/node/node_modules/polymer-bundler/lib/third_party/UglifyJS2" ;BSD-2
211 "third_party/one_euro_filter" ;BSD-3
212 "third_party/openscreen" ;BSD-3
213 "third_party/openscreen/src/third_party/tinycbor" ;Expat
214 "third_party/openscreen/src/third_party/mozilla" ;MPL1.1/GPL2+/LGPL2.1+, BSD-3
215 "third_party/ots" ;BSD-3
216 "third_party/pdfium" ;BSD-3
217 "third_party/pdfium/third_party/agg23" ;Expat
218 "third_party/pdfium/third_party/base" ;BSD-3
219 "third_party/pdfium/third_party/bigint" ;Public domain, BSD-3
220 "third_party/pdfium/third_party/skia_shared" ;BSD-3
221 "third_party/pdfium/third_party/freetype/include/pstables.h" ;FreeType
222 "third_party/perfetto" ;ASL2.0
223 "third_party/pffft" ;the "FFTPACK" license, similar to BSD-3
224 "third_party/ply" ;BSD-3
225 "third_party/polymer" ;BSD-3
226 "third_party/private_membership" ;ASL2.0
227 "third_party/private-join-and-compute" ;ASL2.0
228 "third_party/protobuf" ;BSD-3
229 "third_party/protobuf/third_party/six" ;Expat
230 "third_party/pyjson5" ;ASL2.0
231 "third_party/qcms" ;Expat
232 ;; XXX: System re2 cannot be used when Chromium uses libc++ because the re2
233 ;; ABI relies on libstdc++ internals. See build/linux/unbundle/re2.gn.
234 "third_party/re2" ;BSD-3
235 "third_party/rnnoise" ;BSD-3
236 "third_party/s2cellid" ;ASL2.0
237 "third_party/schema_org" ;CC-BY-SA3.0
238 "third_party/securemessage" ;ASL2.0
239 "third_party/shaka-player" ;ASL2.0
240 "third_party/shell-encryption" ;ASL2.0
241 "third_party/skia" ;BSD-3
242 "third_party/skia/include/third_party/skcms" ;BSD-3
243 "third_party/skia/third_party/skcms" ;BSD-3
244 "third_party/skia/third_party/vulkanmemoryallocator" ;BSD-3, Expat
245 "third_party/smhasher" ;Expat, public domain
246 "third_party/speech-dispatcher" ;GPL2+
247 "third_party/spirv-headers" ;ASL2.0
248 "third_party/SPIRV-Tools" ;ASL2.0
249 "third_party/sqlite" ;Public domain
250 "third_party/swiftshader" ;ASL2.0
251 "third_party/swiftshader/third_party/astc-encoder" ;ASL2.0
252 "third_party/swiftshader/third_party/llvm-10.0" ;ASL2.0, with LLVM exception
253 "third_party/swiftshader/third_party/llvm-subzero" ;NCSA
254 "third_party/swiftshader/third_party/marl" ;ASL2.0
255 "third_party/swiftshader/third_party/subzero" ;NCSA
256 "third_party/swiftshader/third_party/SPIRV-Headers" ;X11-style
257 "third_party/tcmalloc/chromium" ;BSD-3
258 "third_party/ukey2" ;ASL2.0
259 "third_party/usb_ids" ;BSD-3
260 "third_party/usrsctp" ;BSD-2
261 "third_party/vulkan_memory_allocator" ;Expat
262 "third_party/wayland/protocol" ;Expat
263 "third_party/wayland/stubs" ;BSD-3, Expat
264 "third_party/wayland/wayland_scanner_wrapper.py" ;BSD-3
265 "third_party/wayland-protocols" ;Expat
266 "third_party/web-animations-js" ;ASL2.0
267 "third_party/webdriver" ;ASL2.0
268 "third_party/webrtc" ;BSD-3
269 "third_party/webrtc/common_audio/third_party/ooura" ;Non-copyleft
270 "third_party/webrtc/common_audio/third_party/spl_sqrt_floor" ;Public domain
271 "third_party/webrtc/modules/third_party/fft" ;Non-copyleft
272 "third_party/webrtc/modules/third_party/g711" ;Public domain
273 "third_party/webrtc/modules/third_party/g722" ;Public domain
274 "third_party/webrtc/rtc_base/third_party/base64" ;Non-copyleft
275 "third_party/webrtc/rtc_base/third_party/sigslot" ;Public domain
276 "third_party/widevine/cdm/widevine_cdm_version.h" ;BSD-3
277 "third_party/widevine/cdm/widevine_cdm_common.h" ;BSD-3
278 "third_party/woff2" ;ASL2.0
279 "third_party/xcbproto" ;X11
280 "third_party/xdg-utils" ;Expat
281
282 ;; These are forked components of the X11 keybinding code.
283 "third_party/libxcb-keysyms" ;X11
284 "third_party/libx11/src/KeyBind.c" ;X11
285 "third_party/libx11/src/xkb/XKBBind.c" ;X11
286 "third_party/x11proto/keysymdef.h" ;X11
287
288 "third_party/zlib/google" ;BSD-3
289 "third_party/zxcvbn-cpp" ;Expat
290 "url/third_party/mozilla" ;BSD-3, MPL1.1/GPL2+/LGPL2.1+
291 "v8/src/third_party/siphash" ;Public domain
292 "v8/src/third_party/utf8-decoder" ;Expat
293 "v8/src/third_party/valgrind" ;BSD-4
294 "v8/third_party/inspector_protocol" ;BSD-3
295 "v8/third_party/v8/builtins")) ;PSFL
296
297 (define %blacklisted-files
298 ;; 'third_party/blink/perf_tests/resources/svg/HarveyRayner.svg' carries a
299 ;; nonfree license according to LICENSES in the same directory. As we don't
300 ;; run the Blink performance tests, just remove everything to save ~70MiB.
301 '("third_party/blink/perf_tests"))
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 %chromium-version "88.0.4324.182")
314 (define %ungoogled-revision "b98f2d51406c84a75df96f0da9dee3c0d790963d")
315 (define %debian-revision "debian/84.0.4147.105-1")
316
317 (define %debian-patches
318 (list (debian-patch "system/zlib.patch" %debian-revision
319 "09vqgs37w9ycc7par14wa7rnvmg9bm0z9pqg6fyl3iqvpghyjyr4")
320 (debian-patch "system/openjpeg.patch" %debian-revision
321 "0zd6v5njx1pc7i0y6mslxvpx5j4cq01mmyx55qcqx8qzkm0gm48j")))
322
323 (define %ungoogled-origin
324 (origin
325 (method git-fetch)
326 (uri (git-reference (url "https://github.com/Eloston/ungoogled-chromium")
327 (commit %ungoogled-revision)))
328 (file-name (git-file-name "ungoogled-chromium"
329 (string-take %ungoogled-revision 7)))
330 (sha256
331 (base32
332 "1c9y1dn9s06pskkjw2r8lsbplak8m2rwh4drixvjpif7b4cgdhay"))))
333
334 (define %guix-patches
335 (list (local-file
336 (assume-valid-file-name
337 (search-patch "ungoogled-chromium-system-nspr.patch")))
338 (local-file
339 (assume-valid-file-name
340 (search-patch "ungoogled-chromium-extension-search-path.patch")))))
341
342 ;; This is a source 'snippet' that does the following:
343 ;; *) Applies various patches for unbundling purposes and libstdc++ compatibility.
344 ;; *) Runs the ungoogled patch-, domain substitution-, and scrubbing scripts.
345 ;; *) Prunes all third_party directories that are not explicitly preserved.
346 ;; *) Adjusts "GN" build files such that system libraries are preferred.
347 (define ungoogled-chromium-snippet
348 ;; Note: delay to cope with cyclic module imports at the top level.
349 (delay
350 #~(begin
351 (let ((chromium-dir (getcwd)))
352 (set-path-environment-variable
353 "PATH" '("bin")
354 (list #+patch #+python-wrapper #+xz))
355
356 ;; Apply patches before running the ungoogled scripts because
357 ;; domain substitution may break some of the patches.
358 (format #t "Applying assorted build fixes...~%")
359 (force-output)
360 (for-each (lambda (patch)
361 (invoke "patch" "-p1" "--force" "--input"
362 patch "--no-backup-if-mismatch"))
363 (append '#+%debian-patches '#+%guix-patches))
364
365 (with-directory-excursion #+%ungoogled-origin
366 (format #t "Ungooglifying...~%")
367 (force-output)
368 (invoke "python" "utils/prune_binaries.py" chromium-dir
369 "pruning.list")
370 (invoke "python" "utils/patches.py" "apply" chromium-dir
371 "patches")
372 (invoke "python" "utils/domain_substitution.py" "apply" "-r"
373 "domain_regex.list" "-f" "domain_substitution.list"
374 "-c" "/tmp/domainscache.tar.gz" chromium-dir))
375
376 ;; Run after the ungoogled scripts to avoid interfering with
377 ;; patches or file lists.
378 (format #t "Removing blacklisted files...~%")
379 (force-output)
380 (for-each delete-file-recursively '#$%blacklisted-files)
381
382 (format #t "Pruning third party files...~%")
383 (force-output)
384 (apply invoke (string-append #+python-2 "/bin/python")
385 "build/linux/unbundle/remove_bundled_libraries.py"
386 "--do-remove" '#$%preserved-third-party-files)
387
388 (format #t "Replacing GN files...~%")
389 (force-output)
390 (substitute* "tools/generate_shim_headers/generate_shim_headers.py"
391 ;; The "is_official_build" configure option enables certain
392 ;; release optimizations like those used in the commercial
393 ;; Chrome browser. Unfortunately it also requires using the
394 ;; bundled libraries: lose that restriction.
395 (("#if defined\\(OFFICIAL_BUILD\\)")
396 "#if 0"))
397 (invoke "python" "build/linux/unbundle/replace_gn_files.py"
398 "--system-libraries" "ffmpeg" "flac" "fontconfig"
399 "freetype" "harfbuzz-ng" "icu" "libdrm" "libevent"
400 "libjpeg" "libpng" "libwebp" "libxml" "libxslt"
401 "openh264" "opus" "snappy" "zlib")
402 #t))))
403
404 (define opus+custom
405 (package/inherit opus
406 (name "opus+custom")
407 (arguments
408 (substitute-keyword-arguments (package-arguments opus)
409 ((#:configure-flags flags ''())
410 ;; Opus Custom is an optional extension of the Opus
411 ;; specification that allows for unsupported frame
412 ;; sizes. Chromium requires that this is enabled.
413 `(cons "--enable-custom-modes"
414 ,flags))))))
415
416 ;; WebRTC in Chromium 88 requires an unreleased version of libvpx. Use the
417 ;; commit mentioned in "third_party/libvpx/README.chromium".
418 (define libvpx/chromium
419 (package
420 (inherit libvpx)
421 (version "1.9.0-88-g12059d956")
422 (source (origin
423 (inherit (package-source libvpx))
424 (uri (git-reference
425 (url "https://chromium.googlesource.com/webm/libvpx")
426 (commit (string-append "v" version))))
427 (file-name (git-file-name "libvpx" version))
428 (sha256
429 (base32
430 "14knnvfaskfz97vs3lfqrdpcbcx22s6qp16213wdnvnsf4c1lx1b"))))))
431
432 ;; 'make-ld-wrapper' can only work with an 'ld' executable, so we need
433 ;; this trick to make it wrap 'lld'.
434 (define (make-lld-wrapper lld)
435 (define lld-as-ld
436 (computed-file "lld-ld"
437 #~(begin
438 (mkdir #$output)
439 (mkdir (string-append #$output "/bin"))
440 (symlink #$(file-append lld "/bin/lld")
441 (string-append #$output "/bin/ld")))))
442
443 ;; Create a wrapper for LLD that inserts appropriate -rpath entries.
444 (define lld-wrapper
445 (make-ld-wrapper "lld-wrapper"
446 #:binutils lld-as-ld))
447
448 ;; Clang looks for an 'ld.lld' executable, so we need to symlink it back.
449 (computed-file "lld-wrapped"
450 #~(begin
451 (mkdir #$output)
452 (mkdir (string-append #$output "/bin"))
453 (symlink #$(file-append lld-wrapper "/bin/ld")
454 (string-append #$output "/bin/lld"))
455 (symlink "lld" (string-append #$output "/bin/ld.lld")))))
456
457 (define-public ungoogled-chromium
458 (package
459 (name "ungoogled-chromium")
460 (version (string-append %chromium-version "-0."
461 (string-take %ungoogled-revision 7)))
462 (synopsis "Graphical web browser")
463 (source (origin
464 (method url-fetch)
465 (uri (string-append "https://commondatastorage.googleapis.com"
466 "/chromium-browser-official/chromium-"
467 %chromium-version ".tar.xz"))
468 (sha256
469 (base32
470 "10av060ix6lgsvv99lyvyy03r0m3zwdg4hddbi6dycrdxk1iyh9h"))
471 (modules '((guix build utils)))
472 (snippet (force ungoogled-chromium-snippet))))
473 (build-system gnu-build-system)
474 (arguments
475 `(#:tests? #f
476 ;; FIXME: Chromiums RUNPATH lacks entries for some libraries.
477 #:validate-runpath? #f
478 #:modules ((guix build gnu-build-system)
479 (guix build utils)
480 (srfi srfi-26))
481 #:configure-flags
482 ;; See tools/gn/docs/cookbook.md and
483 ;; https://www.chromium.org/developers/gn-build-configuration
484 ;; for usage. Run "gn args . --list" in the Release
485 ;; directory for an exhaustive list of supported flags.
486 ;; (Note: The 'configure' phase will do that for you.)
487 (list "is_debug=false"
488 ;; Use the "official" release optimizations, as opposed to
489 ;; a developer build.
490 "is_official_build=true"
491 (string-append "max_jobs_per_link="
492 ;; Respect the default cap of 8 jobs.
493 (number->string (min 8 (parallel-job-count))))
494 "clang_use_chrome_plugins=false"
495 "chrome_pgo_phase=0"
496 "use_sysroot=false"
497 "goma_dir=\"\""
498 "enable_nacl=false"
499 "enable_nacl_nonsfi=false"
500 "use_unofficial_version_number=false"
501 "treat_warnings_as_errors=false"
502 "use_official_google_api_keys=false"
503 "fieldtrial_testing_like_official_build=true"
504 "safe_browsing_mode=0"
505 "enable_mdns=false"
506 "enable_one_click_signin=false"
507 "enable_reading_list=false"
508 "enable_remoting=false"
509 "enable_reporting=false"
510 "enable_service_discovery=false"
511 "enable_vr=false"
512 "enable_widevine=false"
513 ;; Disable type-checking for the Web UI to avoid a Java dependency.
514 "enable_js_type_check=false"
515
516 ;; Define a custom toolchain that simply looks up CC, AR and
517 ;; friends from the environment.
518 "custom_toolchain=\"//build/toolchain/linux/unbundle:default\""
519 "host_toolchain=\"//build/toolchain/linux/unbundle:default\""
520
521 ;; Prefer system libraries.
522 "use_system_freetype=true"
523 "use_system_harfbuzz=true"
524 "use_system_lcms2=true"
525 "use_system_libdrm=true"
526 "use_system_libjpeg=true"
527 "use_system_libopenjpeg2=true"
528 "use_system_libpng=true"
529 "use_system_wayland_scanner=true"
530 (string-append "system_wayland_scanner_path=\""
531 (assoc-ref %build-inputs "wayland-scanner")
532 "/bin/wayland-scanner\"")
533
534 "use_system_zlib=true"
535 "use_gnome_keyring=false" ;deprecated by libsecret
536 "use_openh264=true"
537 "use_pulseaudio=true"
538 "link_pulseaudio=true"
539 "icu_use_data_file=false"
540
541 ;; FIXME: Using system protobuf with "is_official_build" causes an
542 ;; invalid opcode and "protoc-gen-plugin: Plugin killed by signal 4".
543 ;;"perfetto_use_system_protobuf=true"
544
545 ;; VA-API acceleration is currently only supported on x86_64-linux.
546 ,@(if (string-prefix? "x86_64" (or (%current-target-system)
547 (%current-system)))
548 '("use_vaapi=true")
549 '())
550
551 ;; Do not artifically restrict formats supported by system ffmpeg.
552 "proprietary_codecs=true"
553 "ffmpeg_branding=\"Chrome\""
554
555 ;; WebRTC stuff.
556 "rtc_use_h264=true"
557 "rtc_use_pipewire=true"
558 "rtc_link_pipewire=true"
559 ;; Don't use bundled sources.
560 "rtc_build_json=true" ;FIXME: libc++ std::string ABI difference
561 "rtc_build_libevent=false"
562 "rtc_build_libvpx=false"
563 "rtc_build_opus=false"
564 "rtc_build_ssl=false"
565 "rtc_build_libsrtp=true" ;FIXME: fails to find headers
566 "rtc_build_usrsctp=true" ;TODO: package this
567 (string-append "rtc_ssl_root=\""
568 (assoc-ref %build-inputs "openssl")
569 "/include/openssl\""))
570 #:phases
571 (modify-phases %standard-phases
572 (add-after 'unpack 'patch-stuff
573 (lambda _
574 (substitute*
575 '("base/process/launch_posix.cc"
576 "base/third_party/dynamic_annotations/dynamic_annotations.c"
577 "sandbox/linux/seccomp-bpf/sandbox_bpf.cc"
578 "sandbox/linux/services/credentials.cc"
579 "sandbox/linux/services/namespace_utils.cc"
580 "sandbox/linux/services/syscall_wrappers.cc"
581 "sandbox/linux/syscall_broker/broker_host.cc")
582 (("include \"base/third_party/valgrind/") "include \"valgrind/"))
583
584 (for-each (lambda (file)
585 (substitute* file
586 ;; Fix opus include path.
587 ;; Do not substitute opus_private.h.
588 (("#include \"opus\\.h\"")
589 "#include \"opus/opus.h\"")
590 (("#include \"opus_custom\\.h\"")
591 "#include \"opus/opus_custom.h\"")
592 (("#include \"opus_defines\\.h\"")
593 "#include \"opus/opus_defines.h\"")
594 (("#include \"opus_multistream\\.h\"")
595 "#include \"opus/opus_multistream.h\"")
596 (("#include \"opus_types\\.h\"")
597 "#include \"opus/opus_types.h\"")))
598 (find-files (string-append "third_party/webrtc/modules"
599 "/audio_coding/codecs/opus")))
600
601 ;; Many files try to include ICU headers from "third_party/icu/...".
602 ;; Remove the "third_party/" prefix to use system headers instead.
603 (substitute* (find-files "chrome" "\\.cc$")
604 (("third_party/icu/source/(common|i18n)/")
605 ""))
606
607 ;; Fix faulty ICU call. Likely fixed in M89.
608 (substitute*
609 "third_party/blink/renderer/platform/wtf/text/text_codec_icu.cc"
610 (("ideographicSpaceCharacter")
611 "kIdeographicSpaceCharacter"))
612
613 ;; XXX: Should be unnecessary when use_system_lcms2=true.
614 (substitute* "third_party/pdfium/core/fxcodec/icc/iccmodule.h"
615 (("include \"third_party/lcms/include/lcms2\\.h\"")
616 "include \"lcms2.h\""))
617
618 (substitute*
619 "third_party/breakpad/breakpad/src/common/linux/libcurl_wrapper.h"
620 (("include \"third_party/curl")
621 "include \"curl"))
622
623 (substitute* '("components/viz/common/gpu/vulkan_context_provider.h"
624 "components/viz/common/resources/resource_format_utils.h"
625 "gpu/config/gpu_util.cc")
626 (("third_party/vulkan_headers/include/") ""))
627
628 (substitute* "third_party/skia/include/gpu/vk/GrVkVulkan.h"
629 (("include/third_party/vulkan/") ""))
630
631 #t))
632 (add-after 'patch-stuff 'add-absolute-references
633 (lambda* (#:key inputs #:allow-other-keys)
634 (let ((cups (assoc-ref inputs "cups"))
635 (nss (assoc-ref inputs "nss"))
636 (mesa (assoc-ref inputs "mesa"))
637 (udev (assoc-ref inputs "udev")))
638 (substitute* "printing/cups_config_helper.py"
639 (("cups_config =.*")
640 (string-append "cups_config = '" cups
641 "/bin/cups-config'\n")))
642 (substitute* "crypto/nss_util.cc"
643 (("libnssckbi\\.so")
644 (string-append nss "/lib/nss/libnssckbi.so")))
645 (substitute* "device/udev_linux/udev1_loader.cc"
646 (("libudev\\.so\\.1")
647 (string-append udev "/lib/libudev.so.1")))
648
649 (substitute*
650 '("ui/ozone/platform/x11/gl_ozone_glx.cc"
651 "ui/ozone/common/egl_util.cc"
652 "ui/gl/init/gl_initializer_linux_x11.cc"
653 "third_party/angle/src/libANGLE/renderer/gl/glx/FunctionsGLX.cpp")
654 (("libGL\\.so\\.1")
655 (string-append mesa "/lib/libGL.so.1"))
656 (("libEGL\\.so\\.1")
657 (string-append mesa "/lib/libEGL.so.1"))
658 (("libGLESv2\\.so\\.2")
659 (string-append mesa "/lib/libGLESv2.so.2")))
660 #t)))
661 (add-before 'configure 'prepare-build-environment
662 (lambda* (#:key inputs #:allow-other-keys)
663
664 ;; Define the GN toolchain.
665 (setenv "AR" "llvm-ar") (setenv "NM" "llvm-nm")
666 (setenv "CC" "clang") (setenv "CXX" "clang++")
667
668 (let ((gcc (assoc-ref inputs "gcc")))
669 ;; Remove the default compiler from CPLUS_INCLUDE_PATH to
670 ;; prevent header conflict with the bundled libcxx.
671 (setenv "CPLUS_INCLUDE_PATH"
672 (string-join
673 (delete (string-append gcc "/include/c++")
674 (string-split (getenv "CPLUS_INCLUDE_PATH")
675 #\:))
676 ":"))
677 (format #t
678 "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
679 (getenv "CPLUS_INCLUDE_PATH")))
680
681 (setenv "CXXFLAGS"
682 (string-join
683 '(;; Do not optimize away null pointer safety checks.
684 "-fno-delete-null-pointer-checks"
685 ;; Disable warnings about unknown warnings that require
686 ;; Clang plugins or newer versions.
687 "-Wno-unknown-warning-option")))
688
689 (setenv "CFLAGS" "-Wno-unknown-warning-option")
690
691 ;; TODO: pre-compile instead. Avoids a race condition.
692 (setenv "PYTHONDONTWRITEBYTECODE" "1")
693
694 ;; XXX: How portable is this.
695 (mkdir-p "third_party/node/linux/node-linux-x64")
696 (symlink (string-append (assoc-ref inputs "node") "/bin")
697 "third_party/node/linux/node-linux-x64/bin")
698
699 #t))
700 (replace 'configure
701 (lambda* (#:key configure-flags #:allow-other-keys)
702 (let ((args (string-join configure-flags " ")))
703 ;; Generate ninja build files.
704 (invoke "gn" "gen" "out/Release"
705 (string-append "--args=" args))
706
707 ;; Print the full list of supported arguments as well as
708 ;; their current status for convenience.
709 (format #t "Dumping configure flags...\n")
710 (invoke "gn" "args" "out/Release" "--list"))))
711 (add-before 'build 'increase-resource-limits
712 (lambda _
713 ;; XXX: Chromiums linking step requires a lot of simultaneous file
714 ;; accesses. Having a too low ulimit will result in bogus linker
715 ;; errors such as "foo.a: error adding symbols: malformed archive".
716
717 ;; Try increasing the soft resource limit of max open files to 2048,
718 ;; or equal to the hard limit, whichever is lower.
719 (call-with-values (lambda () (getrlimit 'nofile))
720 (lambda (soft hard)
721 (when (and soft (< soft 2048))
722 (if hard
723 (setrlimit 'nofile (min hard 2048) hard)
724 (setrlimit 'nofile 2048 #f))
725 (format #t
726 "increased maximum number of open files from ~d to ~d~%"
727 soft (if hard (min hard 2048) 2048)))))
728 #t))
729 (replace 'build
730 (lambda* (#:key (parallel-build? #t) #:allow-other-keys)
731 (invoke "ninja" "-C" "out/Release"
732 "-j" (if parallel-build?
733 (number->string (parallel-job-count))
734 "1")
735 "chrome"
736 "chromedriver")))
737 (replace 'install
738 (lambda* (#:key inputs outputs #:allow-other-keys)
739 (let* ((out (assoc-ref outputs "out"))
740 (bin (string-append out "/bin"))
741 (exe (string-append bin "/chromium"))
742 (lib (string-append out "/lib"))
743 (man (string-append out "/share/man/man1"))
744 (applications (string-append out "/share/applications"))
745 (libs '("chrome_100_percent.pak"
746 "chrome_200_percent.pak"
747 "resources.pak"
748 "v8_context_snapshot.bin"
749 ;; Chromium ships its own libGL
750 ;; implementation called ANGLE.
751 "libEGL.so" "libGLESv2.so"))
752 (locales (string-append lib "/locales"))
753 (resources (string-append lib "/resources"))
754 (preferences (assoc-ref inputs "master-preferences"))
755 (gtk+ (assoc-ref inputs "gtk+"))
756 (sh (which "sh")))
757
758 (substitute* '("chrome/app/resources/manpage.1.in"
759 "chrome/installer/linux/common/desktop.template")
760 (("@@MENUNAME@@") "Chromium")
761 (("@@PACKAGE@@") "chromium")
762 (("/usr/bin/@@USR_BIN_SYMLINK_NAME@@") exe))
763
764 (mkdir-p man)
765 (copy-file "chrome/app/resources/manpage.1.in"
766 (string-append man "/chromium.1"))
767
768 (mkdir-p applications)
769 (copy-file "chrome/installer/linux/common/desktop.template"
770 (string-append applications "/chromium.desktop"))
771
772 (mkdir-p lib)
773 (copy-file preferences (string-append lib "/master_preferences"))
774
775 (with-directory-excursion "out/Release"
776 (for-each (cut install-file <> lib) libs)
777 (copy-file "chrome" (string-append lib "/chromium"))
778
779 (copy-recursively "locales" locales)
780 (copy-recursively "resources" resources)
781
782 (mkdir-p bin)
783 (symlink "../lib/chromium" exe)
784 (install-file "chromedriver" bin)
785
786 (for-each (lambda (so)
787 (install-file so (string-append lib "/swiftshader")))
788 (find-files "swiftshader" "\\.so$"))
789
790 (wrap-program exe
791 ;; Avoid file manager crash. See <https://bugs.gnu.org/26593>.
792 `("XDG_DATA_DIRS" ":" prefix (,(string-append gtk+ "/share")))))
793
794 (with-directory-excursion "chrome/app/theme/chromium"
795 (for-each
796 (lambda (size)
797 (let ((icons (string-append out "/share/icons/hicolor/"
798 size "x" size "/apps")))
799 (mkdir-p icons)
800 (copy-file (string-append "product_logo_" size ".png")
801 (string-append icons "/chromium.png"))))
802 '("24" "48" "64" "128" "256")))
803 #t))))))
804 (native-inputs
805 `(("bison" ,bison)
806 ("clang" ,clang-11)
807 ("gn" ,gn)
808 ("gperf" ,gperf)
809 ("ld-wrapper" ,(make-lld-wrapper lld))
810 ("ninja" ,ninja)
811 ("node" ,node)
812 ("pkg-config" ,pkg-config)
813 ("which" ,which)
814
815 ;; This file contains defaults for new user profiles.
816 ("master-preferences" ,(local-file "aux-files/chromium/master-preferences.json"))
817
818 ("python-beautifulsoup4" ,python2-beautifulsoup4)
819 ("python-html5lib" ,python2-html5lib)
820 ("python" ,python-2)
821 ("wayland-scanner" ,wayland)))
822 (inputs
823 `(("alsa-lib" ,alsa-lib)
824 ("atk" ,atk)
825 ("cups" ,cups)
826 ("curl" ,curl)
827 ("dbus" ,dbus)
828 ("expat" ,expat)
829 ("flac" ,flac)
830 ("ffmpeg" ,ffmpeg)
831 ("fontconfig" ,fontconfig)
832 ("freetype" ,freetype)
833 ("gdk-pixbuf" ,gdk-pixbuf)
834 ("glib" ,glib)
835 ("gtk+" ,gtk+)
836 ("harfbuzz" ,harfbuzz)
837 ("icu4c" ,icu4c-68)
838 ("lcms" ,lcms)
839 ("libevent" ,libevent)
840 ("libffi" ,libffi)
841 ("libjpeg-turbo" ,libjpeg-turbo)
842 ("libpng" ,libpng)
843 ("libva" ,libva)
844 ("libvpx" ,libvpx/chromium)
845 ("libwebp" ,libwebp)
846 ("libx11" ,libx11)
847 ("libxcb" ,libxcb)
848 ("libxcomposite" ,libxcomposite)
849 ("libxcursor" ,libxcursor)
850 ("libxdamage" ,libxdamage)
851 ("libxext" ,libxext)
852 ("libxfixes" ,libxfixes)
853 ("libxi" ,libxi)
854 ("libxml2" ,libxml2)
855 ("libxrandr" ,libxrandr)
856 ("libxrender" ,libxrender)
857 ("libxscrnsaver" ,libxscrnsaver)
858 ("libxslt" ,libxslt)
859 ("libxtst" ,libxtst)
860 ("mesa" ,mesa)
861 ("minizip" ,minizip)
862 ("mit-krb5" ,mit-krb5)
863 ("nss" ,nss)
864 ("openh264" ,openh264)
865 ("openjpeg" ,openjpeg) ;PDFium only
866 ("openssl" ,openssl)
867 ("opus" ,opus+custom)
868 ("pango" ,pango)
869 ("pciutils" ,pciutils)
870 ("pipewire" ,pipewire)
871 ("pulseaudio" ,pulseaudio)
872 ("snappy" ,snappy)
873 ("speech-dispatcher" ,speech-dispatcher)
874 ("udev" ,eudev)
875 ("valgrind" ,valgrind)
876 ("vulkan-headers" ,vulkan-headers)
877 ("wayland" ,wayland)))
878 (native-search-paths
879 (list (search-path-specification
880 (variable "CHROMIUM_EXTENSION_DIRECTORY")
881 (separator #f) ;single entry
882 (files '("share/chromium/extensions")))))
883
884 ;; Building Chromium takes ... a very long time. On a single core, a busy
885 ;; mid-end x86 system may need more than 24 hours to complete the build.
886 (properties '((timeout . 144000) ;40 hours
887 ;; The linking step may take more than an hour on some hardware.
888 (max-silent-time . 7200)
889 (cpe-name . "chrome")))
890
891 (home-page "https://github.com/Eloston/ungoogled-chromium")
892 (description
893 "Ungoogled-Chromium is the Chromium web browser, with some functionality
894 disabled in order to protect the users privacy.")
895 ;; Chromium is developed as BSD-3, but bundles a large number of third-party
896 ;; components with other licenses. For full information, see chrome://credits.
897 (license (list license:bsd-3
898 license:bsd-2
899 license:expat
900 license:asl2.0
901 license:mpl1.1
902 license:mpl2.0
903 license:public-domain
904 license:isc
905 (license:non-copyleft "chrome://credits"
906 "See chrome://credits for more information.")
907 license:lgpl2.1+))))
908
909 (define-public ungoogled-chromium/wayland
910 (package
911 (inherit ungoogled-chromium)
912 (name "ungoogled-chromium-wayland")
913 (native-inputs '())
914 (inputs
915 `(("bash" ,bash-minimal)
916 ("glibc-locales" ,glibc-utf8-locales)
917 ("ungoogled-chromium" ,ungoogled-chromium)))
918 (build-system trivial-build-system)
919 (arguments
920 '(#:modules ((guix build utils))
921 #:builder
922 (begin
923 (use-modules (guix build utils))
924 (let* ((bash (assoc-ref %build-inputs "bash"))
925 (chromium (assoc-ref %build-inputs "ungoogled-chromium"))
926 (locales (assoc-ref %build-inputs "glibc-locales"))
927 (out (assoc-ref %outputs "out"))
928 (exe (string-append out "/bin/chromium")))
929
930 ;; Use a Unicode locale so we can substitute the file below.
931 (setenv "GUIX_LOCPATH" (string-append locales "/lib/locale"))
932 (setlocale LC_ALL "en_US.utf8")
933
934 (mkdir-p (dirname exe))
935 (symlink (string-append chromium "/bin/chromedriver")
936 (string-append out "/bin/chromedriver"))
937
938 (call-with-output-file exe
939 (lambda (port)
940 (format port "#!~a
941 exec ~a --enable-features=UseOzonePlatform --ozone-platform=wayland $@"
942 (string-append bash "/bin/bash")
943 (string-append chromium "/bin/chromium"))))
944 (chmod exe #o555)
945
946 ;; Provide the manual and .desktop file.
947 (copy-recursively (string-append chromium "/share")
948 (string-append out "/share"))
949 (substitute* (string-append
950 out "/share/applications/chromium.desktop")
951 ((chromium) out))
952 #t))))))