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