1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2019, 2020 Marius Bakke <mbakke@fastmail.com>
3 ;;; Copyright © 2019 Alex Griffin <a@ajgrf.com>
5 ;;; This file is part of GNU Guix.
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.
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.
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/>.
20 (define-module (gnu packages chromium)
21 #:use-module ((guix licenses) #:prefix license:)
22 #:use-module (guix packages)
23 #:use-module (guix gexp)
24 #:use-module (guix store)
25 #:use-module (guix monads)
26 #:use-module (guix download)
27 #:use-module (guix git-download)
28 #:use-module (guix utils)
29 #:use-module (guix build-system gnu)
30 #:use-module (gnu packages)
31 #:use-module (gnu packages assembly)
32 #:use-module (gnu packages base)
33 #:use-module (gnu packages bison)
34 #:use-module (gnu packages build-tools)
35 #:use-module (gnu packages compression)
36 #:use-module (gnu packages cups)
37 #:use-module (gnu packages curl)
38 #:use-module (gnu packages fontutils)
39 #:use-module (gnu packages freedesktop)
40 #:use-module (gnu packages ghostscript)
41 #:use-module (gnu packages gl)
42 #:use-module (gnu packages glib)
43 #:use-module (gnu packages gnome)
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)
51 #:use-module (gnu packages llvm)
52 #:use-module (gnu packages kerberos)
53 #:use-module (gnu packages ninja)
54 #:use-module (gnu packages node)
55 #:use-module (gnu packages nss)
56 #:use-module (gnu packages pciutils)
57 #:use-module (gnu packages pkg-config)
58 #:use-module (gnu packages pulseaudio)
59 #:use-module (gnu packages python)
60 #:use-module (gnu packages python-web)
61 #:use-module (gnu packages python-xyz)
62 #:use-module (gnu packages regex)
63 #:use-module (gnu packages serialization)
64 #:use-module (gnu packages speech)
65 #:use-module (gnu packages tls)
66 #:use-module (gnu packages valgrind)
67 #:use-module (gnu packages vulkan)
68 #:use-module (gnu packages video)
69 #:use-module (gnu packages xiph)
70 #:use-module (gnu packages xml)
71 #:use-module (gnu packages xdisorg)
72 #:use-module (gnu packages xorg)
73 #:use-module (ice-9 match)
74 #:use-module (srfi srfi-1))
76 (define %preserved-third-party-files
77 '("base/third_party/cityhash" ;Expat
78 "base/third_party/double_conversion" ;BSD-3
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
88 "net/third_party/mozilla_security_manager" ;MPL-1.1/GPL2+/LGPL2.1+
89 "net/third_party/nss" ;MPL-2.0
90 "net/third_party/quiche" ;BSD-3
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
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
106 "third_party/axe-core" ;MPL2.0
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
117 ;; XXX: This is a minified version of <https://d3js.org/>.
118 "third_party/catapult/tracing/third_party/d3" ;BSD-3
119 "third_party/catapult/tracing/third_party/gl-matrix" ;Expat
120 ;; XXX: Minified version of <https://github.com/Stuk/jszip>.
121 "third_party/catapult/tracing/third_party/jszip" ;Expat or GPL3
122 "third_party/catapult/tracing/third_party/mannwhitneyu" ;Expat
123 "third_party/catapult/tracing/third_party/oboe" ;BSD-2
124 ;; XXX: Minified version of <https://github.com/nodeca/pako>.
125 "third_party/catapult/tracing/third_party/pako" ;Expat
126 "third_party/ced" ;BSD-3
127 "third_party/cld_3" ;ASL2.0
128 "third_party/closure_compiler" ;ASL2.0
129 "third_party/crashpad" ;ASL2.0
130 "third_party/crashpad/crashpad/third_party/lss" ;ASL2.0
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
134 "third_party/dav1d" ;BSD-2
135 "third_party/dawn" ;ASL2.0
136 "third_party/depot_tools/owners.py" ;BSD-3
137 "third_party/devtools-frontend" ;BSD-3
138 "third_party/devtools-frontend/src/front_end/third_party/fabricjs" ;Expat
139 "third_party/devtools-frontend/src/front_end/third_party/wasmparser" ;ASL2.0
140 "third_party/devtools-frontend/src/third_party/axe-core" ;MPL2.0
141 "third_party/devtools-frontend/src/third_party/pyjson5" ;ASL2.0
142 "third_party/devtools-frontend/src/third_party/typescript" ;ASL2.0
143 "third_party/dom_distiller_js" ;BSD-3
144 "third_party/emoji-segmenter" ;ASL2.0
145 "third_party/flatbuffers" ;ASL2.0
146 "third_party/glslang" ;BSD-3, Expat, ASL2.0
147 "third_party/google_input_tools" ;ASL2.0
148 "third_party/google_input_tools/third_party/closure_library" ;ASL2.0
149 "third_party/google_input_tools/third_party/closure_library/third_party/closure" ;Expat
150 "third_party/googletest" ;BSD-3
151 "third_party/hunspell" ;MPL1.1/GPL2+/LGPL2.1+
152 "third_party/iccjpeg" ;IJG
153 "third_party/inspector_protocol" ;BSD-3
154 "third_party/jinja2" ;BSD-3
155 "third_party/jstemplate" ;ASL2.0
156 "third_party/khronos" ;Expat, SGI
157 "third_party/leveldatabase" ;BSD-3
158 "third_party/libXNVCtrl" ;Expat
159 "third_party/libaddressinput" ;ASL2.0
160 "third_party/libaom" ;BSD-2 or "Alliance for Open Media Patent License 1.0"
161 "third_party/libaom/source/libaom/third_party/vector" ;Expat
162 "third_party/libaom/source/libaom/third_party/x86inc" ;ISC
163 "third_party/libgifcodec" ;MPL1.1/GPL2+/LGPL2.1+, BSD-3, BSD-2
164 "third_party/libjingle_xmpp" ;BSD-3
165 "third_party/libphonenumber" ;ASL2.0
166 "third_party/libsecret" ;LGPL2.1+
167 "third_party/libsrtp" ;BSD-3
168 "third_party/libsync" ;ASL2.0
169 "third_party/libudev" ;LGPL2.1+
170 "third_party/libwebm" ;BSD-3
171 "third_party/libxml/chromium" ;BSD-3
172 "third_party/libyuv" ;BSD-3
173 "third_party/lss" ;BSD-3
174 "third_party/markupsafe" ;BSD-3
175 "third_party/mesa_headers" ;Expat, SGI
176 "third_party/metrics_proto" ;BSD-3
177 "third_party/modp_b64" ;BSD-3
178 "third_party/nasm" ;BSD-2
179 "third_party/node" ;Expat
180 "third_party/node/node_modules/polymer-bundler/lib/third_party/UglifyJS2" ;BSD-2
181 "third_party/one_euro_filter" ;BSD-3
182 "third_party/openscreen" ;BSD-3
183 "third_party/openscreen/src/third_party/tinycbor" ;Expat
184 "third_party/ots" ;BSD-3
185 "third_party/pdfium" ;BSD-3
186 "third_party/pdfium/third_party/agg23" ;Expat
187 "third_party/pdfium/third_party/base" ;BSD-3
188 "third_party/pdfium/third_party/bigint" ;Public domain, BSD-3
189 "third_party/pdfium/third_party/skia_shared" ;BSD-3
190 "third_party/pdfium/third_party/freetype/include/pstables.h" ;FreeType
191 "third_party/perfetto" ;ASL2.0
192 "third_party/pffft" ;the "FFTPACK" license, similar to BSD-3
193 "third_party/ply" ;BSD-3
194 "third_party/polymer" ;BSD-3
195 "third_party/private-join-and-compute" ;ASL2.0
196 "third_party/protobuf" ;BSD-3
197 "third_party/protobuf/third_party/six" ;Expat
198 "third_party/pyjson5" ;ASL2.0
199 "third_party/qcms" ;Expat
200 "third_party/rnnoise" ;BSD-3
201 "third_party/s2cellid" ;ASL2.0
202 "third_party/skia" ;BSD-3
203 "third_party/skia/include/third_party/skcms" ;BSD-3
204 "third_party/skia/third_party/skcms" ;BSD-3
205 "third_party/skia/third_party/vulkanmemoryallocator" ;BSD-3, Expat
206 "third_party/smhasher" ;Expat, public domain
207 "third_party/speech-dispatcher" ;GPL2+
208 "third_party/spirv-headers" ;ASL2.0
209 "third_party/SPIRV-Tools" ;ASL2.0
210 "third_party/sqlite" ;Public domain
211 "third_party/usb_ids" ;BSD-3
212 "third_party/usrsctp" ;BSD-2
213 "third_party/wayland/wayland_scanner_wrapper.py" ;BSD-3
214 "third_party/wayland-protocols" ;Expat
215 "third_party/web-animations-js" ;ASL2.0
216 "third_party/webdriver" ;ASL2.0
217 "third_party/webrtc" ;BSD-3
218 "third_party/webrtc/common_audio/third_party/fft4g" ;Non-copyleft
219 "third_party/webrtc/common_audio/third_party/spl_sqrt_floor" ;Public domain
220 "third_party/webrtc/modules/third_party/fft" ;Non-copyleft
221 "third_party/webrtc/modules/third_party/g711" ;Public domain
222 "third_party/webrtc/modules/third_party/g722" ;Public domain
223 "third_party/webrtc/rtc_base/third_party/base64" ;Non-copyleft
224 "third_party/webrtc/rtc_base/third_party/sigslot" ;Public domain
225 "third_party/widevine/cdm/widevine_cdm_version.h" ;BSD-3
226 "third_party/widevine/cdm/widevine_cdm_common.h" ;BSD-3
227 "third_party/woff2" ;ASL2.0
228 "third_party/xdg-utils" ;Expat
229 "third_party/yasm/run_yasm.py" ;BSD-2 or BSD-3
230 "third_party/zlib/google" ;BSD-3
231 "url/third_party/mozilla" ;BSD-3, MPL1.1/GPL2+/LGPL2.1+
232 "v8/src/third_party/siphash" ;Public domain
233 "v8/src/third_party/utf8-decoder" ;Expat
234 "v8/src/third_party/valgrind" ;BSD-4
235 "v8/third_party/inspector_protocol" ;BSD-3
236 "v8/third_party/v8/builtins")) ;PSFL
238 (define* (computed-origin-method gexp-promise hash-algo hash
239 #:optional (name "source")
240 #:key (system (%current-system))
241 (guile (default-guile)))
242 "Return a derivation that executes the G-expression that results
243 from forcing GEXP-PROMISE."
244 (mlet %store-monad ((guile (package->derivation guile system)))
245 (gexp->derivation (or name "computed-origin")
247 #:graft? #f ;nothing to graft
249 #:guile-for-build guile)))
251 (define %chromium-version "81.0.4044.122")
252 (define %ungoogled-revision "31d6e60c96481599b42072b4489e4468280198e3")
253 (define %debian-revision "debian/81.0.4044.92-1")
254 (define package-revision "0")
255 (define %package-version (string-append %chromium-version "-"
257 (string-take %ungoogled-revision 7)))
259 (define %chromium-origin
262 (uri (string-append "https://commondatastorage.googleapis.com"
263 "/chromium-browser-official/chromium-"
264 %chromium-version ".tar.xz"))
267 "0ahqh3vmzbpai4xwn7qybgw9phc8ssjdvfc7384mxqk9swqgv7qg"))))
269 (define %ungoogled-origin
272 (uri (git-reference (url "https://github.com/Eloston/ungoogled-chromium")
273 (commit %ungoogled-revision)))
274 (file-name (git-file-name "ungoogled-chromium"
275 (string-take %ungoogled-revision 7)))
278 "1pj2vmzb2fagvypjsjn2kqf5n5k8vnhbisyb0snr6wqvpv09x0vv"))))
280 (define %debian-origin
284 (url "https://salsa.debian.org/chromium-team/chromium.git")
285 (commit %debian-revision)))
286 (file-name (git-file-name "debian-chromium-packaging"
287 (match (string-split %debian-revision #\/)
288 ((_ revision) revision)
289 (_ (string-take %debian-revision 7)))))
292 "0srgbcqga3l75bfkv3bnmjk416189nazsximvzdx2k5n8v5k4p3m"))))
294 ;; This is a "computed" origin that does the following:
295 ;; *) Runs the Ungoogled scripts on a pristine Chromium tarball.
296 ;; *) Applies Debians Chromium patches, for their unbundling and GCC work.
297 ;; *) Prunes all third_party directories that are not explicitly preserved.
298 ;; *) Adjusts "GN" build files such that system libraries are preferred.
299 (define ungoogled-chromium-source
300 (let ((chromium-source %chromium-origin)
301 (ungoogled-source %ungoogled-origin)
302 (debian-source %debian-origin))
304 (method computed-origin-method)
305 (file-name (string-append "ungoogled-chromium-" %package-version ".tar.xz"))
309 (with-imported-modules '((guix build utils))
311 (use-modules (guix build utils)
315 (let ((chromium-dir (string-append "chromium-" #$%chromium-version))
316 (preserved-files (list #$@%preserved-third-party-files)))
318 (set-path-environment-variable
320 (list #+(canonical-package patch)
321 #+(canonical-package xz)
322 #+(canonical-package tar)
325 (copy-recursively #+ungoogled-source "/tmp/ungoogled")
327 (with-directory-excursion "/tmp/ungoogled"
329 (format #t "Unpacking chromium tarball...~%")
331 (invoke "tar" "xf" #+chromium-source)
333 ;; Ungoogled-Chromium contains a forked subset of the Debian
334 ;; patches. Disable those, as we apply newer versions later.
335 (substitute* "patches/series"
339 (format #t "Ungooglifying...~%")
341 (invoke "python" "utils/prune_binaries.py" chromium-dir
343 (invoke "python" "utils/patches.py" "apply"
344 chromium-dir "patches")
345 (invoke "python" "utils/domain_substitution.py" "apply" "-r"
346 "domain_regex.list" "-f" "domain_substitution.list"
347 "-c" "/tmp/domainscache.tar.gz" chromium-dir)
349 (with-directory-excursion chromium-dir
351 (format #t "Applying Debian patches...~%")
353 (let* ((debian #+debian-source)
354 (patches (string-append debian "/debian/patches"))
355 (series (string-append patches "/series")))
356 (with-input-from-file series
358 (let loop ((line (read-line)))
359 (unless (eof-object? line)
360 (when (and (> (string-length line) 1)
361 (not (string-prefix? "#" line))
362 ;; Skip the Debian-specific ones.
363 (not (string-prefix? "debianization/" line))
364 (not (string-prefix? "buster/" line))
365 (not (any (cute string-suffix? <> line)
366 ;; These conflict with Ungoogled.
367 '("widevine-buildflag.patch"
369 "third-party-cookies.patch"
371 ;; Disable workarounds for the
372 ;; Chromium "-lite" tarball. We
373 ;; use the "full" version and don't
374 ;; need these patches.
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.
385 "inspector.patch"))))
386 (invoke "patch" "--force" "-p1" "--input"
387 (string-append patches "/" line)
388 "--no-backup-if-mismatch"))
389 (loop (read-line)))))))
391 (format #t "Pruning third party files...~%")
393 (apply invoke (string-append #+python-2 "/bin/python")
394 "build/linux/unbundle/remove_bundled_libraries.py"
395 "--do-remove" preserved-files)
397 (format #t "Replacing GN files...~%")
399 (invoke "python" "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"
406 (format #t (string-append "Packing new ungoogled tarball ...~%"))
408 (invoke "tar" "cvfa" #$output
409 ;; Avoid non-determinism in the archive.
419 (package/inherit opus
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"
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"))))
436 (name "ld-wrapper-next")
438 `(("wrapper" ,(search-path %load-path
439 "gnu/packages/ld-wrapper-next.in"))
440 ,@(alist-delete "wrapper" (package-inputs orig)))))))
442 (define-public ungoogled-chromium
444 (name "ungoogled-chromium")
445 (version %package-version)
446 (synopsis "Graphical web browser")
447 (source ungoogled-chromium-source)
448 (build-system gnu-build-system)
451 ;; FIXME: Chromiums RUNPATH lacks entries for some libraries.
452 #:validate-runpath? #f
453 #:modules ((guix build gnu-build-system)
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"
467 "clang_use_chrome_plugins=false"
468 "linux_use_bundled_binutils=false"
469 "use_custom_libcxx=false"
471 "enable_precompiled_headers=false"
474 "enable_nacl_nonsfi=false"
475 "use_allocator=\"none\""
476 "use_unofficial_version_number=false"
477 "treat_warnings_as_errors=false"
478 "use_official_google_api_keys=false"
479 "fieldtrial_testing_like_official_build=true"
480 "safe_browsing_mode=0"
482 "enable_one_click_signin=false"
483 "enable_reading_list=false"
484 "enable_remoting=false"
485 "enable_reporting=false"
486 "enable_service_discovery=false"
487 "enable_swiftshader=false"
489 "enable_widevine=false"
490 ;; Disable type-checking for the Web UI to avoid a Java dependency.
491 "closure_compile=false"
493 ;; Define a custom toolchain that simply looks up CC, AR and
494 ;; friends from the environment.
495 "custom_toolchain=\"//build/toolchain/linux/unbundle:default\""
496 "host_toolchain=\"//build/toolchain/linux/unbundle:default\""
498 ;; Prefer system libraries.
499 "use_system_freetype=true"
500 "use_system_harfbuzz=true"
501 "use_system_lcms2=true"
502 "use_system_libdrm=true"
503 "use_system_libjpeg=true"
504 "use_system_libopenjpeg2=true"
505 "use_system_libpng=true"
506 "use_system_zlib=true"
507 "use_gnome_keyring=false" ;deprecated by libsecret
509 "use_pulseaudio=true"
510 "link_pulseaudio=true"
512 ;; VA-API acceleration is currently only supported on x86_64-linux.
513 ,@(if (string-prefix? "x86_64" (or (%current-target-system)
518 ;; Do not artifically restrict formats supported by system ffmpeg.
519 "proprietary_codecs=true"
520 "ffmpeg_branding=\"Chrome\""
524 ;; Don't use bundled sources.
525 "rtc_build_json=false"
526 "rtc_build_libevent=false"
527 "rtc_build_libvpx=false"
528 "rtc_build_opus=false"
529 "rtc_build_ssl=false"
530 "rtc_build_libsrtp=true" ;FIXME: fails to find headers
531 "rtc_build_usrsctp=true" ;TODO: package this
532 (string-append "rtc_jsoncpp_root=\""
533 (assoc-ref %build-inputs "jsoncpp")
534 "/include/jsoncpp/json\"")
535 (string-append "rtc_ssl_root=\""
536 (assoc-ref %build-inputs "openssl")
537 "/include/openssl\""))
539 (modify-phases %standard-phases
540 (add-after 'unpack 'patch-stuff
543 '("base/process/launch_posix.cc"
544 "base/third_party/dynamic_annotations/dynamic_annotations.c"
545 "sandbox/linux/seccomp-bpf/sandbox_bpf.cc"
546 "sandbox/linux/services/credentials.cc"
547 "sandbox/linux/services/namespace_utils.cc"
548 "sandbox/linux/services/syscall_wrappers.cc"
549 "sandbox/linux/syscall_broker/broker_host.cc")
550 (("include \"base/third_party/valgrind/") "include \"valgrind/"))
552 (for-each (lambda (file)
554 ;; Fix opus include path.
555 ;; Do not substitute opus_private.h.
556 (("#include \"opus\\.h\"")
557 "#include \"opus/opus.h\"")
558 (("#include \"opus_custom\\.h\"")
559 "#include \"opus/opus_custom.h\"")
560 (("#include \"opus_defines\\.h\"")
561 "#include \"opus/opus_defines.h\"")
562 (("#include \"opus_multistream\\.h\"")
563 "#include \"opus/opus_multistream.h\"")
564 (("#include \"opus_types\\.h\"")
565 "#include \"opus/opus_types.h\"")))
566 (find-files (string-append "third_party/webrtc/modules"
567 "/audio_coding/codecs/opus")))
569 (substitute* "chrome/common/chrome_paths.cc"
570 (("/usr/share/chromium/extensions")
571 ;; TODO: Add ~/.guix-profile.
572 "/run/current-system/profile/share/chromium/extensions"))
574 ;; Many files try to include ICU headers from "third_party/icu/...".
575 ;; Remove the "third_party/" prefix to use system headers instead.
576 (substitute* (find-files "chrome" "\\.cc$")
577 (("third_party/icu/source/(common|i18n)/")
580 ;; XXX: Should be unnecessary when use_system_lcms2=true.
581 (substitute* "third_party/pdfium/core/fxcodec/icc/iccmodule.h"
582 (("include \"third_party/lcms/include/lcms2\\.h\"")
583 "include \"lcms2.h\""))
586 "third_party/breakpad/breakpad/src/common/linux/libcurl_wrapper.h"
587 (("include \"third_party/curl") "include \"curl"))
589 (substitute* "third_party/webrtc/rtc_base/strings/json.h"
590 (("#include \"third_party/jsoncpp/") "#include \"json/"))
592 (substitute* "gpu/config/gpu_util.cc"
593 (("third_party/vulkan/include/")
596 (substitute* '("components/viz/common/gpu/vulkan_context_provider.h"
597 "components/viz/common/resources/resource_format_utils.h")
598 (("third_party/vulkan/include/") ""))
600 (substitute* "third_party/skia/include/gpu/vk/GrVkVulkan.h"
601 (("include/third_party/vulkan/") ""))
603 ;; Building chromedriver embeds some files using the ZIP
604 ;; format which doesn't support timestamps before
605 ;; 1980. Therefore, advance the timestamps of the files
606 ;; which are included so that building chromedriver
608 (let ((circa-1980 (* 10 366 24 60 60)))
609 (for-each (lambda (file)
610 (utime file circa-1980 circa-1980))
611 '("chrome/test/chromedriver/extension/background.js"
612 "chrome/test/chromedriver/extension/manifest.json")))
615 (add-after 'patch-stuff 'add-absolute-references
616 (lambda* (#:key inputs #:allow-other-keys)
617 (let ((cups (assoc-ref inputs "cups"))
618 (nss (assoc-ref inputs "nss"))
619 (mesa (assoc-ref inputs "mesa"))
620 (udev (assoc-ref inputs "udev")))
621 (substitute* "printing/cups_config_helper.py"
623 (string-append "cups_config = '" cups
624 "/bin/cups-config'\n")))
625 (substitute* "crypto/nss_util.cc"
627 (string-append nss "/lib/nss/libnssckbi.so")))
628 (substitute* "device/udev_linux/udev1_loader.cc"
629 (("libudev\\.so\\.1")
630 (string-append udev "/lib/libudev.so.1")))
632 '("ui/ozone/platform/x11/gl_ozone_glx.cc"
633 "ui/ozone/common/egl_util.cc"
634 "ui/gl/init/gl_initializer_x11.cc"
635 "third_party/angle/src/libANGLE/renderer/gl/glx/FunctionsGLX.cpp")
637 (string-append mesa "/lib/libGL.so.1"))
639 (string-append mesa "/lib/libEGL.so.1"))
640 (("libGLESv2\\.so\\.2")
641 (string-append mesa "/lib/libGLESv2.so.2")))
643 (add-before 'configure 'prepare-build-environment
644 (lambda* (#:key inputs #:allow-other-keys)
646 ;; Make sure the right build tools are used.
647 (setenv "AR" "ar") (setenv "NM" "nm")
648 (setenv "CC" "clang") (setenv "CXX" "clang++")
652 '(;; Do not optimize away null pointer safety checks.
653 "-fno-delete-null-pointer-checks"
654 ;; Disable warnings about unknown warnings that require
655 ;; Clang plugins or newer versions.
656 "-Wno-unknown-warning-option")))
658 ;; TODO: pre-compile instead. Avoids a race condition.
659 (setenv "PYTHONDONTWRITEBYTECODE" "1")
662 ;; From Debians 'system/node.patch'.
663 "third_party/devtools-frontend/src/scripts/devtools_paths.py"
664 (("/usr/bin/nodejs") (which "node")))
666 ;; XXX: How portable is this.
667 (mkdir-p "third_party/node/linux/node-linux-x64")
668 (symlink (string-append (assoc-ref inputs "node") "/bin")
669 "third_party/node/linux/node-linux-x64/bin")
673 (lambda* (#:key configure-flags #:allow-other-keys)
674 (let ((args (string-join configure-flags " ")))
675 ;; Generate ninja build files.
676 (invoke "gn" "gen" "out/Release"
677 (string-append "--args=" args))
679 ;; Print the full list of supported arguments as well as
680 ;; their current status for convenience.
681 (format #t "Dumping configure flags...\n")
682 (invoke "gn" "args" "out/Release" "--list"))))
683 (add-before 'build 'increase-resource-limits
685 ;; XXX: Chromiums linking step requires a lot of simultaneous file
686 ;; accesses. Having a too low ulimit will result in bogus linker
687 ;; errors such as "foo.a: error adding symbols: malformed archive".
689 ;; Try increasing the soft resource limit of max open files to 2048,
690 ;; or equal to the hard limit, whichever is lower.
691 (call-with-values (lambda () (getrlimit 'nofile))
693 (when (and soft (< soft 2048))
695 (setrlimit 'nofile (min hard 2048) hard)
696 (setrlimit 'nofile 2048 #f))
698 "increased maximum number of open files from ~d to ~d~%"
699 soft (if hard (min hard 2048) 2048)))))
702 (lambda* (#:key (parallel-build? #t) #:allow-other-keys)
703 (invoke "ninja" "-C" "out/Release"
704 "-j" (if parallel-build?
705 (number->string (parallel-job-count))
710 (lambda* (#:key inputs outputs #:allow-other-keys)
711 (let* ((out (assoc-ref outputs "out"))
712 (bin (string-append out "/bin"))
713 (exe (string-append bin "/chromium"))
714 (lib (string-append out "/lib"))
715 (man (string-append out "/share/man/man1"))
716 (applications (string-append out "/share/applications"))
717 (install-regexp (make-regexp "\\.(bin|pak)$"))
718 (locales (string-append lib "/locales"))
719 (resources (string-append lib "/resources"))
720 (preferences (assoc-ref inputs "master-preferences"))
721 (gtk+ (assoc-ref inputs "gtk+"))
724 (substitute* '("chrome/app/resources/manpage.1.in"
725 "chrome/installer/linux/common/desktop.template")
726 (("@@MENUNAME@@") "Chromium")
727 (("@@PACKAGE@@") "chromium")
728 (("/usr/bin/@@USR_BIN_SYMLINK_NAME@@") exe))
731 (copy-file "chrome/app/resources/manpage.1.in"
732 (string-append man "/chromium.1"))
734 (mkdir-p applications)
735 (copy-file "chrome/installer/linux/common/desktop.template"
736 (string-append applications "/chromium.desktop"))
739 (copy-file preferences (string-append lib "/master_preferences"))
741 (with-directory-excursion "out/Release"
742 (for-each (lambda (file)
743 (install-file file lib))
744 (scandir "." (cut regexp-exec install-regexp <>)))
745 (copy-file "chrome" (string-append lib "/chromium"))
747 (copy-recursively "locales" locales)
748 (copy-recursively "resources" resources)
751 (symlink "../lib/chromium" exe)
752 (install-file "chromedriver" bin)
755 ;; Avoid file manager crash. See <https://bugs.gnu.org/26593>.
756 `("XDG_DATA_DIRS" ":" prefix (,(string-append gtk+ "/share")))))
758 (with-directory-excursion "chrome/app/theme/chromium"
761 (let ((icons (string-append out "/share/icons/hicolor/"
762 size "x" size "/apps")))
764 (copy-file (string-append "product_logo_" size ".png")
765 (string-append icons "/chromium.png"))))
766 '("24" "48" "64" "128" "256")))
773 ("ld-wrapper" ,ld-wrapper-next)
776 ("pkg-config" ,pkg-config)
780 ;; This file contains defaults for new user profiles.
781 ("master-preferences" ,(local-file "aux-files/chromium/master-preferences.json"))
783 ("python-beautifulsoup4" ,python2-beautifulsoup4)
784 ("python-html5lib" ,python2-html5lib)
785 ("python" ,python-2)))
787 `(("alsa-lib" ,alsa-lib)
792 ("dbus-glib" ,dbus-glib)
796 ("fontconfig" ,fontconfig)
797 ("freetype" ,freetype)
798 ("gdk-pixbuf" ,gdk-pixbuf)
801 ("harfbuzz" ,harfbuzz)
802 ("icu4c" ,icu4c-66.1)
805 ("libevent" ,libevent)
807 ("libjpeg-turbo" ,libjpeg-turbo)
814 ("libxcomposite" ,libxcomposite)
815 ("libxcursor" ,libxcursor)
816 ("libxdamage" ,libxdamage)
818 ("libxfixes" ,libxfixes)
821 ("libxrandr" ,libxrandr)
822 ("libxrender" ,libxrender)
823 ("libxscrnsaver" ,libxscrnsaver)
828 ("mit-krb5" ,mit-krb5)
830 ("openh264" ,openh264)
831 ("openjpeg" ,openjpeg) ;PDFium only
833 ("opus" ,opus+custom)
835 ("pciutils" ,pciutils)
836 ("pulseaudio" ,pulseaudio)
839 ("speech-dispatcher" ,speech-dispatcher)
841 ("valgrind" ,valgrind)
842 ("vulkan-headers" ,vulkan-headers)))
844 ;; Building Chromium takes ... a very long time. On a single core, a busy
845 ;; mid-end x86 system may need more than 24 hours to complete the build.
846 (properties '((timeout . 144000) ;40 hours
847 ;; The linking step may take more than an hour on some hardware.
848 (max-silent-time . 7200)))
850 (home-page "https://github.com/Eloston/ungoogled-chromium")
852 "Ungoogled-Chromium is the Chromium web browser, with some functionality
853 disabled in order to protect the users privacy.")
854 ;; Chromium is developed as BSD-3, but bundles a large number of third-party
855 ;; components with other licenses. For full information, see chrome://credits.
856 (license (list license:bsd-3
862 license:public-domain
864 (license:non-copyleft "chrome://credits"
865 "See chrome://credits for more information.")
868 (define-public ungoogled-chromium/wayland
869 (package/inherit ungoogled-chromium
870 (name "ungoogled-chromium-wayland")
872 `(("wayland" ,wayland)
873 ("wayland-protocols" ,wayland-protocols)
874 ,@(package-inputs ungoogled-chromium)))
876 (substitute-keyword-arguments (package-arguments ungoogled-chromium)
878 `(modify-phases ,phases
879 (add-after 'unpack 'add-ozone-patch
881 ;; Add missing include statement required when using libstdc++,
882 ;; Clang and Ozone. Fixed in M81.
883 (substitute* "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.cc"
884 (("#include \"base/logging\\.h" all)
885 (string-append "#include <algorithm>\n" all)))
887 ((#:configure-flags flags)
888 `(append (list "use_ozone=true"
889 "ozone_platform_wayland=true"
890 "ozone_auto_platforms=false"
891 "ozone_platform=\"wayland\""
893 "use_system_minigbm=true"
894 "use_system_libwayland=true"
895 (string-append "system_wayland_scanner_path=\""
896 (assoc-ref %build-inputs "wayland")
897 "/bin/wayland-scanner\""))
898 (delete "use_vaapi=true" ,flags)))))))