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))
74 (define %preserved-third-party-files
75 '("base/third_party/cityhash" ;Expat
76 "base/third_party/double_conversion" ;BSD-3
77 "base/third_party/dynamic_annotations" ;BSD-2
78 "base/third_party/icu" ;Unicode, X11-style
79 "base/third_party/superfasthash" ;BSD-3
80 "base/third_party/symbolize" ;BSD-3
81 "base/third_party/xdg_mime" ;LGPL2.0+ or Academic 2.0
82 "base/third_party/xdg_user_dirs" ;Expat
83 "chrome/third_party/mozilla_security_manager" ;MPL-1.1/GPL2+/LGPL2.1+
84 "courgette/third_party/bsdiff" ;BSD-2, BSD protection license
85 "courgette/third_party/divsufsort" ;Expat
86 "net/third_party/mozilla_security_manager" ;MPL-1.1/GPL2+/LGPL2.1+
87 "net/third_party/nss" ;MPL-2.0
88 "net/third_party/quiche" ;BSD-3
89 "net/third_party/uri_template" ;ASL2.0
90 "third_party/abseil-cpp" ;ASL2.0
91 "third_party/adobe/flash/flapper_version.h" ;no license, trivial
92 "third_party/angle" ;BSD-3
93 "third_party/angle/src/common/third_party/base" ;BSD-3
94 "third_party/angle/src/common/third_party/smhasher" ;Public domain
95 "third_party/angle/src/common/third_party/xxhash" ;BSD-2
96 "third_party/angle/src/third_party/compiler" ;BSD-2
97 "third_party/angle/src/third_party/libXNVCtrl" ;Expat
98 "third_party/angle/src/third_party/trace_event" ;BSD-3
99 "third_party/angle/third_party/vulkan-headers" ;ASL2.0
100 "third_party/angle/third_party/vulkan-loader" ;ASL2.0
101 "third_party/angle/third_party/vulkan-tools" ;ASL2.0
102 "third_party/angle/third_party/vulkan-validation-layers" ;ASL2.0
103 "third_party/apple_apsl" ;APSL2.0
104 "third_party/axe-core" ;MPL2.0
105 "third_party/blink" ;BSD-3, LGPL2+
106 "third_party/boringssl" ;OpenSSL/ISC (Google additions are ISC)
107 "third_party/boringssl/src/third_party/fiat" ;Expat
108 "third_party/boringssl/src/third_party/sike" ;Expat
109 ;; XXX: these files are generated by fp-$arch.pl in the above directory.
110 "third_party/boringssl/linux-aarch64/crypto/third_party/sike/asm/fp-armv8.S"
111 "third_party/boringssl/linux-x86_64/crypto/third_party/sike/asm/fp-x86_64.S"
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 "third_party/catapult/tracing/third_party/d3" ;BSD-3
120 "third_party/catapult/tracing/third_party/gl-matrix" ;Expat
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 "third_party/catapult/tracing/third_party/pako" ;Expat
125 "third_party/ced" ;BSD-3
126 "third_party/cld_3" ;ASL2.0
127 "third_party/closure_compiler" ;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/depot_tools/owners.py" ;BSD-3
136 "third_party/dom_distiller_js" ;BSD-3
137 "third_party/emoji-segmenter" ;ASL2.0
138 "third_party/flatbuffers" ;ASL2.0
139 "third_party/glslang" ;BSD-3, Expat, ASL2.0
140 "third_party/google_input_tools" ;ASL2.0
141 "third_party/google_input_tools/third_party/closure_library" ;ASL2.0
142 "third_party/google_input_tools/third_party/closure_library/third_party/closure" ;Expat
143 "third_party/googletest" ;BSD-3
144 "third_party/hunspell" ;MPL1.1/GPL2+/LGPL2.1+
145 "third_party/iccjpeg" ;IJG
146 "third_party/inspector_protocol" ;BSD-3
147 "third_party/jinja2" ;BSD-3
148 "third_party/jstemplate" ;ASL2.0
149 "third_party/khronos" ;Expat, SGI
150 "third_party/leveldatabase" ;BSD-3
151 "third_party/libXNVCtrl" ;Expat
152 "third_party/libaddressinput" ;ASL2.0
153 "third_party/libaom" ;BSD-2 or "Alliance for Open Media Patent License 1.0"
154 "third_party/libaom/source/libaom/third_party/vector" ;Expat
155 "third_party/libaom/source/libaom/third_party/x86inc" ;ISC
156 "third_party/libjingle_xmpp" ;BSD-3
157 "third_party/libphonenumber" ;ASL2.0
158 "third_party/libsecret" ;LGPL2.1+
159 "third_party/libsrtp" ;BSD-3
160 "third_party/libsync" ;ASL2.0
161 "third_party/libudev" ;LGPL2.1+
162 "third_party/libwebm" ;BSD-3
163 "third_party/libxml/chromium" ;BSD-3
164 "third_party/libyuv" ;BSD-3
165 "third_party/lss" ;BSD-3
166 "third_party/markupsafe" ;BSD-3
167 "third_party/mesa_headers" ;Expat, SGI
168 "third_party/metrics_proto" ;BSD-3
169 "third_party/modp_b64" ;BSD-3
170 "third_party/nasm" ;BSD-2
171 "third_party/node" ;Expat
172 "third_party/node/node_modules/polymer-bundler/lib/third_party/UglifyJS2" ;BSD-2
173 "third_party/one_euro_filter" ;BSD-3
174 "third_party/openscreen" ;BSD-3
175 "third_party/openscreen/src/third_party/tinycbor" ;Expat
176 "third_party/ots" ;BSD-3
177 "third_party/pdfium" ;BSD-3
178 "third_party/pdfium/third_party/agg23" ;Expat
179 "third_party/pdfium/third_party/base" ;BSD-3
180 "third_party/pdfium/third_party/bigint" ;Public domain, BSD-3
181 "third_party/pdfium/third_party/skia_shared" ;BSD-3
182 "third_party/pdfium/third_party/freetype/include/pstables.h" ;FreeType
183 "third_party/pffft" ;the "FFTPACK" license, similar to BSD-3
184 "third_party/ply" ;BSD-3
185 "third_party/polymer" ;BSD-3
186 "third_party/private-join-and-compute" ;ASL2.0
187 "third_party/protobuf" ;BSD-3
188 "third_party/protobuf/third_party/six" ;Expat
189 "third_party/pyjson5" ;ASL2.0
190 "third_party/qcms" ;Expat
191 "third_party/rnnoise" ;BSD-3
192 "third_party/s2cellid" ;ASL2.0
193 "third_party/sfntly" ;ASL2.0
194 "third_party/skia" ;BSD-3
195 "third_party/skia/include/third_party/skcms" ;BSD-3
196 "third_party/skia/third_party/gif" ;MPL1.1/GPL2+/LGPL2.1+
197 "third_party/skia/third_party/skcms" ;BSD-3
198 "third_party/skia/third_party/vulkanmemoryallocator" ;BSD-3, Expat
199 "third_party/smhasher" ;Expat, public domain
200 "third_party/speech-dispatcher" ;GPL2+
201 "third_party/spirv-headers" ;ASL2.0
202 "third_party/SPIRV-Tools" ;ASL2.0
203 "third_party/sqlite" ;Public domain
204 "third_party/ungoogled" ;BSD-3
205 "third_party/usb_ids" ;BSD-3
206 "third_party/usrsctp" ;BSD-2
207 "third_party/wayland/wayland_scanner_wrapper.py" ;BSD-3
208 "third_party/wayland-protocols" ;Expat
209 "third_party/web-animations-js" ;ASL2.0
210 "third_party/webdriver" ;ASL2.0
211 "third_party/webrtc" ;BSD-3
212 "third_party/webrtc/common_audio/third_party/fft4g" ;Non-copyleft
213 "third_party/webrtc/common_audio/third_party/spl_sqrt_floor" ;Public domain
214 "third_party/webrtc/modules/third_party/fft" ;Non-copyleft
215 "third_party/webrtc/modules/third_party/g711" ;Public domain
216 "third_party/webrtc/modules/third_party/g722" ;Public domain
217 "third_party/webrtc/rtc_base/third_party/base64" ;Non-copyleft
218 "third_party/webrtc/rtc_base/third_party/sigslot" ;Public domain
219 "third_party/widevine/cdm/widevine_cdm_version.h" ;BSD-3
220 "third_party/widevine/cdm/widevine_cdm_common.h" ;BSD-3
221 "third_party/woff2" ;ASL2.0
222 "third_party/xdg-utils" ;Expat
223 "third_party/yasm/run_yasm.py" ;BSD-2 or BSD-3
224 "third_party/zlib/google" ;BSD-3
225 "url/third_party/mozilla" ;BSD-3, MPL1.1/GPL2+/LGPL2.1+
226 "v8/src/third_party/siphash" ;Public domain
227 "v8/src/third_party/utf8-decoder" ;Expat
228 "v8/src/third_party/valgrind" ;BSD-4
229 "v8/third_party/inspector_protocol" ;BSD-3
230 "v8/third_party/v8/builtins")) ;PSFL
232 (define* (computed-origin-method gexp-promise hash-algo hash
233 #:optional (name "source")
234 #:key (system (%current-system))
235 (guile (default-guile)))
236 "Return a derivation that executes the G-expression that results
237 from forcing GEXP-PROMISE."
238 (mlet %store-monad ((guile (package->derivation guile system)))
239 (gexp->derivation (or name "computed-origin")
241 #:graft? #f ;nothing to graft
243 #:guile-for-build guile)))
245 (define %chromium-version "78.0.3904.108")
246 (define %ungoogled-revision "8f065138317a6152b20decc224027a5192ba76b1")
247 (define %debian-revision "e43d74632091324774a5049668782dba7b09cf72")
248 (define package-revision "0")
249 (define %package-version (string-append %chromium-version "-"
251 (string-take %ungoogled-revision 7)))
253 (define %chromium-origin
256 (uri (string-append "https://commondatastorage.googleapis.com"
257 "/chromium-browser-official/chromium-"
258 %chromium-version ".tar.xz"))
261 "03jvfz68nvmmrplygf96sh0l347p4h03c8vpw8yrglh6ycwkiigr"))))
263 (define %ungoogled-origin
266 (uri (git-reference (url "https://github.com/Eloston/ungoogled-chromium")
267 (commit %ungoogled-revision)))
268 (file-name (git-file-name "ungoogled-chromium"
269 (string-take %ungoogled-revision 7)))
272 "0zix90jz82hpym9jmyf99yw19swaf13ps6szi60wccmz1gccv77g"))))
274 (define %debian-origin
278 (url "https://salsa.debian.org/chromium-team/chromium.git")
279 (commit %debian-revision)))
280 (file-name (git-file-name "debian-chromium-packaging"
281 (if (string-prefix? "debian/" %debian-revision)
282 (cadr (string-split %debian-revision #\/))
283 (string-take %debian-revision 7))))
286 "1l1ajjkn1y7ql5w4zb3c3vw57hkydvy1mac7y81rycx4g5djasaz"))))
288 (define (gentoo-patch name hash revision)
291 (uri (string-append "https://gitweb.gentoo.org/repo/gentoo.git/plain"
292 "/www-client/chromium/files/" name "?id=" revision))
294 (sha256 (base32 hash))))
296 ;; This is a "computed" origin that does the following:
297 ;; *) Runs the Ungoogled scripts on a pristine Chromium tarball.
298 ;; *) Applies Debians Chromium patches, for their unbundling and GCC work.
299 ;; *) Prunes all third_party directories that are not explicitly preserved.
300 ;; *) Adjusts "GN" build files such that system libraries are preferred.
301 (define ungoogled-chromium-source
302 (let ((chromium-source %chromium-origin)
303 (ungoogled-source %ungoogled-origin)
304 (debian-source %debian-origin))
306 (method computed-origin-method)
307 (file-name (string-append "ungoogled-chromium-" %package-version ".tar.xz"))
311 (with-imported-modules '((guix build utils))
313 (use-modules (guix build utils)
317 (let ((chromium-dir (string-append "chromium-" #$%chromium-version))
318 (preserved-files (list #$@%preserved-third-party-files)))
320 (set-path-environment-variable
322 (list #+(canonical-package patch)
323 #+(canonical-package xz)
324 #+(canonical-package tar)
328 (copy-recursively #+ungoogled-source "/tmp/ungoogled")
330 (with-directory-excursion "/tmp/ungoogled"
332 (format #t "Unpacking chromium tarball...~%")
334 (invoke "tar" "xf" #+chromium-source)
336 ;; Ungoogled-Chromium contains a forked subset of the Debian
337 ;; patches. Disable those, as we apply newer versions later.
338 (substitute* "patches/series"
339 ((".*/debian_buster/.*")
342 (format #t "Ungooglifying...~%")
344 (invoke "python3" "utils/prune_binaries.py" chromium-dir
346 (invoke "python3" "utils/patches.py" "apply"
347 chromium-dir "patches")
348 (invoke "python3" "utils/domain_substitution.py" "apply" "-r"
349 "domain_regex.list" "-f" "domain_substitution.list"
350 "-c" "/tmp/domainscache.tar.gz" chromium-dir)
352 (with-directory-excursion chromium-dir
354 (format #t "applying Debian patches...~%")
356 (let* ((debian #+debian-source)
357 (patches (string-append debian "/debian/patches"))
358 (series (string-append patches "/series")))
359 (with-input-from-file series
361 (let loop ((line (read-line)))
362 (unless (eof-object? line)
363 (when (and (> (string-length line) 1)
364 ;; Skip the Debian-specific ones.
365 (not (string-prefix? "debianization/" line))
366 (not (string-prefix? "buster/" line))
367 (not (any (cute string-suffix? <> line)
368 ;; These conflict with Ungoogled.
369 '("widevine-buildflag.patch"
371 "third-party-cookies.patch"
373 ;; Disable workarounds for the
374 ;; Chromium "-lite" tarball. We
375 ;; use the "full" version and don't
376 ;; need these patches.
380 ;; XXX: 'fixes/inspector.patch'
381 ;; makes v8 reuse the top-level
382 ;; third_party/inspector_protocol
383 ;; instead of its own bundled copy,
384 ;; but that does not work here for
385 ;; some reason. Ignore that patch
386 ;; and those that depend on it.
387 "inspector.patch"))))
388 (invoke "patch" "--force" "-p1" "--input"
389 (string-append patches "/" line)
390 "--no-backup-if-mismatch"))
391 (loop (read-line)))))))
393 (format #t "Pruning third party files...~%")
395 (apply invoke "python"
396 "build/linux/unbundle/remove_bundled_libraries.py"
397 "--do-remove" preserved-files)
399 (format #t "Replacing GN files...~%")
401 (invoke "python3" "build/linux/unbundle/replace_gn_files.py"
402 "--system-libraries" "ffmpeg" "flac" "fontconfig"
403 "freetype" "harfbuzz-ng" "icu" "libdrm" "libevent"
404 "libjpeg" "libpng" "libvpx" "libwebp" "libxml"
405 "libxslt" "openh264" "opus" "re2" "snappy" "yasm"
408 (format #t (string-append "Packing new ungoogled tarball ...~%"))
410 (invoke "tar" "cvfa" #$output
411 ;; Avoid non-determinism in the archive.
421 (package/inherit opus
424 (substitute-keyword-arguments (package-arguments opus)
425 ((#:configure-flags flags ''())
426 ;; Opus Custom is an optional extension of the Opus
427 ;; specification that allows for unsupported frame
428 ;; sizes. Chromium requires that this is enabled.
429 `(cons "--enable-custom-modes"
432 ;; Chromium 78 requires libvpx features that are not in any release.
433 (define libvpx/chromium
438 (inherit (package-source libvpx))
440 (url "https://chromium.googlesource.com/webm/libvpx")
442 (file-name (git-file-name "libvpx" version))
445 "1pphjfmg0aqq93n5cq790884v1h84di8p9mk3r28sm053wszhm7g"))))))
447 (define-public ungoogled-chromium
449 (name "ungoogled-chromium")
450 (version %package-version)
451 (synopsis "Graphical web browser")
452 (source ungoogled-chromium-source)
453 (build-system gnu-build-system)
456 ;; FIXME: Chromiums RUNPATH lacks entries for some libraries, so
457 ;; we have to disable validation and add a wrapper below.
458 #:validate-runpath? #f
459 #:modules ((guix build gnu-build-system)
465 ;; See tools/gn/docs/cookbook.md and
466 ;; https://www.chromium.org/developers/gn-build-configuration
467 ;; for usage. Run "./gn args . --list" in the Release
468 ;; directory for an exhaustive list of supported flags.
469 ;; (Note: The 'configure' phase will do that for you.)
470 (list "is_debug=false"
473 "linux_use_bundled_binutils=false"
474 "use_custom_libcxx=false"
476 "enable_precompiled_headers=false"
479 "enable_nacl_nonsfi=false"
480 "use_allocator=\"none\""
481 "use_unofficial_version_number=false"
482 "treat_warnings_as_errors=false"
483 "use_official_google_api_keys=false"
484 "fieldtrial_testing_like_official_build=true"
485 "safe_browsing_mode=0"
487 "enable_one_click_signin=false"
488 "enable_reading_list=false"
489 "enable_remoting=false"
490 "enable_reporting=false"
491 "enable_service_discovery=false"
492 "enable_swiftshader=false"
494 "enable_widevine=false"
495 ;; Disable type-checking for the Web UI to avoid a Java dependency.
496 "closure_compile=false"
498 ;; Define a custom toolchain that simply looks up CC, AR and
499 ;; friends from the environment.
500 "custom_toolchain=\"//build/toolchain/linux/unbundle:default\""
501 "host_toolchain=\"//build/toolchain/linux/unbundle:default\""
502 ;; Don't assume it's clang.
504 ;; Disable debugging features to save space. These are normally
505 ;; pulled in by "is_official_build", but that requires "is_clang".
506 "enable_iterator_debugging=false"
507 "exclude_unwind_tables=true"
508 ;; Optimize for building everything at once, as opposed to
509 ;; incrementally for development. See "docs/jumbo.md".
510 "use_jumbo_build=true"
511 ;; The default file merge limit of 50 requires huge amounts of RAM.
512 ;; Cap it to make sure the build succeeds on commodity hardware.
513 "jumbo_file_merge_limit=8"
515 ;; Prefer system libraries.
516 "use_system_freetype=true"
517 "use_system_harfbuzz=true"
518 "use_system_lcms2=true"
519 "use_system_libdrm=true"
520 "use_system_libjpeg=true"
521 "use_system_libopenjpeg2=true"
522 "use_system_libpng=true"
523 "use_system_zlib=true"
524 "use_gnome_keyring=false" ;deprecated by libsecret
526 "use_pulseaudio=true"
527 "link_pulseaudio=true"
529 ;; VA-API acceleration is currently only supported on x86_64-linux.
530 ,@(if (string-prefix? "x86_64" (or (%current-target-system)
535 ;; Do not artifically restrict formats supported by system ffmpeg.
536 "proprietary_codecs=true"
537 "ffmpeg_branding=\"Chrome\""
541 ;; Don't use bundled sources.
542 "rtc_build_json=false"
543 "rtc_build_libevent=false"
544 "rtc_build_libvpx=false"
545 "rtc_build_opus=false"
546 "rtc_build_ssl=false"
547 "rtc_build_libsrtp=true" ;FIXME: fails to find headers
548 "rtc_build_usrsctp=true" ;TODO: package this
549 (string-append "rtc_jsoncpp_root=\""
550 (assoc-ref %build-inputs "jsoncpp")
551 "/include/jsoncpp/json\"")
552 (string-append "rtc_ssl_root=\""
553 (assoc-ref %build-inputs "openssl")
554 "/include/openssl\""))
556 (modify-phases %standard-phases
557 (add-after 'unpack 'patch-stuff
558 (lambda* (#:key inputs #:allow-other-keys)
559 (substitute* "printing/cups_config_helper.py"
561 (string-append "cups_config = '" (assoc-ref inputs "cups")
562 "/bin/cups-config'\n")))
565 '("base/process/launch_posix.cc"
566 "base/third_party/dynamic_annotations/dynamic_annotations.c"
567 "sandbox/linux/seccomp-bpf/sandbox_bpf.cc"
568 "sandbox/linux/services/credentials.cc"
569 "sandbox/linux/services/namespace_utils.cc"
570 "sandbox/linux/services/syscall_wrappers.cc"
571 "sandbox/linux/syscall_broker/broker_host.cc")
572 (("include \"base/third_party/valgrind/") "include \"valgrind/"))
574 (for-each (lambda (file)
576 ;; Fix opus include path.
577 ;; Do not substitute opus_private.h.
578 (("#include \"opus\\.h\"")
579 "#include \"opus/opus.h\"")
580 (("#include \"opus_custom\\.h\"")
581 "#include \"opus/opus_custom.h\"")
582 (("#include \"opus_defines\\.h\"")
583 "#include \"opus/opus_defines.h\"")
584 (("#include \"opus_multistream\\.h\"")
585 "#include \"opus/opus_multistream.h\"")
586 (("#include \"opus_types\\.h\"")
587 "#include \"opus/opus_types.h\"")))
588 (find-files (string-append "third_party/webrtc/modules"
589 "/audio_coding/codecs/opus")))
591 (substitute* "chrome/common/chrome_paths.cc"
592 (("/usr/share/chromium/extensions")
593 ;; TODO: Add ~/.guix-profile.
594 "/run/current-system/profile/share/chromium/extensions"))
596 ;; Many files try to include ICU headers from "third_party/icu/...".
597 ;; Remove the "third_party/" prefix to use system headers instead.
598 (substitute* (find-files "chrome" "\\.cc$")
599 (("third_party/icu/source/(common|i18n)/")
602 ;; XXX: Should be unnecessary when use_system_lcms2=true.
603 (substitute* "third_party/pdfium/core/fxcodec/icc/iccmodule.h"
604 (("include \"third_party/lcms/include/lcms2\\.h\"")
605 "include \"lcms2.h\""))
608 "third_party/breakpad/breakpad/src/common/linux/libcurl_wrapper.h"
609 (("include \"third_party/curl") "include \"curl"))
611 (substitute* "third_party/webrtc/rtc_base/strings/json.h"
612 (("#include \"third_party/jsoncpp/") "#include \"json/"))
614 (substitute* '("components/viz/common/gpu/vulkan_context_provider.h"
615 "components/viz/common/resources/resource_format_utils.h")
616 (("third_party/vulkan/include/") ""))
618 (substitute* "third_party/skia/include/gpu/vk/GrVkVulkan.h"
619 (("include/third_party/vulkan/") ""))
621 ;; Building chromedriver embeds some files using the ZIP
622 ;; format which doesn't support timestamps before
623 ;; 1980. Therefore, advance the timestamps of the files
624 ;; which are included so that building chromedriver
626 (let ((circa-1980 (* 10 366 24 60 60)))
627 (for-each (lambda (file)
628 (utime file circa-1980 circa-1980))
629 '("chrome/test/chromedriver/extension/background.js"
630 "chrome/test/chromedriver/extension/manifest.json")))
633 (add-before 'configure 'prepare-build-environment
634 (lambda* (#:key inputs #:allow-other-keys)
636 ;; Make sure the right build tools are used.
637 (setenv "AR" "ar") (setenv "NM" "nm")
638 (setenv "CC" "gcc") (setenv "CXX" "g++")
640 ;; Prevent GCC from optimizing away null pointer safety checks.
641 (setenv "CXXFLAGS" "-fno-delete-null-pointer-checks")
643 ;; TODO: pre-compile instead. Avoids a race condition.
644 (setenv "PYTHONDONTWRITEBYTECODE" "1")
646 ;; XXX: How portable is this.
647 (mkdir-p "third_party/node/linux/node-linux-x64")
648 (symlink (string-append (assoc-ref inputs "node") "/bin")
649 "third_party/node/linux/node-linux-x64/bin")
653 (lambda* (#:key configure-flags #:allow-other-keys)
654 (let ((args (string-join configure-flags " ")))
655 ;; Generate ninja build files.
656 (invoke "gn" "gen" "out/Release"
657 (string-append "--args=" args))
659 ;; Print the full list of supported arguments as well as
660 ;; their current status for convenience.
661 (format #t "Dumping configure flags...\n")
662 (invoke "gn" "args" "out/Release" "--list"))))
663 (add-before 'build 'increase-resource-limits
665 ;; XXX: Chromiums linking step requires a lot of simultaneous file
666 ;; accesses. Having a too low ulimit will result in bogus linker
667 ;; errors such as "foo.a: error adding symbols: malformed archive".
669 ;; Try increasing the soft resource limit of max open files to 4096,
670 ;; or equal to the hard limit, whichever is lower.
671 (call-with-values (lambda () (getrlimit 'nofile))
673 (when (and soft (< soft 4096))
675 (setrlimit 'nofile (min hard 4096) hard)
676 (setrlimit 'nofile 4096 #f))
678 "increased maximum number of open files from ~d to ~d~%"
679 soft (if hard (min hard 4096) 4096)))))
682 (lambda* (#:key (parallel-build? #t) #:allow-other-keys)
683 (invoke "ninja" "-C" "out/Release"
684 "-j" (if parallel-build?
685 (number->string (parallel-job-count))
690 (lambda* (#:key inputs outputs #:allow-other-keys)
691 (let* ((out (assoc-ref outputs "out"))
692 (bin (string-append out "/bin"))
693 (exe (string-append bin "/chromium"))
694 (lib (string-append out "/lib"))
695 (man (string-append out "/share/man/man1"))
696 (applications (string-append out "/share/applications"))
697 (install-regexp (make-regexp "\\.(bin|pak)$"))
698 (locales (string-append lib "/locales"))
699 (resources (string-append lib "/resources"))
700 (preferences (assoc-ref inputs "master-preferences"))
701 (gtk+ (assoc-ref inputs "gtk+"))
702 (mesa (assoc-ref inputs "mesa"))
703 (nss (assoc-ref inputs "nss"))
704 (udev (assoc-ref inputs "udev"))
707 (substitute* '("chrome/app/resources/manpage.1.in"
708 "chrome/installer/linux/common/desktop.template")
709 (("@@MENUNAME@@") "Chromium")
710 (("@@PACKAGE@@") "chromium")
711 (("/usr/bin/@@USR_BIN_SYMLINK_NAME@@") exe))
714 (copy-file "chrome/app/resources/manpage.1.in"
715 (string-append man "/chromium.1"))
717 (mkdir-p applications)
718 (copy-file "chrome/installer/linux/common/desktop.template"
719 (string-append applications "/chromium.desktop"))
722 (copy-file preferences (string-append lib "/master_preferences"))
724 (with-directory-excursion "out/Release"
725 (for-each (lambda (file)
726 (install-file file lib))
727 (scandir "." (cut regexp-exec install-regexp <>)))
728 (copy-file "chrome" (string-append lib "/chromium"))
730 (copy-recursively "locales" locales)
731 (copy-recursively "resources" resources)
734 (symlink "../lib/chromium" exe)
735 (install-file "chromedriver" bin)
738 ;; TODO: Get these in RUNPATH.
739 `("LD_LIBRARY_PATH" ":" prefix
740 (,(string-append lib ":" nss "/lib/nss:" mesa "/lib:"
742 ;; Avoid file manager crash. See <https://bugs.gnu.org/26593>.
743 `("XDG_DATA_DIRS" ":" prefix (,(string-append gtk+ "/share")))))
745 (with-directory-excursion "chrome/app/theme/chromium"
748 (let ((icons (string-append out "/share/icons/hicolor/"
749 size "x" size "/apps")))
751 (copy-file (string-append "product_logo_" size ".png")
752 (string-append icons "/chromium.png"))))
753 '("24" "48" "64" "128" "256")))
762 ("pkg-config" ,pkg-config)
766 ;; This file contains defaults for new user profiles.
767 ("master-preferences" ,(local-file "aux-files/chromium/master-preferences.json"))
769 ("python-beautifulsoup4" ,python2-beautifulsoup4)
770 ("python-html5lib" ,python2-html5lib)
771 ("python" ,python-2)))
773 `(("alsa-lib" ,alsa-lib)
778 ("dbus-glib" ,dbus-glib)
782 ("fontconfig" ,fontconfig)
783 ("freetype" ,freetype)
784 ("gdk-pixbuf" ,gdk-pixbuf)
787 ("harfbuzz" ,harfbuzz)
791 ("libevent" ,libevent)
793 ("libjpeg-turbo" ,libjpeg-turbo)
796 ("libvpx" ,libvpx/chromium)
800 ("libxcomposite" ,libxcomposite)
801 ("libxcursor" ,libxcursor)
802 ("libxdamage" ,libxdamage)
804 ("libxfixes" ,libxfixes)
807 ("libxrandr" ,libxrandr)
808 ("libxrender" ,libxrender)
809 ("libxscrnsaver" ,libxscrnsaver)
814 ("mit-krb5" ,mit-krb5)
816 ("openh264" ,openh264)
817 ("openjpeg" ,openjpeg) ;PDFium only
819 ("opus" ,opus+custom)
821 ("pciutils" ,pciutils)
822 ("pulseaudio" ,pulseaudio)
825 ("speech-dispatcher" ,speech-dispatcher)
827 ("valgrind" ,valgrind)
828 ("vulkan-headers" ,vulkan-headers)))
830 ;; Building Chromium takes ... a very long time. On a single core, a busy
831 ;; mid-end x86 system may need more than 24 hours to complete the build.
832 (properties '((timeout . 144000))) ;40 hours
834 (home-page "https://github.com/Eloston/ungoogled-chromium")
836 "Ungoogled-Chromium is the Chromium web browser, with some functionality
837 disabled in order to protect the users privacy.")
838 ;; Chromium is developed as BSD-3, but bundles a large number of third-party
839 ;; components with other licenses. For full information, see chrome://credits.
840 (license (list license:bsd-3
846 license:public-domain
848 (license:non-copyleft "chrome://credits"
849 "See chrome://credits for more information.")
852 (define-public ungoogled-chromium/wayland
853 (package/inherit ungoogled-chromium
854 (name "ungoogled-chromium-wayland")
856 `(("wayland" ,wayland)
857 ("wayland-protocols" ,wayland-protocols)
858 ,@(package-inputs ungoogled-chromium)))
861 (substitute-keyword-arguments (package-arguments ungoogled-chromium)
862 ((#:configure-flags flags)
863 `(append (list "use_ozone=true"
864 "ozone_platform_wayland=true"
865 "ozone_auto_platforms=false"
867 "use_system_minigbm=true"
868 "use_system_libwayland=true"
869 (string-append "system_wayland_scanner_path=\""
870 (assoc-ref %build-inputs "wayland")
871 "/bin/wayland-scanner\""))
872 (delete "use_vaapi=true" ,flags)))))))