1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2019 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 gcc)
41 #:use-module (gnu packages ghostscript)
42 #:use-module (gnu packages gl)
43 #:use-module (gnu packages glib)
44 #:use-module (gnu packages gnome)
45 #:use-module (gnu packages gperf)
46 #:use-module (gnu packages gtk)
47 #:use-module (gnu packages icu4c)
48 #:use-module (gnu packages image)
49 #:use-module (gnu packages libevent)
50 #:use-module (gnu packages libffi)
51 #:use-module (gnu packages linux)
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 (srfi srfi-1))
75 (define %preserved-third-party-files
76 '("base/third_party/cityhash" ;Expat
77 "base/third_party/dmg_fp" ;X11-style
78 "base/third_party/dynamic_annotations" ;BSD-2
79 "base/third_party/icu" ;Unicode, X11-style
80 "base/third_party/superfasthash" ;BSD-3
81 "base/third_party/symbolize" ;BSD-3
82 "base/third_party/xdg_mime" ;LGPL2.0+ or Academic 2.0
83 "base/third_party/xdg_user_dirs" ;Expat
84 "chrome/third_party/mozilla_security_manager" ;MPL-1.1/GPL2+/LGPL2.1+
85 "courgette/third_party/bsdiff" ;BSD-2, BSD protection license
86 "courgette/third_party/divsufsort" ;Expat
87 "net/third_party/mozilla_security_manager" ;MPL-1.1/GPL2+/LGPL2.1+
88 "net/third_party/nss" ;MPL-2.0
89 "net/third_party/quiche" ;BSD-3
90 "net/third_party/uri_template" ;ASL2.0
91 "third_party/abseil-cpp" ;ASL2.0
92 "third_party/adobe/flash/flapper_version.h" ;no license, trivial
93 "third_party/angle" ;BSD-3
94 "third_party/angle/src/common/third_party/base" ;BSD-3
95 "third_party/angle/src/common/third_party/smhasher" ;Public domain
96 "third_party/angle/src/common/third_party/xxhash" ;BSD-2
97 "third_party/angle/src/third_party/compiler" ;BSD-2
98 "third_party/angle/src/third_party/libXNVCtrl" ;Expat
99 "third_party/angle/src/third_party/trace_event" ;BSD-3
100 "third_party/angle/third_party/vulkan-headers" ;ASL2.0
101 "third_party/angle/third_party/vulkan-loader" ;ASL2.0
102 "third_party/angle/third_party/vulkan-tools" ;ASL2.0
103 "third_party/angle/third_party/vulkan-validation-layers" ;ASL2.0
104 "third_party/apple_apsl" ;APSL2.0
105 "third_party/axe-core" ;MPL2.0
106 "third_party/blink" ;BSD-3, LGPL2+
107 "third_party/boringssl" ;OpenSSL/ISC (Google additions are ISC)
108 "third_party/boringssl/src/third_party/fiat" ;Expat
109 "third_party/boringssl/src/third_party/sike" ;Expat
110 ;; XXX: these files are generated by fp-$arch.pl in the above directory.
111 "third_party/boringssl/linux-aarch64/crypto/third_party/sike/asm/fp-armv8.S"
112 "third_party/boringssl/linux-x86_64/crypto/third_party/sike/asm/fp-x86_64.S"
113 "third_party/breakpad" ;BSD-3
114 "third_party/brotli" ;Expat
115 "third_party/cacheinvalidation" ;ASL2.0
116 "third_party/catapult" ;BSD-3
117 "third_party/catapult/common/py_vulcanize/third_party/rcssmin" ;ASL2.0
118 "third_party/catapult/common/py_vulcanize/third_party/rjsmin" ;ASL2.0
119 "third_party/catapult/third_party/polymer" ;BSD-3
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/jszip" ;Expat or GPL3
123 "third_party/catapult/tracing/third_party/mannwhitneyu" ;Expat
124 "third_party/catapult/tracing/third_party/oboe" ;BSD-2
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/crashpad" ;ASL2.0
129 "third_party/crashpad/crashpad/third_party/lss" ;ASL2.0
130 "third_party/crashpad/crashpad/third_party/zlib/zlib_crashpad.h" ;Zlib
131 "third_party/crc32c" ;BSD-3
132 "third_party/cros_system_api" ;BSD-3
133 "third_party/dav1d" ;BSD-2
134 "third_party/dawn" ;ASL2.0
135 "third_party/dom_distiller_js" ;BSD-3
136 "third_party/emoji-segmenter" ;ASL2.0
137 "third_party/flatbuffers" ;ASL2.0
138 "third_party/glslang" ;BSD-3, Expat, ASL2.0
139 "third_party/google_input_tools" ;ASL2.0
140 "third_party/google_input_tools/third_party/closure_library" ;ASL2.0
141 "third_party/google_input_tools/third_party/closure_library/third_party/closure" ;Expat
142 "third_party/googletest" ;BSD-3
143 "third_party/hunspell" ;MPL1.1/GPL2+/LGPL2.1+
144 "third_party/iccjpeg" ;IJG
145 "third_party/inspector_protocol" ;BSD-3
146 "third_party/jinja2" ;BSD-3
147 "third_party/jstemplate" ;ASL2.0
148 "third_party/khronos" ;Expat, SGI
149 "third_party/leveldatabase" ;BSD-3
150 "third_party/libXNVCtrl" ;Expat
151 "third_party/libaddressinput" ;ASL2.0
152 "third_party/libaom" ;BSD-2 or "Alliance for Open Media Patent License 1.0"
153 "third_party/libaom/source/libaom/third_party/vector" ;Expat
154 "third_party/libaom/source/libaom/third_party/x86inc" ;ISC
155 "third_party/libjingle_xmpp" ;BSD-3
156 "third_party/libphonenumber" ;ASL2.0
157 "third_party/libsecret" ;LGPL2.1+
158 "third_party/libsrtp" ;BSD-3
159 "third_party/libsync" ;ASL2.0
160 "third_party/libudev" ;LGPL2.1+
161 "third_party/libwebm" ;BSD-3
162 "third_party/libxml/chromium" ;BSD-3
163 "third_party/libyuv" ;BSD-3
164 "third_party/lss" ;BSD-3
165 "third_party/markupsafe" ;BSD-3
166 "third_party/mesa_headers" ;Expat, SGI
167 "third_party/metrics_proto" ;BSD-3
168 "third_party/modp_b64" ;BSD-3
169 "third_party/nasm" ;BSD-2
170 "third_party/node" ;Expat
171 "third_party/node/node_modules/polymer-bundler/lib/third_party/UglifyJS2" ;BSD-2
172 "third_party/openscreen" ;BSD-3
173 "third_party/ots" ;BSD-3
174 "third_party/pdfium" ;BSD-3
175 "third_party/pdfium/third_party/agg23" ;Expat
176 "third_party/pdfium/third_party/base" ;BSD-3
177 "third_party/pdfium/third_party/bigint" ;Public domain, BSD-3
178 "third_party/pdfium/third_party/skia_shared" ;BSD-3
179 "third_party/pdfium/third_party/freetype/include/pstables.h" ;FreeType
180 "third_party/pffft" ;the "FFTPACK" license, similar to BSD-3
181 "third_party/ply" ;BSD-3
182 "third_party/polymer" ;BSD-3
183 "third_party/protobuf" ;BSD-3
184 "third_party/protobuf/third_party/six" ;Expat
185 "third_party/pyjson5" ;ASL2.0
186 "third_party/qcms" ;Expat
187 "third_party/rnnoise" ;BSD-3
188 "third_party/s2cellid" ;ASL2.0
189 "third_party/sfntly" ;ASL2.0
190 "third_party/skia" ;BSD-3
191 "third_party/skia/include/third_party/skcms" ;BSD-3
192 "third_party/skia/third_party/gif" ;MPL1.1/GPL2+/LGPL2.1+
193 "third_party/skia/third_party/skcms" ;BSD-3
194 "third_party/skia/third_party/vulkanmemoryallocator" ;BSD-3, Expat
195 "third_party/smhasher" ;Expat, public domain
196 "third_party/speech-dispatcher" ;GPL2+
197 "third_party/spirv-headers" ;ASL2.0
198 "third_party/SPIRV-Tools" ;ASL2.0
199 "third_party/sqlite" ;Public domain
200 "third_party/ungoogled" ;BSD-3
201 "third_party/usb_ids" ;BSD-3
202 "third_party/usrsctp" ;BSD-2
203 "third_party/wayland/wayland_scanner_wrapper.py" ;BSD-3
204 "third_party/wayland-protocols" ;Expat
205 "third_party/web-animations-js" ;ASL2.0
206 "third_party/webdriver" ;ASL2.0
207 "third_party/webrtc" ;BSD-3
208 "third_party/webrtc/common_audio/third_party/fft4g" ;Non-copyleft
209 "third_party/webrtc/common_audio/third_party/spl_sqrt_floor" ;Public domain
210 "third_party/webrtc/modules/third_party/fft" ;Non-copyleft
211 "third_party/webrtc/modules/third_party/g711" ;Public domain
212 "third_party/webrtc/modules/third_party/g722" ;Public domain
213 "third_party/webrtc/rtc_base/third_party/base64" ;Non-copyleft
214 "third_party/webrtc/rtc_base/third_party/sigslot" ;Public domain
215 "third_party/widevine/cdm/widevine_cdm_version.h" ;BSD-3
216 "third_party/widevine/cdm/widevine_cdm_common.h" ;BSD-3
217 "third_party/woff2" ;ASL2.0
218 "third_party/xdg-utils" ;Expat
219 "third_party/yasm/run_yasm.py" ;BSD-2 or BSD-3
220 "third_party/zlib/google" ;BSD-3
221 "url/third_party/mozilla" ;BSD-3, MPL1.1/GPL2+/LGPL2.1+
222 "v8/src/third_party/siphash" ;Public domain
223 "v8/src/third_party/utf8-decoder" ;Expat
224 "v8/src/third_party/valgrind" ;BSD-4
225 "v8/third_party/inspector_protocol" ;BSD-3
226 "v8/third_party/v8/builtins")) ;PSFL
228 (define* (computed-origin-method gexp-promise hash-algo hash
229 #:optional (name "source")
230 #:key (system (%current-system))
231 (guile (default-guile)))
232 "Return a derivation that executes the G-expression that results
233 from forcing GEXP-PROMISE."
234 (mlet %store-monad ((guile (package->derivation guile system)))
235 (gexp->derivation (or name "computed-origin")
237 #:graft? #f ;nothing to graft
239 #:guile-for-build guile)))
241 (define %chromium-version "76.0.3809.132")
242 (define %ungoogled-revision "8eba5c0df1a318012e3deab39a9add252a0d56a3")
243 (define %debian-revision "debian/76.0.3809.87-2")
244 (define package-revision "0")
245 (define %package-version (string-append %chromium-version "-"
247 (string-take %ungoogled-revision 7)))
249 (define %chromium-origin
252 (uri (string-append "https://commondatastorage.googleapis.com"
253 "/chromium-browser-official/chromium-"
254 %chromium-version ".tar.xz"))
257 "0hajwjf7swlgh1flpf8ljfrb2zhmcpzvrigvvxqd36g3nm04cknm"))))
259 (define %ungoogled-origin
262 (uri (git-reference (url "https://github.com/Eloston/ungoogled-chromium")
263 (commit %ungoogled-revision)))
264 (file-name (git-file-name "ungoogled-chromium"
265 (string-take %ungoogled-revision 7)))
268 "08fd9whfc1qky44xqxbypr7jz1rg6cma017wj4b5c5b14grxz6k6"))))
270 (define %debian-origin
274 (url "https://salsa.debian.org/chromium-team/chromium.git")
275 (commit %debian-revision)))
276 (file-name (git-file-name "debian-chromium-packaging"
277 (if (string-prefix? "debian/" %debian-revision)
278 (cadr (string-split %debian-revision #\/))
279 (string-take %debian-revision 7))))
282 "1fjhpzrxmgjr7i31li1vsfmp0qkbi0cpyc7p1zjwvf2x4da0v907"))))
284 (define (gentoo-patch name hash revision)
287 (uri (string-append "https://gitweb.gentoo.org/repo/gentoo.git/plain"
288 "/www-client/chromium/files/" name "?id=" revision))
290 (sha256 (base32 hash))))
292 (define-syntax-rule (gentoo-patches (name hash) ...)
293 (list (gentoo-patch name hash "9fd80e7d75aa63843ec33c9d44fee32596ae8f25")
296 (define %auxiliary-patches
297 ;; XXX: Debians "gcc/wrong-namespace.patch" and "fixes/inspector.patch" does
298 ;; not work for us, so we take these upstream fixes via Gentoo instead.
300 ("chromium-76-quiche.patch" "1cs0y16jn7r1nxh0j36vqcsdvigl902kdcqfmyivnxgblrx66l2i")
301 ("chromium-76-gcc-blink-namespace1.patch"
302 "0k7nrn0dhvqxj4sg2gndzxih0l1f77h6pv7jhcdz7h69sm4xci2z")
303 ("chromium-76-gcc-blink-namespace2.patch"
304 "014y2d8ii9sr340sjbv1fhsjd5s3dl0vbmq5wzlkdjsp91dcn9ch")))
306 ;; This is a "computed" origin that does the following:
307 ;; *) Runs the Ungoogled scripts on a pristine Chromium tarball.
308 ;; *) Applies Debians Chromium patches, for their unbundling and GCC work.
309 ;; *) Prunes all third_party directories that are not explicitly preserved.
310 ;; *) Adjusts "GN" build files such that system libraries are preferred.
311 (define ungoogled-chromium-source
312 (let ((chromium-source %chromium-origin)
313 (ungoogled-source %ungoogled-origin)
314 (debian-source %debian-origin))
316 (method computed-origin-method)
317 (file-name (string-append "ungoogled-chromium-" %package-version ".tar.xz"))
321 (with-imported-modules '((guix build utils))
323 (use-modules (guix build utils)
327 (let ((chromium-dir (string-append "chromium-" #$%chromium-version))
328 (preserved-files (list #$@%preserved-third-party-files)))
330 (set-path-environment-variable
332 (list #+(canonical-package patch)
333 #+(canonical-package xz)
334 #+(canonical-package tar)
338 (copy-recursively #+ungoogled-source "/tmp/ungoogled")
340 (with-directory-excursion "/tmp/ungoogled"
342 (format #t "Unpacking chromium tarball...~%")
344 (invoke "tar" "xf" #+chromium-source)
346 ;; Ungoogled-Chromium contains a forked subset of the Debian
347 ;; patches. Disable those, as we apply newer versions later.
348 (substitute* "patches/series"
349 ((".*/debian_buster/.*")
352 (format #t "Ungooglifying...~%")
354 (invoke "python3" "utils/prune_binaries.py" chromium-dir
356 (invoke "python3" "utils/patches.py" "apply"
357 chromium-dir "patches")
358 (invoke "python3" "utils/domain_substitution.py" "apply" "-r"
359 "domain_regex.list" "-f" "domain_substitution.list"
360 "-c" "/tmp/domainscache.tar.gz" chromium-dir)
362 (with-directory-excursion chromium-dir
364 (format #t "applying Debian patches...~%")
366 (let* ((debian #+debian-source)
367 (patches (string-append debian "/debian/patches"))
368 (series (string-append patches "/series")))
369 (with-input-from-file series
371 (let loop ((line (read-line)))
372 (unless (eof-object? line)
373 (when (and (> (string-length line) 1)
374 ;; Skip the Debian-specific ones.
375 (not (string-prefix? "debianization/" line))
376 (not (string-prefix? "buster/" line))
377 ;; And those that conflict with Ungoogled.
378 (not (any (cute string-suffix? <> line)
379 '("widevine-buildflag.patch"
381 "third-party-cookies.patch"
383 ;; XXX: 'fixes/inspector.patch'
384 ;; makes v8 reuse the top-level
385 ;; third_party/inspector_protocol
386 ;; instead of its own bundled copy,
387 ;; but that does not work here for
388 ;; some reason. Ignore that patch
389 ;; and those that depend on it.
390 "wrong-namespace.patch"
391 "explicit-specialization.patch"
392 "inspector.patch"))))
393 (invoke "patch" "--force" "-p1" "--input"
394 (string-append patches "/" line)
395 "--no-backup-if-mismatch"))
396 (loop (read-line)))))))
398 (format #t "Applying Guix-specific patches...~%")
400 (for-each (lambda (patch)
401 (invoke "patch" "--force" "-p1" "--input"
402 patch "--no-backup-if-mismatch"))
403 '#+%auxiliary-patches)
405 (format #t "Pruning third party files...~%")
407 (apply invoke "python"
408 "build/linux/unbundle/remove_bundled_libraries.py"
409 "--do-remove" preserved-files)
411 (format #t "Replacing GN files...~%")
413 (invoke "python3" "build/linux/unbundle/replace_gn_files.py"
414 "--system-libraries" "ffmpeg" "flac" "fontconfig"
415 "freetype" "harfbuzz-ng" "icu" "libdrm" "libevent"
416 "libjpeg" "libpng" "libvpx" "libwebp" "libxml"
417 "libxslt" "openh264" "opus" "re2" "snappy" "yasm"
420 (format #t (string-append "Packing new ungoogled tarball ...~%"))
422 (invoke "tar" "cvfa" #$output
423 ;; Avoid non-determinism in the archive.
433 (package/inherit opus
436 (substitute-keyword-arguments (package-arguments opus)
437 ((#:configure-flags flags ''())
438 ;; Opus Custom is an optional extension of the Opus
439 ;; specification that allows for unsupported frame
440 ;; sizes. Chromium requires that this is enabled.
441 `(cons "--enable-custom-modes"
444 (define-public ungoogled-chromium
446 (name "ungoogled-chromium")
447 (version %package-version)
448 (synopsis "Graphical web browser")
449 (source ungoogled-chromium-source)
450 (build-system gnu-build-system)
453 ;; FIXME: Chromiums RUNPATH lacks entries for some libraries, so
454 ;; we have to disable validation and add a wrapper below.
455 #:validate-runpath? #f
456 #:modules ((guix build gnu-build-system)
462 ;; See tools/gn/docs/cookbook.md and
463 ;; https://www.chromium.org/developers/gn-build-configuration
464 ;; for usage. Run "./gn args . --list" in the Release
465 ;; directory for an exhaustive list of supported flags.
466 ;; (Note: The 'configure' phase will do that for you.)
467 (list "is_debug=false"
470 "linux_use_bundled_binutils=false"
471 "use_custom_libcxx=false"
473 "enable_precompiled_headers=false"
476 "enable_nacl_nonsfi=false"
477 "use_allocator=\"none\""
478 "use_unofficial_version_number=false"
479 "treat_warnings_as_errors=false"
480 "use_official_google_api_keys=false"
481 "fieldtrial_testing_like_official_build=true"
482 "safe_browsing_mode=0"
484 "enable_one_click_signin=false"
485 "enable_reading_list=false"
486 "enable_remoting=false"
487 "enable_reporting=false"
488 "enable_service_discovery=false"
489 "enable_swiftshader=false"
491 "enable_widevine=false"
492 ;; Disable type-checking for the Web UI to avoid a Java dependency.
493 "closure_compile=false"
495 ;; Define a custom toolchain that simply looks up CC, AR and
496 ;; friends from the environment.
497 "custom_toolchain=\"//build/toolchain/linux/unbundle:default\""
498 "host_toolchain=\"//build/toolchain/linux/unbundle:default\""
499 ;; Don't assume it's clang.
501 ;; Disable debugging features to save space. These are normally
502 ;; pulled in by "is_official_build", but that requires "is_clang".
503 "enable_iterator_debugging=false"
504 "exclude_unwind_tables=true"
505 ;; Optimize for building everything at once, as opposed to
506 ;; incrementally for development. See "docs/jumbo.md".
507 "use_jumbo_build=true"
508 ;; The default file merge limit of 50 requires huge amounts of RAM.
509 ;; Cap it to make sure the build succeeds on commodity hardware.
510 "jumbo_file_merge_limit=8"
512 ;; Prefer system libraries.
513 "use_system_freetype=true"
514 "use_system_harfbuzz=true"
515 "use_system_lcms2=true"
516 "use_system_libdrm=true"
517 "use_system_libjpeg=true"
518 "use_system_libopenjpeg2=true"
519 "use_system_libpng=true"
520 "use_system_zlib=true"
521 "use_gnome_keyring=false" ;deprecated by libsecret
523 "use_pulseaudio=true"
524 "link_pulseaudio=true"
526 ;; VA-API acceleration is currently only supported on x86_64-linux.
527 ,@(if (string-prefix? "x86_64" (or (%current-target-system)
532 ;; Do not artifically restrict formats supported by system ffmpeg.
533 "proprietary_codecs=true"
534 "ffmpeg_branding=\"Chrome\""
538 ;; Don't use bundled sources.
539 "rtc_build_json=false"
540 "rtc_build_libevent=false"
541 "rtc_build_libvpx=false"
542 "rtc_build_opus=false"
543 "rtc_build_ssl=false"
544 "rtc_build_libsrtp=true" ;FIXME: fails to find headers
545 "rtc_build_usrsctp=true" ;TODO: package this
546 (string-append "rtc_jsoncpp_root=\""
547 (assoc-ref %build-inputs "jsoncpp")
548 "/include/jsoncpp/json\"")
549 (string-append "rtc_ssl_root=\""
550 (assoc-ref %build-inputs "openssl")
551 "/include/openssl\""))
553 (modify-phases %standard-phases
554 (add-after 'unpack 'patch-stuff
555 (lambda* (#:key inputs #:allow-other-keys)
556 (substitute* "printing/cups_config_helper.py"
558 (string-append "cups_config = '" (assoc-ref inputs "cups")
559 "/bin/cups-config'\n")))
562 '("base/process/launch_posix.cc"
563 "base/third_party/dynamic_annotations/dynamic_annotations.c"
564 "sandbox/linux/seccomp-bpf/sandbox_bpf.cc"
565 "sandbox/linux/services/credentials.cc"
566 "sandbox/linux/services/namespace_utils.cc"
567 "sandbox/linux/services/syscall_wrappers.cc"
568 "sandbox/linux/syscall_broker/broker_host.cc")
569 (("include \"base/third_party/valgrind/") "include \"valgrind/"))
571 (for-each (lambda (file)
573 ;; Fix opus include path.
574 ;; Do not substitute opus_private.h.
575 (("#include \"opus\\.h\"")
576 "#include \"opus/opus.h\"")
577 (("#include \"opus_custom\\.h\"")
578 "#include \"opus/opus_custom.h\"")
579 (("#include \"opus_defines\\.h\"")
580 "#include \"opus/opus_defines.h\"")
581 (("#include \"opus_multistream\\.h\"")
582 "#include \"opus/opus_multistream.h\"")
583 (("#include \"opus_types\\.h\"")
584 "#include \"opus/opus_types.h\"")))
585 (find-files (string-append "third_party/webrtc/modules"
586 "/audio_coding/codecs/opus")))
588 (substitute* "chrome/common/chrome_paths.cc"
589 (("/usr/share/chromium/extensions")
590 ;; TODO: Add ~/.guix-profile.
591 "/run/current-system/profile/share/chromium/extensions"))
593 ;; XXX: Should be unnecessary when use_system_lcms2=true.
594 (substitute* "third_party/pdfium/core/fxcodec/codec/ccodec_iccmodule.h"
595 (("include \"third_party/lcms/include/lcms2\\.h\"")
596 "include \"lcms2.h\""))
599 "third_party/breakpad/breakpad/src/common/linux/libcurl_wrapper.h"
600 (("include \"third_party/curl") "include \"curl"))
602 (substitute* "third_party/webrtc/rtc_base/strings/json.h"
603 (("#include \"third_party/jsoncpp/") "#include \"json/"))
605 (substitute* '("components/viz/common/gpu/vulkan_context_provider.h"
606 "components/viz/common/resources/resource_format_utils.h")
607 (("third_party/vulkan/include/") ""))
609 (substitute* "third_party/skia/include/gpu/vk/GrVkVulkan.h"
610 (("include/third_party/vulkan/") ""))
612 ;; Building chromedriver embeds some files using the ZIP
613 ;; format which doesn't support timestamps before
614 ;; 1980. Therefore, advance the timestamps of the files
615 ;; which are included so that building chromedriver
617 (let ((circa-1980 (* 10 366 24 60 60)))
618 (for-each (lambda (file)
619 (utime file circa-1980 circa-1980))
620 '("chrome/test/chromedriver/extension/background.js"
621 "chrome/test/chromedriver/extension/manifest.json")))
624 (add-before 'configure 'prepare-build-environment
625 (lambda* (#:key inputs #:allow-other-keys)
627 ;; Make sure the right build tools are used.
628 (setenv "AR" "ar") (setenv "NM" "nm")
629 (setenv "CC" "gcc") (setenv "CXX" "g++")
631 ;; Prevent GCC from optimizing away null pointer safety checks.
632 (setenv "CXXFLAGS" "-fno-delete-null-pointer-checks")
634 ;; Work around <https://bugs.gnu.org/30756>.
635 (unsetenv "C_INCLUDE_PATH")
636 (unsetenv "CPLUS_INCLUDE_PATH")
638 ;; TODO: pre-compile instead. Avoids a race condition.
639 (setenv "PYTHONDONTWRITEBYTECODE" "1")
641 ;; XXX: How portable is this.
642 (mkdir-p "third_party/node/linux/node-linux-x64")
643 (symlink (string-append (assoc-ref inputs "node") "/bin")
644 "third_party/node/linux/node-linux-x64/bin")
648 (lambda* (#:key configure-flags #:allow-other-keys)
649 (let ((args (string-join configure-flags " ")))
650 ;; Generate ninja build files.
651 (invoke "gn" "gen" "out/Release"
652 (string-append "--args=" args))
654 ;; Print the full list of supported arguments as well as
655 ;; their current status for convenience.
656 (format #t "Dumping configure flags...\n")
657 (invoke "gn" "args" "out/Release" "--list"))))
659 (lambda* (#:key (parallel-build? #t) #:allow-other-keys)
660 (invoke "ninja" "-C" "out/Release"
661 "-j" (if parallel-build?
662 (number->string (parallel-job-count))
667 (lambda* (#:key inputs outputs #:allow-other-keys)
668 (let* ((out (assoc-ref outputs "out"))
669 (bin (string-append out "/bin"))
670 (exe (string-append bin "/chromium"))
671 (lib (string-append out "/lib"))
672 (man (string-append out "/share/man/man1"))
673 (applications (string-append out "/share/applications"))
674 (install-regexp (make-regexp "\\.(bin|pak)$"))
675 (locales (string-append lib "/locales"))
676 (resources (string-append lib "/resources"))
677 (preferences (assoc-ref inputs "master-preferences"))
678 (gtk+ (assoc-ref inputs "gtk+"))
679 (mesa (assoc-ref inputs "mesa"))
680 (nss (assoc-ref inputs "nss"))
681 (udev (assoc-ref inputs "udev"))
684 (substitute* '("chrome/app/resources/manpage.1.in"
685 "chrome/installer/linux/common/desktop.template")
686 (("@@MENUNAME@@") "Chromium")
687 (("@@PACKAGE@@") "chromium")
688 (("/usr/bin/@@USR_BIN_SYMLINK_NAME@@") exe))
691 (copy-file "chrome/app/resources/manpage.1.in"
692 (string-append man "/chromium.1"))
694 (mkdir-p applications)
695 (copy-file "chrome/installer/linux/common/desktop.template"
696 (string-append applications "/chromium.desktop"))
699 (copy-file preferences (string-append lib "/master_preferences"))
701 (with-directory-excursion "out/Release"
702 (for-each (lambda (file)
703 (install-file file lib))
704 (scandir "." (cut regexp-exec install-regexp <>)))
705 (copy-file "chrome" (string-append lib "/chromium"))
707 (copy-recursively "locales" locales)
708 (copy-recursively "resources" resources)
711 (symlink "../lib/chromium" exe)
712 (install-file "chromedriver" bin)
715 ;; TODO: Get these in RUNPATH.
716 `("LD_LIBRARY_PATH" ":" prefix
717 (,(string-append lib ":" nss "/lib/nss:" mesa "/lib:"
719 ;; Avoid file manager crash. See <https://bugs.gnu.org/26593>.
720 `("XDG_DATA_DIRS" ":" prefix (,(string-append gtk+ "/share")))))
722 (with-directory-excursion "chrome/app/theme/chromium"
725 (let ((icons (string-append out "/share/icons/hicolor/"
726 size "x" size "/apps")))
728 (copy-file (string-append "product_logo_" size ".png")
729 (string-append icons "/chromium.png"))))
730 '("22" "24" "48" "64" "128" "256")))
739 ("pkg-config" ,pkg-config)
743 ;; This file contains defaults for new user profiles.
744 ("master-preferences" ,(local-file "aux-files/chromium/master-preferences.json"))
746 ("python-beautifulsoup4" ,python2-beautifulsoup4)
747 ("python-html5lib" ,python2-html5lib)
748 ("python" ,python-2)))
750 `(("alsa-lib" ,alsa-lib)
755 ("dbus-glib" ,dbus-glib)
759 ("fontconfig" ,fontconfig)
760 ("freetype" ,freetype)
761 ("gdk-pixbuf" ,gdk-pixbuf)
764 ("harfbuzz" ,harfbuzz)
768 ("libevent" ,libevent)
770 ("libjpeg-turbo" ,libjpeg-turbo)
777 ("libxcomposite" ,libxcomposite)
778 ("libxcursor" ,libxcursor)
779 ("libxdamage" ,libxdamage)
781 ("libxfixes" ,libxfixes)
784 ("libxrandr" ,libxrandr)
785 ("libxrender" ,libxrender)
786 ("libxscrnsaver" ,libxscrnsaver)
791 ("mit-krb5" ,mit-krb5)
793 ("openh264" ,openh264)
794 ("openjpeg" ,openjpeg) ;PDFium only
796 ("opus" ,opus+custom)
798 ("pciutils" ,pciutils)
799 ("pulseaudio" ,pulseaudio)
802 ("speech-dispatcher" ,speech-dispatcher)
804 ("valgrind" ,valgrind)
805 ("vulkan-headers" ,vulkan-headers)))
807 ;; Building Chromium takes ... a very long time. On a single core, a busy
808 ;; mid-end x86 system may need more than 24 hours to complete the build.
809 (properties '((timeout . 144000))) ;40 hours
811 (home-page "https://github.com/Eloston/ungoogled-chromium")
813 "Ungoogled-Chromium is the Chromium web browser, with some functionality
814 disabled in order to protect the users privacy.")
815 ;; Chromium is developed as BSD-3, but bundles a large number of third-party
816 ;; components with other licenses. For full information, see chrome://credits.
817 (license (list license:bsd-3
823 license:public-domain
825 (license:non-copyleft "chrome://credits"
826 "See chrome://credits for more information.")
829 (define-public ungoogled-chromium/wayland
830 (package/inherit ungoogled-chromium
831 (name "ungoogled-chromium-wayland")
833 `(("wayland" ,wayland)
834 ("wayland-protocols" ,wayland-protocols)
835 ;; Remove inputs only needed for X11.
836 ,@(fold alist-delete (package-inputs ungoogled-chromium)
837 '("libx11" "libxcb" "libxcomposite" "libxcursor"
838 "libxdamage" "libxext" "libxfixes" "libxi"
839 "libxrender" "libxtst" "libxext" "libxrandr"
843 (substitute-keyword-arguments (package-arguments ungoogled-chromium)
844 ((#:configure-flags flags)
845 `(append (list "use_ozone=true"
846 "ozone_platform_wayland=true"
847 "ozone_auto_platforms=false"
849 "use_system_minigbm=true"
850 "use_system_libwayland=true"
851 (string-append "system_wayland_scanner_path=\""
852 (assoc-ref %build-inputs "wayland")
853 "/bin/wayland-scanner\""))
854 (delete "use_vaapi=true" ,flags)))))))