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