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 protobuf)
59 #:use-module (gnu packages pulseaudio)
60 #:use-module (gnu packages python)
61 #:use-module (gnu packages python-web)
62 #:use-module (gnu packages python-xyz)
63 #:use-module (gnu packages regex)
64 #:use-module (gnu packages serialization)
65 #:use-module (gnu packages speech)
66 #:use-module (gnu packages tls)
67 #:use-module (gnu packages valgrind)
68 #:use-module (gnu packages vulkan)
69 #:use-module (gnu packages video)
70 #:use-module (gnu packages xiph)
71 #:use-module (gnu packages xml)
72 #:use-module (gnu packages xdisorg)
73 #:use-module (gnu packages xorg)
74 #:use-module (ice-9 match)
75 #:use-module (srfi srfi-1))
77 (define %preserved-third-party-files
78 '("base/third_party/cityhash" ;Expat
79 "base/third_party/double_conversion" ;BSD-3
80 "base/third_party/dynamic_annotations" ;BSD-2
81 "base/third_party/icu" ;Unicode, X11-style
82 "base/third_party/superfasthash" ;BSD-3
83 "base/third_party/symbolize" ;BSD-3
84 "base/third_party/xdg_mime" ;LGPL2.0+ or Academic 2.0
85 "base/third_party/xdg_user_dirs" ;Expat
86 "chrome/third_party/mozilla_security_manager" ;MPL-1.1/GPL2+/LGPL2.1+
87 "courgette/third_party/bsdiff" ;BSD-2, BSD protection license
88 "courgette/third_party/divsufsort" ;Expat
89 "net/third_party/mozilla_security_manager" ;MPL-1.1/GPL2+/LGPL2.1+
90 "net/third_party/nss" ;MPL-2.0
91 "net/third_party/quiche" ;BSD-3
92 "net/third_party/uri_template" ;ASL2.0
93 "third_party/abseil-cpp" ;ASL2.0
94 "third_party/adobe/flash/flapper_version.h" ;no license, trivial
95 "third_party/angle" ;BSD-3
96 "third_party/angle/src/common/third_party/base" ;BSD-3
97 "third_party/angle/src/common/third_party/smhasher" ;Public domain
98 "third_party/angle/src/common/third_party/xxhash" ;BSD-2
99 "third_party/angle/src/third_party/compiler" ;BSD-2
100 "third_party/angle/src/third_party/libXNVCtrl" ;Expat
101 "third_party/angle/src/third_party/trace_event" ;BSD-3
102 "third_party/angle/src/third_party/volk" ;Expat
103 "third_party/angle/third_party/vulkan-headers" ;ASL2.0
104 "third_party/angle/third_party/vulkan-loader" ;ASL2.0
105 "third_party/angle/third_party/vulkan-tools" ;ASL2.0
106 "third_party/angle/third_party/vulkan-validation-layers" ;ASL2.0
107 "third_party/apple_apsl" ;APSL2.0
108 "third_party/axe-core" ;MPL2.0
109 "third_party/blink" ;BSD-3, LGPL2+
110 "third_party/boringssl" ;OpenSSL/ISC (Google additions are ISC)
111 "third_party/boringssl/src/third_party/fiat" ;Expat
112 "third_party/breakpad" ;BSD-3
113 "third_party/brotli" ;Expat
114 "third_party/cacheinvalidation" ;ASL2.0
115 "third_party/catapult" ;BSD-3
116 "third_party/catapult/common/py_vulcanize/third_party/rcssmin" ;ASL2.0
117 "third_party/catapult/common/py_vulcanize/third_party/rjsmin" ;ASL2.0
118 "third_party/catapult/third_party/polymer" ;BSD-3
119 ;; XXX: This is a minified version of <https://d3js.org/>.
120 "third_party/catapult/tracing/third_party/d3" ;BSD-3
121 "third_party/catapult/tracing/third_party/gl-matrix" ;Expat
122 "third_party/catapult/tracing/third_party/jpeg-js" ;ASL2.0
123 ;; XXX: Minified version of <https://github.com/Stuk/jszip>.
124 "third_party/catapult/tracing/third_party/jszip" ;Expat or GPL3
125 "third_party/catapult/tracing/third_party/mannwhitneyu" ;Expat
126 "third_party/catapult/tracing/third_party/oboe" ;BSD-2
127 ;; XXX: Minified version of <https://github.com/nodeca/pako>.
128 "third_party/catapult/tracing/third_party/pako" ;Expat
129 "third_party/ced" ;BSD-3
130 "third_party/cld_3" ;ASL2.0
131 "third_party/closure_compiler" ;ASL2.0
132 "third_party/crashpad" ;ASL2.0
133 "third_party/crashpad/crashpad/third_party/lss" ;ASL2.0
134 "third_party/crashpad/crashpad/third_party/zlib/zlib_crashpad.h" ;Zlib
135 "third_party/crc32c" ;BSD-3
136 "third_party/cros_system_api" ;BSD-3
137 "third_party/dav1d" ;BSD-2
138 "third_party/dawn" ;ASL2.0
139 "third_party/depot_tools/owners.py" ;BSD-3
140 "third_party/devtools-frontend" ;BSD-3
141 "third_party/devtools-frontend/src/front_end/third_party/acorn" ;Expat
142 "third_party/devtools-frontend/src/front_end/third_party/codemirror" ;Expat
143 "third_party/devtools-frontend/src/front_end/third_party/fabricjs" ;Expat
144 "third_party/devtools-frontend/src/front_end/third_party/lighthouse" ;ASL2.0
145 "third_party/devtools-frontend/src/front_end/third_party/wasmparser" ;ASL2.0
146 "third_party/devtools-frontend/src/third_party/axe-core" ;MPL2.0
147 "third_party/devtools-frontend/src/third_party/pyjson5" ;ASL2.0
148 "third_party/devtools-frontend/src/third_party/typescript" ;ASL2.0
149 "third_party/dom_distiller_js" ;BSD-3
150 "third_party/emoji-segmenter" ;ASL2.0
151 "third_party/flatbuffers" ;ASL2.0
152 "third_party/glslang" ;BSD-3, Expat, ASL2.0
153 "third_party/google_input_tools" ;ASL2.0
154 "third_party/google_input_tools/third_party/closure_library" ;ASL2.0
155 "third_party/google_input_tools/third_party/closure_library/third_party/closure" ;Expat
156 "third_party/googletest" ;BSD-3
157 "third_party/harfbuzz-ng" ;Expat
158 "third_party/hunspell" ;MPL1.1/GPL2+/LGPL2.1+
159 "third_party/iccjpeg" ;IJG
160 "third_party/inspector_protocol" ;BSD-3
161 "third_party/jinja2" ;BSD-3
162 "third_party/jstemplate" ;ASL2.0
163 "third_party/khronos" ;Expat, SGI
164 "third_party/leveldatabase" ;BSD-3
165 "third_party/libavif" ;BSD-2
166 "third_party/libXNVCtrl" ;Expat
167 "third_party/libaddressinput" ;ASL2.0
168 "third_party/libaom" ;BSD-2 or "Alliance for Open Media Patent License 1.0"
169 "third_party/libaom/source/libaom/third_party/vector" ;Expat
170 "third_party/libaom/source/libaom/third_party/x86inc" ;ISC
171 "third_party/libgifcodec" ;MPL1.1/GPL2+/LGPL2.1+, BSD-3, BSD-2
172 "third_party/libjingle_xmpp" ;BSD-3
173 "third_party/libphonenumber" ;ASL2.0
174 "third_party/libsecret" ;LGPL2.1+
175 "third_party/libsrtp" ;BSD-3
176 "third_party/libsync" ;ASL2.0
177 "third_party/libudev" ;LGPL2.1+
178 "third_party/libwebm" ;BSD-3
179 "third_party/libxml/chromium" ;BSD-3
180 "third_party/libyuv" ;BSD-3
181 "third_party/lottie" ;Expat
182 "third_party/lss" ;BSD-3
183 "third_party/mako" ;Expat
184 "third_party/markupsafe" ;BSD-3
185 "third_party/mesa_headers" ;Expat, SGI
186 "third_party/metrics_proto" ;BSD-3
187 "third_party/modp_b64" ;BSD-3
188 "third_party/nasm" ;BSD-2
189 "third_party/node" ;Expat
190 "third_party/node/node_modules/polymer-bundler/lib/third_party/UglifyJS2" ;BSD-2
191 "third_party/one_euro_filter" ;BSD-3
192 "third_party/openscreen" ;BSD-3
193 "third_party/openscreen/src/third_party/tinycbor" ;Expat
194 "third_party/openscreen/src/third_party/mozilla" ;MPL1.1/GPL2+/LGPL2.1+, BSD-3
195 "third_party/ots" ;BSD-3
196 "third_party/pdfium" ;BSD-3
197 "third_party/pdfium/third_party/agg23" ;Expat
198 "third_party/pdfium/third_party/base" ;BSD-3
199 "third_party/pdfium/third_party/bigint" ;Public domain, BSD-3
200 "third_party/pdfium/third_party/skia_shared" ;BSD-3
201 "third_party/pdfium/third_party/freetype/include/pstables.h" ;FreeType
202 "third_party/perfetto" ;ASL2.0
203 "third_party/pffft" ;the "FFTPACK" license, similar to BSD-3
204 "third_party/ply" ;BSD-3
205 "third_party/polymer" ;BSD-3
206 "third_party/private-join-and-compute" ;ASL2.0
207 "third_party/protobuf" ;BSD-3
208 "third_party/protobuf/third_party/six" ;Expat
209 "third_party/pyjson5" ;ASL2.0
210 "third_party/qcms" ;Expat
211 "third_party/rnnoise" ;BSD-3
212 "third_party/s2cellid" ;ASL2.0
213 "third_party/schema_org" ;CC-BY-SA3.0
214 "third_party/skia" ;BSD-3
215 "third_party/skia/include/third_party/skcms" ;BSD-3
216 "third_party/skia/third_party/skcms" ;BSD-3
217 "third_party/skia/third_party/vulkanmemoryallocator" ;BSD-3, Expat
218 "third_party/smhasher" ;Expat, public domain
219 "third_party/speech-dispatcher" ;GPL2+
220 "third_party/spirv-headers" ;ASL2.0
221 "third_party/SPIRV-Tools" ;ASL2.0
222 "third_party/sqlite" ;Public domain
223 "third_party/swiftshader" ;ASL2.0
224 "third_party/swiftshader/third_party/astc-encoder" ;ASL2.0
225 "third_party/swiftshader/third_party/llvm-7.0" ;NCSA
226 "third_party/swiftshader/third_party/llvm-subzero" ;NCSA
227 "third_party/swiftshader/third_party/marl" ;ASL2.0
228 "third_party/swiftshader/third_party/subzero" ;NCSA
229 "third_party/swiftshader/third_party/SPIRV-Headers" ;X11-style
230 "third_party/usb_ids" ;BSD-3
231 "third_party/usrsctp" ;BSD-2
232 "third_party/vulkan_memory_allocator" ;Expat
233 "third_party/wayland/wayland_scanner_wrapper.py" ;BSD-3
234 "third_party/wayland-protocols" ;Expat
235 "third_party/web-animations-js" ;ASL2.0
236 "third_party/webdriver" ;ASL2.0
237 "third_party/webrtc" ;BSD-3
238 "third_party/webrtc/common_audio/third_party/ooura" ;Non-copyleft
239 "third_party/webrtc/common_audio/third_party/spl_sqrt_floor" ;Public domain
240 "third_party/webrtc/modules/third_party/fft" ;Non-copyleft
241 "third_party/webrtc/modules/third_party/g711" ;Public domain
242 "third_party/webrtc/modules/third_party/g722" ;Public domain
243 "third_party/webrtc/rtc_base/third_party/base64" ;Non-copyleft
244 "third_party/webrtc/rtc_base/third_party/sigslot" ;Public domain
245 "third_party/widevine/cdm/widevine_cdm_version.h" ;BSD-3
246 "third_party/widevine/cdm/widevine_cdm_common.h" ;BSD-3
247 "third_party/woff2" ;ASL2.0
248 "third_party/xdg-utils" ;Expat
249 "third_party/zlib/google" ;BSD-3
250 "url/third_party/mozilla" ;BSD-3, MPL1.1/GPL2+/LGPL2.1+
251 "v8/src/third_party/siphash" ;Public domain
252 "v8/src/third_party/utf8-decoder" ;Expat
253 "v8/src/third_party/valgrind" ;BSD-4
254 "v8/third_party/inspector_protocol" ;BSD-3
255 "v8/third_party/v8/builtins")) ;PSFL
257 (define %blacklisted-files
258 ;; 'third_party/blink/perf_tests/resources/svg/HarveyRayner.svg' carries a
259 ;; nonfree license according to LICENSES in the same directory. As we don't
260 ;; run the Blink performance tests, just remove everything to save ~24MiB.
261 '("third_party/blink/perf_tests"))
263 (define (gentoo-patch name revision hash)
266 (uri (string-append "https://gitweb.gentoo.org/repo/gentoo.git/plain"
267 "/www-client/chromium/files/" name "?id=" revision))
268 (file-name (string-append "ungoogled-" name))
269 (sha256 (base32 hash))))
271 ;; This repository contains libstdc++ compatibility patches for Chromium.
272 (define (chromium-gcc-patchset commit hash)
276 (url "https://github.com/stha09/chromium-patches")
278 (file-name (git-file-name "chromium-gcc-patches" commit))
279 (sha256 (base32 hash))))
281 (define (debian-patch name revision hash)
284 (uri (string-append "https://salsa.debian.org/chromium-team/chromium/-/raw/"
285 revision "/debian/patches/" name))
286 (file-name (match (string-split name #\/)
288 (string-append "ungoogled-chromium-" category "-" name))))
289 (sha256 (base32 hash))))
291 (define %ungoogled-revision "df199c04ff367da59ce52a23a3f3b305dd3b00c3")
292 (define %debian-revision "debian/83.0.4103.116-3")
293 (define %gentoo-revision "f3f649046d31ebdbc8c4a302b2384504eff78027")
295 (define %gentoo-patches
296 ;; This patch is necessary for compatibility with FFmpeg 4.3.
297 (list (gentoo-patch "chromium-84-mediaalloc.patch" %gentoo-revision
298 "0snxdc4nb8ykzncz62vpsl8hgxpy24m17mycx67i2gckmrpslzzv")))
300 (define %chromium-gcc-patches
301 (chromium-gcc-patchset
302 "chromium-84-patchset-3"
303 "0l05gx3pn703n47anjwsl5sjcqw8kaxmivf7llax97kj3k6d127v"))
305 (define %debian-patches
306 (list (debian-patch "system/zlib.patch" %debian-revision
307 "0bp2vh1cgmwjrn1zkpphkd3bs662s23xwdhy3abm9cfjvwrj117n")
308 (debian-patch "system/jsoncpp.patch" %debian-revision
309 "0d95brl4a5y5w142yd0rvf59z513h7chsz0vnm034d6lqf22ahwf")
310 (debian-patch "system/openjpeg.patch" %debian-revision
311 "0zd6v5njx1pc7i0y6mslxvpx5j4cq01mmyx55qcqx8qzkm0gm48j")))
313 (define %ungoogled-origin
316 (uri (git-reference (url "https://github.com/Eloston/ungoogled-chromium")
317 (commit %ungoogled-revision)))
318 (file-name (git-file-name "ungoogled-chromium"
319 (string-take %ungoogled-revision 7)))
322 "1bqvcq3dj6615198j7cz3ylyyic5zpis06capvl6ybl1na3ainb0"))))
324 ;; This is a source 'snippet' that does the following:
325 ;; *) Applies various patches for unbundling purposes and libstdc++ compatibility.
326 ;; *) Runs the ungoogled patch-, domain substitution-, and scrubbing scripts.
327 ;; *) Prunes all third_party directories that are not explicitly preserved.
328 ;; *) Adjusts "GN" build files such that system libraries are preferred.
329 (define ungoogled-chromium-snippet
330 ;; Note: delay to cope with cyclic module imports at the top level.
333 (let ((chromium-dir (getcwd)))
334 (set-path-environment-variable
336 (list #+patch #+python-wrapper #+xz))
338 ;; Apply patches before running the ungoogled scripts because
339 ;; domain substitution may break some of the patches.
340 (format #t "Applying assorted build fixes...~%")
342 (for-each (lambda (patch)
343 (invoke "patch" "-p1" "--force" "--input"
344 patch "--no-backup-if-mismatch"))
346 '#+%gentoo-patches '#+%debian-patches
347 (find-files #$%chromium-gcc-patches "\\.patch$")
350 "ungoogled-chromium-system-nspr.patch")))))
352 (with-directory-excursion #+%ungoogled-origin
353 (format #t "Ungooglifying...~%")
355 (invoke "python" "utils/prune_binaries.py" chromium-dir
357 (invoke "python" "utils/patches.py" "apply"
358 chromium-dir "patches")
359 (invoke "python" "utils/domain_substitution.py" "apply" "-r"
360 "domain_regex.list" "-f" "domain_substitution.list"
361 "-c" "/tmp/domainscache.tar.gz" chromium-dir))
363 ;; Run after the ungoogled scripts to avoid interfering with
364 ;; patches or file lists.
365 (format #t "Removing blacklisted files...~%")
367 (for-each delete-file-recursively '#$%blacklisted-files)
369 (format #t "Pruning third party files...~%")
371 (apply invoke (string-append #+python-2 "/bin/python")
372 "build/linux/unbundle/remove_bundled_libraries.py"
373 "--do-remove" '#$%preserved-third-party-files)
375 (format #t "Replacing GN files...~%")
377 (invoke "python" "build/linux/unbundle/replace_gn_files.py"
378 "--system-libraries" "ffmpeg" "flac" "fontconfig"
379 "freetype" "harfbuzz-ng" "icu" "libdrm" "libevent"
380 "libjpeg" "libpng" "libvpx" "libwebp" "libxml"
381 "libxslt" "openh264" "opus" "re2" "snappy" "zlib")
385 (package/inherit opus
388 (substitute-keyword-arguments (package-arguments opus)
389 ((#:configure-flags flags ''())
390 ;; Opus Custom is an optional extension of the Opus
391 ;; specification that allows for unsupported frame
392 ;; sizes. Chromium requires that this is enabled.
393 `(cons "--enable-custom-modes"
396 ;; Chromium still has Python2-only code, so we need this special Python 2
397 ;; variant of xcb-proto.
398 (define xcb-proto/python2
401 (name "python2-xcb-proto")
403 `(("pkg-config" ,pkg-config)
404 ("python" ,python-2)))))
406 (define-public ungoogled-chromium
408 (name "ungoogled-chromium")
409 (version (string-append "84.0.4147.89-0."
410 (string-take %ungoogled-revision 7)))
411 (synopsis "Graphical web browser")
414 (uri (string-append "https://commondatastorage.googleapis.com"
415 "/chromium-browser-official/chromium-"
416 (car (string-split version #\-)) ".tar.xz"))
419 "0yf6j0459qzr677zsa2apmfz0x0ndlscvwj1a5v40nqjijchv5qp"))
420 (modules '((guix build utils)))
421 (snippet (force ungoogled-chromium-snippet))))
422 (build-system gnu-build-system)
425 ;; FIXME: Chromiums RUNPATH lacks entries for some libraries.
426 #:validate-runpath? #f
427 #:modules ((guix build gnu-build-system)
433 ;; See tools/gn/docs/cookbook.md and
434 ;; https://www.chromium.org/developers/gn-build-configuration
435 ;; for usage. Run "./gn args . --list" in the Release
436 ;; directory for an exhaustive list of supported flags.
437 ;; (Note: The 'configure' phase will do that for you.)
438 (list "is_debug=false"
439 "is_unsafe_developer_build=false"
442 (string-append "max_jobs_per_link="
443 (number->string (parallel-job-count)))
444 "exclude_unwind_tables=true"
445 "clang_use_chrome_plugins=false"
446 "use_custom_libcxx=false"
448 "enable_precompiled_headers=false"
451 "enable_nacl_nonsfi=false"
452 "use_allocator=\"none\""
453 "use_unofficial_version_number=false"
454 "treat_warnings_as_errors=false"
455 "use_official_google_api_keys=false"
456 "fieldtrial_testing_like_official_build=true"
457 "safe_browsing_mode=0"
459 "enable_one_click_signin=false"
460 "enable_reading_list=false"
461 "enable_remoting=false"
462 "enable_reporting=false"
463 "enable_service_discovery=false"
465 "enable_widevine=false"
466 ;; Disable type-checking for the Web UI to avoid a Java dependency.
467 "closure_compile=false"
469 ;; Define a custom toolchain that simply looks up CC, AR and
470 ;; friends from the environment.
471 "custom_toolchain=\"//build/toolchain/linux/unbundle:default\""
472 "host_toolchain=\"//build/toolchain/linux/unbundle:default\""
474 (string-append "xcbproto_path=\""
475 (assoc-ref %build-inputs "xcb-proto") "/share/xcb\"")
477 ;; Prefer system libraries.
478 "use_system_freetype=true"
479 "use_system_harfbuzz=true"
480 "use_system_lcms2=true"
481 "use_system_libdrm=true"
482 "use_system_libjpeg=true"
483 "use_system_libopenjpeg2=true"
484 "use_system_libpng=true"
485 "use_system_zlib=true"
486 "use_gnome_keyring=false" ;deprecated by libsecret
488 "use_pulseaudio=true"
489 "link_pulseaudio=true"
490 "icu_use_data_file=false"
491 "perfetto_use_system_protobuf=true"
493 ;; VA-API acceleration is currently only supported on x86_64-linux.
494 ,@(if (string-prefix? "x86_64" (or (%current-target-system)
499 ;; Do not artifically restrict formats supported by system ffmpeg.
500 "proprietary_codecs=true"
501 "ffmpeg_branding=\"Chrome\""
505 ;; Don't use bundled sources.
506 "rtc_build_json=false"
507 "rtc_build_libevent=false"
508 "rtc_build_libvpx=false"
509 "rtc_build_opus=false"
510 "rtc_build_ssl=false"
511 "rtc_build_libsrtp=true" ;FIXME: fails to find headers
512 "rtc_build_usrsctp=true" ;TODO: package this
513 (string-append "rtc_jsoncpp_root=\""
514 (assoc-ref %build-inputs "jsoncpp")
515 "/include/jsoncpp/json\"")
516 (string-append "rtc_ssl_root=\""
517 (assoc-ref %build-inputs "openssl")
518 "/include/openssl\""))
520 (modify-phases %standard-phases
521 (add-after 'unpack 'patch-stuff
523 ;; Fix build with newer re2. Taken from:
524 ;; https://chromium-review.googlesource.com/c/chromium/src/+/2145261
525 (substitute* "components/autofill/core/browser/address_rewriter.cc"
526 (("options\\.set_utf8\\(true\\)")
527 "options.set_encoding(RE2::Options::EncodingUTF8)"))
530 '("base/process/launch_posix.cc"
531 "base/third_party/dynamic_annotations/dynamic_annotations.c"
532 "sandbox/linux/seccomp-bpf/sandbox_bpf.cc"
533 "sandbox/linux/services/credentials.cc"
534 "sandbox/linux/services/namespace_utils.cc"
535 "sandbox/linux/services/syscall_wrappers.cc"
536 "sandbox/linux/syscall_broker/broker_host.cc")
537 (("include \"base/third_party/valgrind/") "include \"valgrind/"))
539 (for-each (lambda (file)
541 ;; Fix opus include path.
542 ;; Do not substitute opus_private.h.
543 (("#include \"opus\\.h\"")
544 "#include \"opus/opus.h\"")
545 (("#include \"opus_custom\\.h\"")
546 "#include \"opus/opus_custom.h\"")
547 (("#include \"opus_defines\\.h\"")
548 "#include \"opus/opus_defines.h\"")
549 (("#include \"opus_multistream\\.h\"")
550 "#include \"opus/opus_multistream.h\"")
551 (("#include \"opus_types\\.h\"")
552 "#include \"opus/opus_types.h\"")))
553 (find-files (string-append "third_party/webrtc/modules"
554 "/audio_coding/codecs/opus")))
556 (substitute* "chrome/common/chrome_paths.cc"
557 (("/usr/share/chromium/extensions")
558 ;; TODO: Add ~/.guix-profile.
559 "/run/current-system/profile/share/chromium/extensions"))
561 ;; Many files try to include ICU headers from "third_party/icu/...".
562 ;; Remove the "third_party/" prefix to use system headers instead.
563 (substitute* (find-files "chrome" "\\.cc$")
564 (("third_party/icu/source/(common|i18n)/")
567 ;; XXX: Should be unnecessary when use_system_lcms2=true.
568 (substitute* "third_party/pdfium/core/fxcodec/icc/iccmodule.h"
569 (("include \"third_party/lcms/include/lcms2\\.h\"")
570 "include \"lcms2.h\""))
573 "third_party/breakpad/breakpad/src/common/linux/libcurl_wrapper.h"
574 (("include \"third_party/curl") "include \"curl"))
576 (substitute* "third_party/webrtc/rtc_base/strings/json.h"
577 (("#include \"third_party/jsoncpp/") "#include \"json/"))
579 (substitute* '("components/viz/common/gpu/vulkan_context_provider.h"
580 "components/viz/common/resources/resource_format_utils.h"
581 "gpu/config/gpu_util.cc")
582 (("third_party/vulkan_headers/include/") ""))
584 (substitute* "third_party/skia/include/gpu/vk/GrVkVulkan.h"
585 (("include/third_party/vulkan/") ""))
587 ;; Building chromedriver embeds some files using the ZIP
588 ;; format which doesn't support timestamps before
589 ;; 1980. Therefore, advance the timestamps of the files
590 ;; which are included so that building chromedriver
592 (let ((circa-1980 (* 10 366 24 60 60)))
593 (for-each (lambda (file)
594 (utime file circa-1980 circa-1980))
595 '("chrome/test/chromedriver/extension/background.js"
596 "chrome/test/chromedriver/extension/manifest.json")))
599 (add-after 'patch-stuff 'add-absolute-references
600 (lambda* (#:key inputs #:allow-other-keys)
601 (let ((cups (assoc-ref inputs "cups"))
602 (nss (assoc-ref inputs "nss"))
603 (mesa (assoc-ref inputs "mesa"))
604 (udev (assoc-ref inputs "udev")))
605 (substitute* "printing/cups_config_helper.py"
607 (string-append "cups_config = '" cups
608 "/bin/cups-config'\n")))
609 (substitute* "crypto/nss_util.cc"
611 (string-append nss "/lib/nss/libnssckbi.so")))
612 (substitute* "device/udev_linux/udev1_loader.cc"
613 (("libudev\\.so\\.1")
614 (string-append udev "/lib/libudev.so.1")))
616 (add-before 'configure 'prepare-build-environment
617 (lambda* (#:key inputs #:allow-other-keys)
619 ;; Make sure the right build tools are used.
620 (setenv "AR" "ar") (setenv "NM" "nm")
621 (setenv "CC" "clang") (setenv "CXX" "clang++")
625 '(;; Do not optimize away null pointer safety checks.
626 "-fno-delete-null-pointer-checks"
627 ;; Disable warnings about unknown warnings that require
628 ;; Clang plugins or newer versions.
629 "-Wno-unknown-warning-option")))
631 (setenv "CFLAGS" "-Wno-unknown-warning-option")
633 ;; TODO: pre-compile instead. Avoids a race condition.
634 (setenv "PYTHONDONTWRITEBYTECODE" "1")
636 ;; XXX: How portable is this.
637 (mkdir-p "third_party/node/linux/node-linux-x64")
638 (symlink (string-append (assoc-ref inputs "node") "/bin")
639 "third_party/node/linux/node-linux-x64/bin")
643 (lambda* (#:key configure-flags #:allow-other-keys)
644 (let ((args (string-join configure-flags " ")))
645 ;; Generate ninja build files.
646 (invoke "gn" "gen" "out/Release"
647 (string-append "--args=" args))
649 ;; Print the full list of supported arguments as well as
650 ;; their current status for convenience.
651 (format #t "Dumping configure flags...\n")
652 (invoke "gn" "args" "out/Release" "--list"))))
653 (add-before 'build 'increase-resource-limits
655 ;; XXX: Chromiums linking step requires a lot of simultaneous file
656 ;; accesses. Having a too low ulimit will result in bogus linker
657 ;; errors such as "foo.a: error adding symbols: malformed archive".
659 ;; Try increasing the soft resource limit of max open files to 2048,
660 ;; or equal to the hard limit, whichever is lower.
661 (call-with-values (lambda () (getrlimit 'nofile))
663 (when (and soft (< soft 2048))
665 (setrlimit 'nofile (min hard 2048) hard)
666 (setrlimit 'nofile 2048 #f))
668 "increased maximum number of open files from ~d to ~d~%"
669 soft (if hard (min hard 2048) 2048)))))
672 (lambda* (#:key (parallel-build? #t) #:allow-other-keys)
673 (invoke "ninja" "-C" "out/Release"
674 "-j" (if parallel-build?
675 (number->string (parallel-job-count))
680 (lambda* (#:key inputs outputs #:allow-other-keys)
681 (let* ((out (assoc-ref outputs "out"))
682 (bin (string-append out "/bin"))
683 (exe (string-append bin "/chromium"))
684 (lib (string-append out "/lib"))
685 (man (string-append out "/share/man/man1"))
686 (applications (string-append out "/share/applications"))
687 (install-regexp (make-regexp "\\.(bin|pak|so)$"))
688 (locales (string-append lib "/locales"))
689 (resources (string-append lib "/resources"))
690 (preferences (assoc-ref inputs "master-preferences"))
691 (gtk+ (assoc-ref inputs "gtk+"))
694 (substitute* '("chrome/app/resources/manpage.1.in"
695 "chrome/installer/linux/common/desktop.template")
696 (("@@MENUNAME@@") "Chromium")
697 (("@@PACKAGE@@") "chromium")
698 (("/usr/bin/@@USR_BIN_SYMLINK_NAME@@") exe))
701 (copy-file "chrome/app/resources/manpage.1.in"
702 (string-append man "/chromium.1"))
704 (mkdir-p applications)
705 (copy-file "chrome/installer/linux/common/desktop.template"
706 (string-append applications "/chromium.desktop"))
709 (copy-file preferences (string-append lib "/master_preferences"))
711 (with-directory-excursion "out/Release"
712 (for-each (lambda (file)
713 (install-file file lib))
714 (scandir "." (cut regexp-exec install-regexp <>)))
715 (copy-file "chrome" (string-append lib "/chromium"))
717 (copy-recursively "locales" locales)
718 (copy-recursively "resources" resources)
721 (symlink "../lib/chromium" exe)
722 (install-file "chromedriver" bin)
724 (for-each (lambda (so)
725 (install-file so (string-append lib "/swiftshader")))
726 (find-files "swiftshader" "\\.so$"))
729 ;; Avoid file manager crash. See <https://bugs.gnu.org/26593>.
730 `("XDG_DATA_DIRS" ":" prefix (,(string-append gtk+ "/share")))))
732 (with-directory-excursion "chrome/app/theme/chromium"
735 (let ((icons (string-append out "/share/icons/hicolor/"
736 size "x" size "/apps")))
738 (copy-file (string-append "product_logo_" size ".png")
739 (string-append icons "/chromium.png"))))
740 '("24" "48" "64" "128" "256")))
749 ("pkg-config" ,pkg-config)
752 ;; This file contains defaults for new user profiles.
753 ("master-preferences" ,(local-file "aux-files/chromium/master-preferences.json"))
755 ("python-beautifulsoup4" ,python2-beautifulsoup4)
756 ("python-html5lib" ,python2-html5lib)
757 ("python" ,python-2)))
759 `(("alsa-lib" ,alsa-lib)
764 ("dbus-glib" ,dbus-glib)
768 ("fontconfig" ,fontconfig)
769 ("freetype" ,freetype)
770 ("gdk-pixbuf" ,gdk-pixbuf)
773 ("harfbuzz" ,harfbuzz)
777 ("libevent" ,libevent)
779 ("libjpeg-turbo" ,libjpeg-turbo)
786 ("libxcomposite" ,libxcomposite)
787 ("libxcursor" ,libxcursor)
788 ("libxdamage" ,libxdamage)
790 ("libxfixes" ,libxfixes)
793 ("libxrandr" ,libxrandr)
794 ("libxrender" ,libxrender)
795 ("libxscrnsaver" ,libxscrnsaver)
800 ("mit-krb5" ,mit-krb5)
802 ("openh264" ,openh264)
803 ("openjpeg" ,openjpeg) ;PDFium only
805 ("opus" ,opus+custom)
807 ("pciutils" ,pciutils)
808 ("protobuf" ,protobuf)
809 ("pulseaudio" ,pulseaudio)
812 ("speech-dispatcher" ,speech-dispatcher)
814 ("valgrind" ,valgrind)
815 ("vulkan-headers" ,vulkan-headers)
816 ("xcb-proto" ,xcb-proto/python2)))
818 ;; Building Chromium takes ... a very long time. On a single core, a busy
819 ;; mid-end x86 system may need more than 24 hours to complete the build.
820 (properties '((timeout . 144000) ;40 hours
821 ;; The linking step may take more than an hour on some hardware.
822 (max-silent-time . 7200)
823 (cpe-name . "chrome")))
825 (home-page "https://github.com/Eloston/ungoogled-chromium")
827 "Ungoogled-Chromium is the Chromium web browser, with some functionality
828 disabled in order to protect the users privacy.")
829 ;; Chromium is developed as BSD-3, but bundles a large number of third-party
830 ;; components with other licenses. For full information, see chrome://credits.
831 (license (list license:bsd-3
837 license:public-domain
839 (license:non-copyleft "chrome://credits"
840 "See chrome://credits for more information.")
843 (define-public ungoogled-chromium/wayland
844 (package/inherit ungoogled-chromium
845 (name "ungoogled-chromium-wayland")
847 `(("wayland" ,wayland)
848 ("wayland-protocols" ,wayland-protocols)
849 ,@(package-inputs ungoogled-chromium)))
851 (substitute-keyword-arguments (package-arguments ungoogled-chromium)
852 ((#:configure-flags flags)
853 `(append (list "use_ozone=true"
854 "ozone_platform_wayland=true"
855 "ozone_platform_x11=true"
856 "ozone_auto_platforms=false"
857 "ozone_platform=\"wayland\""
859 "use_system_minigbm=true"
860 "use_system_libwayland=true"
861 (string-append "system_wayland_scanner_path=\""
862 (assoc-ref %build-inputs "wayland")
863 "/bin/wayland-scanner\""))
864 (delete "use_vaapi=true" ,flags)))))))