Merge branch 'master' into core-updates
[jackhill/guix/guix.git] / gnu / packages / chromium.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2019 Marius Bakke <mbakke@fastmail.com>
3 ;;;
4 ;;; This file is part of GNU Guix.
5 ;;;
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
10 ;;;
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
15 ;;;
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19 (define-module (gnu packages chromium)
20 #:use-module ((guix licenses) #:prefix license:)
21 #:use-module (guix packages)
22 #:use-module (guix gexp)
23 #:use-module (guix store)
24 #:use-module (guix monads)
25 #:use-module (guix download)
26 #:use-module (guix git-download)
27 #:use-module (guix utils)
28 #:use-module (guix build-system gnu)
29 #:use-module (gnu packages)
30 #:use-module (gnu packages assembly)
31 #:use-module (gnu packages base)
32 #:use-module (gnu packages bison)
33 #:use-module (gnu packages build-tools)
34 #:use-module (gnu packages compression)
35 #:use-module (gnu packages cups)
36 #:use-module (gnu packages curl)
37 #:use-module (gnu packages fontutils)
38 #:use-module (gnu packages gcc)
39 #:use-module (gnu packages ghostscript)
40 #:use-module (gnu packages gl)
41 #:use-module (gnu packages glib)
42 #:use-module (gnu packages gnome)
43 #:use-module (gnu packages gperf)
44 #:use-module (gnu packages gtk)
45 #:use-module (gnu packages icu4c)
46 #:use-module (gnu packages image)
47 #:use-module (gnu packages libevent)
48 #:use-module (gnu packages libffi)
49 #:use-module (gnu packages linux)
50 #:use-module (gnu packages kerberos)
51 #:use-module (gnu packages ninja)
52 #:use-module (gnu packages node)
53 #:use-module (gnu packages nss)
54 #:use-module (gnu packages pciutils)
55 #:use-module (gnu packages pkg-config)
56 #:use-module (gnu packages pulseaudio)
57 #:use-module (gnu packages python)
58 #:use-module (gnu packages python-web)
59 #:use-module (gnu packages python-xyz)
60 #:use-module (gnu packages regex)
61 #:use-module (gnu packages serialization)
62 #:use-module (gnu packages speech)
63 #:use-module (gnu packages tls)
64 #:use-module (gnu packages valgrind)
65 #:use-module (gnu packages vulkan)
66 #:use-module (gnu packages video)
67 #:use-module (gnu packages xiph)
68 #:use-module (gnu packages xml)
69 #:use-module (gnu packages xdisorg)
70 #:use-module (gnu packages xorg))
71
72 (define %preserved-third-party-files
73 '("base/third_party/dmg_fp" ;X11-style
74 "base/third_party/dynamic_annotations" ;BSD-2
75 "base/third_party/icu" ;Unicode, X11-style
76 "base/third_party/superfasthash" ;BSD-3
77 "base/third_party/symbolize" ;BSD-3
78 "base/third_party/xdg_mime" ;LGPL2.0+ or Academic 2.0
79 "base/third_party/xdg_user_dirs" ;Expat
80 "chrome/third_party/mozilla_security_manager" ;MPL-1.1/GPL2+/LGPL2.1+
81 "courgette/third_party/bsdiff" ;BSD-2, BSD protection license
82 "courgette/third_party/divsufsort" ;Expat
83 "net/third_party/mozilla_security_manager" ;MPL-1.1/GPL2+/LGPL2.1+
84 "net/third_party/nss" ;MPL-2.0
85 "net/third_party/quic" ;BSD-3
86 "net/third_party/uri_template" ;ASL2.0
87 "third_party/abseil-cpp" ;ASL2.0
88 "third_party/adobe/flash/flapper_version.h" ;no license, trivial
89 "third_party/angle" ;BSD-3
90 "third_party/angle/src/common/third_party/base" ;BSD-3
91 "third_party/angle/src/common/third_party/smhasher" ;Public domain
92 "third_party/angle/src/common/third_party/xxhash" ;BSD-2
93 "third_party/angle/src/third_party/compiler" ;BSD-2
94 "third_party/angle/src/third_party/libXNVCtrl" ;Expat
95 "third_party/angle/src/third_party/trace_event" ;BSD-3
96 "third_party/angle/third_party/vulkan-headers" ;ASL2.0
97 "third_party/angle/third_party/vulkan-loader" ;ASL2.0
98 "third_party/angle/third_party/vulkan-tools" ;ASL2.0
99 "third_party/angle/third_party/vulkan-validation-layers" ;ASL2.0
100 "third_party/apple_apsl" ;APSL2.0
101 "third_party/axe-core" ;MPL2.0
102 "third_party/blink" ;BSD-3, LGPL2+
103 "third_party/boringssl" ;OpenSSL/ISC (Google additions are ISC)
104 "third_party/boringssl/src/third_party/fiat" ;Expat
105 "third_party/breakpad" ;BSD-3
106 "third_party/brotli" ;Expat
107 "third_party/cacheinvalidation" ;ASL2.0
108 "third_party/catapult" ;BSD-3
109 "third_party/catapult/common/py_vulcanize/third_party/rcssmin" ;ASL2.0
110 "third_party/catapult/common/py_vulcanize/third_party/rjsmin" ;ASL2.0
111 "third_party/catapult/third_party/polymer" ;BSD-3
112 "third_party/catapult/tracing/third_party/d3" ;BSD-3
113 "third_party/catapult/tracing/third_party/gl-matrix" ;Expat
114 "third_party/catapult/tracing/third_party/jszip" ;Expat or GPL3
115 "third_party/catapult/tracing/third_party/mannwhitneyu" ;Expat
116 "third_party/catapult/tracing/third_party/oboe" ;BSD-2
117 "third_party/catapult/tracing/third_party/pako" ;Expat
118 "third_party/ced" ;BSD-3
119 "third_party/cld_3" ;ASL2.0
120 "third_party/crashpad" ;ASL2.0
121 "third_party/crashpad/crashpad/third_party/lss" ;ASL2.0
122 "third_party/crashpad/crashpad/third_party/zlib/zlib_crashpad.h" ;Zlib
123 "third_party/crc32c" ;BSD-3
124 "third_party/cros_system_api" ;BSD-3
125 "third_party/dav1d" ;BSD-2
126 "third_party/dawn" ;ASL2.0
127 "third_party/dom_distiller_js" ;BSD-3
128 "third_party/emoji-segmenter" ;ASL2.0
129 "third_party/flatbuffers" ;ASL2.0
130 "third_party/glslang" ;BSD-3, Expat, ASL2.0
131 "third_party/google_input_tools" ;ASL2.0
132 "third_party/google_input_tools/third_party/closure_library" ;ASL2.0
133 "third_party/google_input_tools/third_party/closure_library/third_party/closure" ;Expat
134 "third_party/googletest" ;BSD-3
135 "third_party/hunspell" ;MPL1.1/GPL2+/LGPL2.1+
136 "third_party/iccjpeg" ;IJG
137 "third_party/inspector_protocol" ;BSD-3
138 "third_party/jinja2" ;BSD-3
139 "third_party/jstemplate" ;ASL2.0
140 "third_party/khronos" ;Expat, SGI
141 "third_party/leveldatabase" ;BSD-3
142 "third_party/libXNVCtrl" ;Expat
143 "third_party/libaddressinput" ;ASL2.0
144 "third_party/libaom" ;BSD-2 or "Alliance for Open Media Patent License 1.0"
145 "third_party/libaom/source/libaom/third_party/vector" ;Expat
146 "third_party/libaom/source/libaom/third_party/x86inc" ;ISC
147 "third_party/libjingle_xmpp" ;BSD-3
148 "third_party/libphonenumber" ;ASL2.0
149 "third_party/libsecret" ;LGPL2.1+
150 "third_party/libsrtp" ;BSD-3
151 "third_party/libsync" ;ASL2.0
152 "third_party/libudev" ;LGPL2.1+
153 "third_party/libwebm" ;BSD-3
154 "third_party/libxml/chromium" ;BSD-3
155 "third_party/libyuv" ;BSD-3
156 "third_party/lss" ;BSD-3
157 "third_party/markupsafe" ;BSD-3
158 "third_party/mesa_headers" ;Expat, SGI
159 "third_party/metrics_proto" ;BSD-3
160 "third_party/modp_b64" ;BSD-3
161 "third_party/nasm" ;BSD-2
162 "third_party/node" ;Expat
163 "third_party/node/node_modules/polymer-bundler/lib/third_party/UglifyJS2" ;BSD-2
164 "third_party/ots" ;BSD-3
165 "third_party/pdfium" ;BSD-3
166 "third_party/pdfium/third_party/agg23" ;Expat
167 "third_party/pdfium/third_party/base" ;BSD-3
168 "third_party/pdfium/third_party/bigint" ;Public domain, BSD-3
169 "third_party/pdfium/third_party/skia_shared" ;BSD-3
170 "third_party/pdfium/third_party/freetype/include/pstables.h" ;FreeType
171 "third_party/pffft" ;the "FFTPACK" license, similar to BSD-3
172 "third_party/ply" ;BSD-3
173 "third_party/polymer" ;BSD-3
174 "third_party/protobuf" ;BSD-3
175 "third_party/protobuf/third_party/six" ;Expat
176 "third_party/pyjson5" ;ASL2.0
177 "third_party/qcms" ;Expat
178 "third_party/rnnoise" ;BSD-3
179 "third_party/s2cellid" ;ASL2.0
180 "third_party/sfntly" ;ASL2.0
181 "third_party/skia" ;BSD-3
182 "third_party/skia/third_party/gif" ;MPL1.1/GPL2+/LGPL2.1+
183 "third_party/skia/third_party/skcms" ;BSD-3
184 "third_party/skia/third_party/vulkan" ;BSD-3
185 "third_party/smhasher" ;Expat, public domain
186 "third_party/speech-dispatcher" ;GPL2+
187 "third_party/spirv-headers" ;ASL2.0
188 "third_party/SPIRV-Tools" ;ASL2.0
189 "third_party/sqlite" ;Public domain
190 "third_party/ungoogled" ;BSD-3
191 "third_party/usb_ids" ;BSD-3
192 "third_party/usrsctp" ;BSD-2
193 "third_party/web-animations-js" ;ASL2.0
194 "third_party/webdriver" ;ASL2.0
195 "third_party/webrtc" ;BSD-3
196 "third_party/webrtc/common_audio/third_party/fft4g" ;Non-copyleft
197 "third_party/webrtc/common_audio/third_party/spl_sqrt_floor" ;Public domain
198 "third_party/webrtc/modules/third_party/fft" ;Non-copyleft
199 "third_party/webrtc/modules/third_party/g711" ;Public domain
200 "third_party/webrtc/modules/third_party/g722" ;Public domain
201 "third_party/webrtc/rtc_base/third_party/base64" ;Non-copyleft
202 "third_party/webrtc/rtc_base/third_party/sigslot" ;Public domain
203 "third_party/widevine/cdm/widevine_cdm_version.h" ;BSD-3
204 "third_party/widevine/cdm/widevine_cdm_common.h" ;BSD-3
205 "third_party/woff2" ;ASL2.0
206 "third_party/xdg-utils" ;Expat
207 "third_party/yasm/run_yasm.py" ;BSD-2 or BSD-3
208 "third_party/zlib/google" ;BSD-3
209 "url/third_party/mozilla" ;BSD-3, MPL1.1/GPL2+/LGPL2.1+
210 "v8/src/third_party/siphash" ;Public domain
211 "v8/src/third_party/utf8-decoder" ;Expat
212 "v8/src/third_party/valgrind" ;BSD-4
213 "v8/third_party/inspector_protocol" ;BSD-3
214 "v8/third_party/v8/builtins")) ;PSFL
215
216 (define* (computed-origin-method gexp-promise hash-algo hash
217 #:optional (name "source")
218 #:key (system (%current-system))
219 (guile (default-guile)))
220 "Return a derivation that executes the G-expression that results
221 from forcing GEXP-PROMISE."
222 (mlet %store-monad ((guile (package->derivation guile system)))
223 (gexp->derivation (or name "computed-origin")
224 (force gexp-promise)
225 #:graft? #f ;nothing to graft
226 #:system system
227 #:guile-for-build guile)))
228
229 (define %chromium-version "75.0.3770.80")
230 (define %ungoogled-revision "5d8abc38b43a62f379615a0dc972b29d9aebb4b4")
231 (define %debian-revision "debian/75.0.3770.80-1")
232 (define package-revision "0")
233 (define %package-version (string-append %chromium-version "-"
234 package-revision "."
235 (string-take %ungoogled-revision 7)))
236
237 (define %chromium-origin
238 (origin
239 (method url-fetch)
240 (uri (string-append "https://commondatastorage.googleapis.com"
241 "/chromium-browser-official/chromium-"
242 %chromium-version ".tar.xz"))
243 (sha256
244 (base32
245 "1mk6gb3iif8i6zq41wjn3lhqqlqp1syzpav1nj0170l7v348p0ns"))))
246
247 (define %ungoogled-origin
248 (origin
249 (method git-fetch)
250 (uri (git-reference (url "https://github.com/Eloston/ungoogled-chromium")
251 (commit %ungoogled-revision)))
252 (file-name (git-file-name "ungoogled-chromium"
253 (string-take %ungoogled-revision 7)))
254 (sha256
255 (base32
256 "1vk8jzzsn20ysn4nlz84mwwhfa9nnywzd1lrahlhcky9pf6xzpwa"))))
257
258 (define %debian-origin
259 (origin
260 (method git-fetch)
261 (uri (git-reference
262 (url "https://salsa.debian.org/chromium-team/chromium.git")
263 (commit %debian-revision)))
264 (file-name (git-file-name "debian-chromium-packaging"
265 (if (string-prefix? "debian/" %debian-revision)
266 (cadr (string-split %debian-revision #\/))
267 (string-take %debian-revision 7))))
268 (sha256
269 (base32
270 "16z4bncc2q1d5bymywq8291bzkcvba447ql3vsq20rwcdjckyimx"))))
271
272 ;; This is a "computed" origin that does the following:
273 ;; *) Runs the Ungoogled scripts on a pristine Chromium tarball.
274 ;; *) Applies Debians Chromium patches, for their unbundling and GCC work.
275 ;; *) Prunes all third_party directories that are not explicitly preserved.
276 ;; *) Adjusts "GN" build files such that system libraries are preferred.
277 (define ungoogled-chromium-source
278 (let ((chromium-source %chromium-origin)
279 (ungoogled-source %ungoogled-origin)
280 (debian-source %debian-origin))
281 (origin
282 (method computed-origin-method)
283 (file-name (string-append "ungoogled-chromium-" %package-version ".tar.xz"))
284 (sha256 #f)
285 (uri
286 (delay
287 (with-imported-modules '((guix build utils))
288 #~(begin
289 (use-modules (guix build utils)
290 (ice-9 rdelim)
291 (srfi srfi-1)
292 (srfi srfi-26))
293 (let ((chromium-dir (string-append "chromium-" #$%chromium-version))
294 (preserved-files (list #$@%preserved-third-party-files)))
295
296 (set-path-environment-variable
297 "PATH" '("bin")
298 (list #+(canonical-package patch)
299 #+(canonical-package xz)
300 #+(canonical-package tar)
301 #+python-2
302 #+python))
303
304 (copy-recursively #+ungoogled-source "/tmp/ungoogled")
305
306 (with-directory-excursion "/tmp/ungoogled"
307
308 (format #t "Unpacking chromium tarball...~%")
309 (force-output)
310 (invoke "tar" "xf" #+chromium-source)
311
312 (format #t "Ungooglifying...~%")
313 (force-output)
314 (invoke "python3" "utils/prune_binaries.py" chromium-dir
315 "pruning.list")
316 (invoke "python3" "utils/patches.py" "apply"
317 chromium-dir "patches")
318 (invoke "python3" "utils/domain_substitution.py" "apply" "-r"
319 "domain_regex.list" "-f" "domain_substitution.list"
320 "-c" "/tmp/domainscache.tar.gz" chromium-dir)
321
322 (with-directory-excursion chromium-dir
323
324 (format #t "applying Debian patches...~%")
325 (force-output)
326 (let* ((debian #+debian-source)
327 (patches (string-append debian "/debian/patches"))
328 (series (string-append patches "/series"))
329 (grep-q (lambda (query file)
330 (with-input-from-file file
331 (lambda ()
332 (let loop ((line (read-line))
333 (match #f))
334 (if (or match (eof-object? line))
335 (if match #t #f)
336 (loop (read-line)
337 (string-contains line query)))))))))
338 (with-input-from-file series
339 (lambda ()
340 (let loop ((line (read-line)))
341 (unless (eof-object? line)
342 (when (and (> (string-length line) 1)
343 ;; Skip the Debian-specific ones.
344 (not (string-prefix? "debianization/" line))
345 ;; And those that conflict with Ungoogled.
346 (not (any (cute string-suffix? <> line)
347 '("widevine-buildflag.patch"
348 "signin.patch"
349 "third-party-cookies.patch")))
350 ;; Ungoogled includes a subset of the Debian
351 ;; patches. Exclude those already present.
352 (not (grep-q line "../patches/series")))
353 (invoke "patch" "--force" "-p1" "--input"
354 (string-append patches "/" line)
355 "--no-backup-if-mismatch"))
356 (loop (read-line)))))))
357
358 (format #t "Pruning third party files...~%")
359 (force-output)
360 (apply invoke "python"
361 "build/linux/unbundle/remove_bundled_libraries.py"
362 "--do-remove" preserved-files)
363
364 (format #t "Replacing GN files...~%")
365 (force-output)
366 (invoke "python3" "build/linux/unbundle/replace_gn_files.py"
367 "--system-libraries" "ffmpeg" "flac" "fontconfig"
368 "freetype" "harfbuzz-ng" "icu" "libdrm" "libevent"
369 "libjpeg" "libpng" "libvpx" "libwebp" "libxml"
370 "libxslt" "openh264" "opus" "re2" "snappy" "yasm"
371 "zlib"))
372
373 (format #t (string-append "Packing new ungoogled tarball ...~%"))
374 (force-output)
375 (invoke "tar" "cvfa" #$output
376 ;; Avoid non-determinism in the archive.
377 "--mtime=@0"
378 "--owner=root:0"
379 "--group=root:0"
380 "--sort=name"
381 chromium-dir)
382
383 #t)))))))))
384
385 (define opus+custom
386 (package/inherit opus
387 (name "opus+custom")
388 (arguments
389 (substitute-keyword-arguments (package-arguments opus)
390 ((#:configure-flags flags ''())
391 ;; Opus Custom is an optional extension of the Opus
392 ;; specification that allows for unsupported frame
393 ;; sizes. Chromium requires that this is enabled.
394 `(cons "--enable-custom-modes"
395 ,flags))))))
396
397 (define-public ungoogled-chromium
398 (package
399 (name "ungoogled-chromium")
400 (version %package-version)
401 (synopsis "Graphical web browser")
402 (source ungoogled-chromium-source)
403 (build-system gnu-build-system)
404 (arguments
405 `(#:tests? #f
406 ;; FIXME: Chromiums RUNPATH lacks entries for some libraries, so
407 ;; we have to disable validation and add a wrapper below.
408 #:validate-runpath? #f
409 #:modules ((guix build gnu-build-system)
410 (guix build utils)
411 (ice-9 ftw)
412 (ice-9 regex)
413 (srfi srfi-26))
414 #:configure-flags
415 ;; See tools/gn/docs/cookbook.md and
416 ;; https://www.chromium.org/developers/gn-build-configuration
417 ;; for usage. Run "./gn args . --list" in the Release
418 ;; directory for an exhaustive list of supported flags.
419 ;; (Note: The 'configure' phase will do that for you.)
420 (list "is_debug=false"
421 "use_gold=false"
422 "use_lld=false"
423 "linux_use_bundled_binutils=false"
424 "use_custom_libcxx=false"
425 "use_sysroot=false"
426 "enable_precompiled_headers=false"
427 "goma_dir=\"\""
428 "enable_nacl=false"
429 "enable_nacl_nonsfi=false"
430 "use_allocator=\"none\""
431 "use_unofficial_version_number=false"
432 "treat_warnings_as_errors=false"
433 "use_official_google_api_keys=false"
434 "fieldtrial_testing_like_official_build=true"
435 "safe_browsing_mode=0"
436 "enable_mdns=false"
437 "enable_one_click_signin=false"
438 "enable_reading_list=false"
439 "enable_remoting=false"
440 "enable_reporting=false"
441 "enable_service_discovery=false"
442 "enable_swiftshader=false"
443 "enable_vr=false"
444 "enable_widevine=false"
445 ;; Disable type-checking for the Web UI to avoid a Java dependency.
446 "closure_compile=false"
447
448 ;; Define a custom toolchain that simply looks up CC, AR and
449 ;; friends from the environment.
450 "custom_toolchain=\"//build/toolchain/linux/unbundle:default\""
451 "host_toolchain=\"//build/toolchain/linux/unbundle:default\""
452 ;; Don't assume it's clang.
453 "is_clang=false"
454 ;; Disable debugging features to save space. These are normally
455 ;; pulled in by "is_official_build", but that requires "is_clang".
456 "blink_symbol_level=0"
457 "enable_iterator_debugging=false"
458 "exclude_unwind_tables=true"
459 ;; Optimize for building everything at once, as opposed to
460 ;; incrementally for development. See "docs/jumbo.md".
461 "use_jumbo_build=true"
462
463 ;; Prefer system libraries.
464 "use_system_freetype=true"
465 "use_system_harfbuzz=true"
466 "use_system_lcms2=true"
467 "use_system_libdrm=true"
468 "use_system_libjpeg=true"
469 "use_system_libopenjpeg2=true"
470 "use_system_libpng=true"
471 "use_system_zlib=true"
472 "use_gnome_keyring=false" ;deprecated by libsecret
473 "use_openh264=true"
474 "use_pulseaudio=true"
475 "link_pulseaudio=true"
476
477 ;; VA-API acceleration is currently only supported on x86_64-linux.
478 ,@(if (string-prefix? "x86_64" (or (%current-target-system)
479 (%current-system)))
480 '("use_vaapi=true")
481 '())
482
483 ;; Don't arbitrarily restrict formats supported by system ffmpeg.
484 "proprietary_codecs=true"
485 "ffmpeg_branding=\"Chrome\""
486
487 ;; WebRTC stuff.
488 "rtc_use_h264=true"
489 ;; Don't use bundled sources.
490 "rtc_build_json=false"
491 "rtc_build_libevent=false"
492 "rtc_build_libvpx=false"
493 "rtc_build_opus=false"
494 "rtc_build_ssl=false"
495 "rtc_build_libsrtp=true" ;FIXME: fails to find headers
496 "rtc_build_usrsctp=true" ;TODO: package this
497 (string-append "rtc_jsoncpp_root=\""
498 (assoc-ref %build-inputs "jsoncpp")
499 "/include/jsoncpp/json\"")
500 (string-append "rtc_ssl_root=\""
501 (assoc-ref %build-inputs "openssl")
502 "/include/openssl\""))
503 #:phases
504 (modify-phases %standard-phases
505 (add-after 'unpack 'patch-stuff
506 (lambda* (#:key inputs #:allow-other-keys)
507 (substitute* "printing/cups_config_helper.py"
508 (("cups_config =.*")
509 (string-append "cups_config = '" (assoc-ref inputs "cups")
510 "/bin/cups-config'\n")))
511
512 (substitute*
513 '("base/process/launch_posix.cc"
514 "base/third_party/dynamic_annotations/dynamic_annotations.c"
515 "sandbox/linux/seccomp-bpf/sandbox_bpf.cc"
516 "sandbox/linux/services/credentials.cc"
517 "sandbox/linux/services/namespace_utils.cc"
518 "sandbox/linux/services/syscall_wrappers.cc"
519 "sandbox/linux/syscall_broker/broker_host.cc")
520 (("include \"base/third_party/valgrind/") "include \"valgrind/"))
521
522 (for-each (lambda (file)
523 (substitute* file
524 ;; Fix opus include path.
525 ;; Do not substitute opus_private.h.
526 (("#include \"opus\\.h\"")
527 "#include \"opus/opus.h\"")
528 (("#include \"opus_custom\\.h\"")
529 "#include \"opus/opus_custom.h\"")
530 (("#include \"opus_defines\\.h\"")
531 "#include \"opus/opus_defines.h\"")
532 (("#include \"opus_multistream\\.h\"")
533 "#include \"opus/opus_multistream.h\"")
534 (("#include \"opus_types\\.h\"")
535 "#include \"opus/opus_types.h\"")))
536 (find-files (string-append "third_party/webrtc/modules"
537 "/audio_coding/codecs/opus")))
538
539 (substitute* "chrome/common/chrome_paths.cc"
540 (("/usr/share/chromium/extensions")
541 ;; TODO: Add ~/.guix-profile.
542 "/run/current-system/profile/share/chromium/extensions"))
543
544 ;; XXX: Should be unnecessary when use_system_lcms2=true.
545 (substitute* "third_party/pdfium/core/fxcodec/codec/ccodec_iccmodule.h"
546 (("include \"third_party/lcms/include/lcms2\\.h\"")
547 "include \"lcms2.h\""))
548
549 (substitute*
550 "third_party/breakpad/breakpad/src/common/linux/libcurl_wrapper.h"
551 (("include \"third_party/curl") "include \"curl"))
552
553 (substitute* "third_party/webrtc/rtc_base/strings/json.h"
554 (("#include \"third_party/jsoncpp/") "#include \"json/"))
555
556 (substitute* '("ui/gfx/skia_util.h"
557 "components/viz/common/resources/resource_format_utils.h")
558 (("third_party/vulkan/include/") ""))
559
560 (substitute* "third_party/skia/include/gpu/vk/GrVkVulkan.h"
561 (("\\.\\./\\.\\./include/third_party/vulkan/") ""))
562
563 ;; Building chromedriver embeds some files using the ZIP
564 ;; format which doesn't support timestamps before
565 ;; 1980. Therefore, advance the timestamps of the files
566 ;; which are included so that building chromedriver
567 ;; works.
568 (let ((circa-1980 (* 10 366 24 60 60)))
569 (for-each (lambda (file)
570 (utime file circa-1980 circa-1980))
571 '("chrome/test/chromedriver/extension/background.js"
572 "chrome/test/chromedriver/extension/manifest.json")))
573
574 #t))
575 (add-before 'configure 'prepare-build-environment
576 (lambda* (#:key inputs #:allow-other-keys)
577
578 ;; Make sure the right build tools are used.
579 (setenv "AR" "ar") (setenv "NM" "nm")
580 (setenv "CC" "gcc") (setenv "CXX" "g++")
581
582 ;; Work around <https://bugs.gnu.org/30756>.
583 (unsetenv "C_INCLUDE_PATH")
584 (unsetenv "CPLUS_INCLUDE_PATH")
585
586 ;; TODO: pre-compile instead. Avoids a race condition.
587 (setenv "PYTHONDONTWRITEBYTECODE" "1")
588
589 ;; XXX: How portable is this.
590 (mkdir-p "third_party/node/linux/node-linux-x64")
591 (symlink (string-append (assoc-ref inputs "node") "/bin")
592 "third_party/node/linux/node-linux-x64/bin")
593
594 #t))
595 (replace 'configure
596 (lambda* (#:key configure-flags #:allow-other-keys)
597 (let ((args (string-join configure-flags " ")))
598 ;; Generate ninja build files.
599 (invoke "gn" "gen" "out/Release"
600 (string-append "--args=" args))
601
602 ;; Print the full list of supported arguments as well as
603 ;; their current status for convenience.
604 (format #t "Dumping configure flags...\n")
605 (invoke "gn" "args" "out/Release" "--list"))))
606 (replace 'build
607 (lambda* (#:key outputs #:allow-other-keys)
608 (invoke "ninja" "-C" "out/Release"
609 "-j" (number->string (parallel-job-count))
610 "chrome"
611 "chromedriver")))
612 (replace 'install
613 (lambda* (#:key inputs outputs #:allow-other-keys)
614 (let* ((out (assoc-ref outputs "out"))
615 (bin (string-append out "/bin"))
616 (exe (string-append bin "/chromium"))
617 (lib (string-append out "/lib"))
618 (man (string-append out "/share/man/man1"))
619 (applications (string-append out "/share/applications"))
620 (install-regexp (make-regexp "\\.(bin|pak)$"))
621 (locales (string-append lib "/locales"))
622 (resources (string-append lib "/resources"))
623 (preferences (assoc-ref inputs "master-preferences"))
624 (gtk+ (assoc-ref inputs "gtk+"))
625 (mesa (assoc-ref inputs "mesa"))
626 (nss (assoc-ref inputs "nss"))
627 (udev (assoc-ref inputs "udev"))
628 (sh (which "sh")))
629
630 (substitute* '("chrome/app/resources/manpage.1.in"
631 "chrome/installer/linux/common/desktop.template")
632 (("@@MENUNAME@@") "Chromium")
633 (("@@PACKAGE@@") "chromium")
634 (("/usr/bin/@@USR_BIN_SYMLINK_NAME@@") exe))
635
636 (mkdir-p man)
637 (copy-file "chrome/app/resources/manpage.1.in"
638 (string-append man "/chromium.1"))
639
640 (mkdir-p applications)
641 (copy-file "chrome/installer/linux/common/desktop.template"
642 (string-append applications "/chromium.desktop"))
643
644 (mkdir-p lib)
645 (copy-file preferences (string-append lib "/master_preferences"))
646
647 (with-directory-excursion "out/Release"
648 (for-each (lambda (file)
649 (install-file file lib))
650 (scandir "." (cut regexp-exec install-regexp <>)))
651 (copy-file "chrome" (string-append lib "/chromium"))
652
653 ;; TODO: Install icons from "../../chrome/app/themes" into
654 ;; "out/share/icons/hicolor/$size".
655 (install-file
656 "product_logo_48.png"
657 (string-append out "/share/icons/48x48/chromium.png"))
658
659 (copy-recursively "locales" locales)
660 (copy-recursively "resources" resources)
661
662 (mkdir-p bin)
663 (symlink "../lib/chromium" exe)
664 (install-file "chromedriver" bin)
665
666 (wrap-program exe
667 ;; TODO: Get these in RUNPATH.
668 `("LD_LIBRARY_PATH" ":" prefix
669 (,(string-append lib ":" nss "/lib/nss:" mesa "/lib:"
670 udev "/lib")))
671 ;; Avoid file manager crash. See <https://bugs.gnu.org/26593>.
672 `("XDG_DATA_DIRS" ":" prefix (,(string-append gtk+ "/share"))))
673 #t)))))))
674 (native-inputs
675 `(("bison" ,bison)
676 ("gcc" ,gcc-8)
677 ("gn" ,gn)
678 ("gperf" ,gperf)
679 ("ninja" ,ninja)
680 ("node" ,node)
681 ("pkg-config" ,pkg-config)
682 ("which" ,which)
683 ("yasm" ,yasm)
684
685 ;; This file contains defaults for new user profiles.
686 ("master-preferences" ,(local-file "aux-files/chromium/master-preferences.json"))
687
688 ("python-beautifulsoup4" ,python2-beautifulsoup4)
689 ("python-html5lib" ,python2-html5lib)
690 ("python" ,python-2)))
691 (inputs
692 `(("alsa-lib" ,alsa-lib)
693 ("atk" ,atk)
694 ("cups" ,cups)
695 ("curl" ,curl)
696 ("dbus" ,dbus)
697 ("dbus-glib" ,dbus-glib)
698 ("expat" ,expat)
699 ("flac" ,flac)
700 ("ffmpeg" ,ffmpeg)
701 ("fontconfig" ,fontconfig)
702 ("freetype" ,freetype)
703 ("gdk-pixbuf" ,gdk-pixbuf)
704 ("glib" ,glib)
705 ("gtk+" ,gtk+)
706 ("harfbuzz" ,harfbuzz)
707 ("icu4c" ,icu4c)
708 ("jsoncpp" ,jsoncpp)
709 ("lcms" ,lcms)
710 ("libevent" ,libevent)
711 ("libffi" ,libffi)
712 ("libjpeg-turbo" ,libjpeg-turbo)
713 ("libpng" ,libpng)
714 ("libva" ,libva)
715 ("libvpx" ,libvpx)
716 ("libwebp" ,libwebp)
717 ("libx11" ,libx11)
718 ("libxcb" ,libxcb)
719 ("libxcomposite" ,libxcomposite)
720 ("libxcursor" ,libxcursor)
721 ("libxdamage" ,libxdamage)
722 ("libxext" ,libxext)
723 ("libxfixes" ,libxfixes)
724 ("libxi" ,libxi)
725 ("libxml2" ,libxml2)
726 ("libxrandr" ,libxrandr)
727 ("libxrender" ,libxrender)
728 ("libxscrnsaver" ,libxscrnsaver)
729 ("libxslt" ,libxslt)
730 ("libxtst" ,libxtst)
731 ("mesa" ,mesa)
732 ("minizip" ,minizip)
733 ("mit-krb5" ,mit-krb5)
734 ("nss" ,nss)
735 ("openh264" ,openh264)
736 ("openjpeg" ,openjpeg) ;PDFium only
737 ("openssl" ,openssl)
738 ("opus" ,opus+custom)
739 ("pango" ,pango)
740 ("pciutils" ,pciutils)
741 ("pulseaudio" ,pulseaudio)
742 ("re2" ,re2)
743 ("snappy" ,snappy)
744 ("speech-dispatcher" ,speech-dispatcher)
745 ("udev" ,eudev)
746 ("valgrind" ,valgrind)
747 ("vulkan-headers" ,vulkan-headers)))
748 (home-page "https://github.com/Eloston/ungoogled-chromium")
749 (description
750 "Ungoogled-Chromium is the Chromium web browser, with some functionality
751 disabled in order to protect the users privacy.")
752 ;; Chromium is developed as BSD-3, but bundles a large number of third-party
753 ;; components with other licenses. For full information, see chrome://credits.
754 (license (list license:bsd-3
755 license:bsd-2
756 license:expat
757 license:asl2.0
758 license:mpl1.1
759 license:mpl2.0
760 license:public-domain
761 license:isc
762 (license:non-copyleft "chrome://credits"
763 "See chrome://credits for more information.")
764 license:lgpl2.1+))))