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