gnu: Add python-pytest-helpers-namespace.
[jackhill/guix/guix.git] / gnu / packages / chromium.scm
CommitLineData
f1e9de4d 1;;; GNU Guix --- Functional package management for GNU
91bfb6d1 2;;; Copyright © 2019, 2020, 2021 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)
f1e9de4d
MB
24 #:use-module (guix download)
25 #:use-module (guix git-download)
26 #:use-module (guix utils)
27 #:use-module (guix build-system gnu)
689d8845 28 #:use-module (guix build-system trivial)
f1e9de4d
MB
29 #:use-module (gnu packages)
30 #:use-module (gnu packages assembly)
31 #:use-module (gnu packages base)
689d8845 32 #:use-module (gnu packages bash)
f1e9de4d
MB
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 ghostscript)
41 #:use-module (gnu packages gl)
42 #:use-module (gnu packages glib)
43 #:use-module (gnu packages gnome)
f1e9de4d
MB
44 #:use-module (gnu packages gperf)
45 #:use-module (gnu packages gtk)
46 #:use-module (gnu packages icu4c)
47 #:use-module (gnu packages image)
48 #:use-module (gnu packages libevent)
49 #:use-module (gnu packages libffi)
50 #:use-module (gnu packages linux)
f613d459 51 #:use-module (gnu packages llvm)
f1e9de4d
MB
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)
c91c132f 58 #:use-module (gnu packages protobuf)
f1e9de4d
MB
59 #:use-module (gnu packages pulseaudio)
60 #:use-module (gnu packages python)
61 #:use-module (gnu packages python-web)
62 #:use-module (gnu packages python-xyz)
63 #:use-module (gnu packages regex)
64 #:use-module (gnu packages serialization)
65 #:use-module (gnu packages speech)
f1e9de4d
MB
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)
4cac5579 72 #:use-module (gnu packages xorg)
25590118
MB
73 #:use-module (ice-9 match)
74 #:use-module (srfi srfi-1))
f1e9de4d
MB
75
76(define %preserved-third-party-files
7f2e8522 77 '("base/third_party/cityhash" ;Expat
ba261f63 78 "base/third_party/double_conversion" ;BSD-3
f1e9de4d
MB
79 "base/third_party/dynamic_annotations" ;BSD-2
80 "base/third_party/icu" ;Unicode, X11-style
81 "base/third_party/superfasthash" ;BSD-3
82 "base/third_party/symbolize" ;BSD-3
83 "base/third_party/xdg_mime" ;LGPL2.0+ or Academic 2.0
84 "base/third_party/xdg_user_dirs" ;Expat
f01ec472
MB
85 ;; XXX: Chromium requires a newer C++ standard library. Remove this when
86 ;; the default GCC is 9 or later.
87 "buildtools/third_party/libc++" ;ASL2.0, with LLVM exceptions
f1e9de4d
MB
88 "chrome/third_party/mozilla_security_manager" ;MPL-1.1/GPL2+/LGPL2.1+
89 "courgette/third_party/bsdiff" ;BSD-2, BSD protection license
90 "courgette/third_party/divsufsort" ;Expat
f1e9de4d
MB
91 "net/third_party/mozilla_security_manager" ;MPL-1.1/GPL2+/LGPL2.1+
92 "net/third_party/nss" ;MPL-2.0
7f2e8522 93 "net/third_party/quiche" ;BSD-3
f1e9de4d
MB
94 "net/third_party/uri_template" ;ASL2.0
95 "third_party/abseil-cpp" ;ASL2.0
f1e9de4d
MB
96 "third_party/angle" ;BSD-3
97 "third_party/angle/src/common/third_party/base" ;BSD-3
98 "third_party/angle/src/common/third_party/smhasher" ;Public domain
99 "third_party/angle/src/common/third_party/xxhash" ;BSD-2
100 "third_party/angle/src/third_party/compiler" ;BSD-2
101 "third_party/angle/src/third_party/libXNVCtrl" ;Expat
102 "third_party/angle/src/third_party/trace_event" ;BSD-3
75527eb1 103 "third_party/angle/src/third_party/volk" ;Expat
f1e9de4d 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
109 "third_party/breakpad" ;BSD-3
110 "third_party/brotli" ;Expat
f1e9de4d
MB
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
f613d459 115 ;; XXX: This is a minified version of <https://d3js.org/>.
f1e9de4d
MB
116 "third_party/catapult/tracing/third_party/d3" ;BSD-3
117 "third_party/catapult/tracing/third_party/gl-matrix" ;Expat
75527eb1 118 "third_party/catapult/tracing/third_party/jpeg-js" ;ASL2.0
f613d459 119 ;; XXX: Minified version of <https://github.com/Stuk/jszip>.
f1e9de4d
MB
120 "third_party/catapult/tracing/third_party/jszip" ;Expat or GPL3
121 "third_party/catapult/tracing/third_party/mannwhitneyu" ;Expat
122 "third_party/catapult/tracing/third_party/oboe" ;BSD-2
f613d459 123 ;; XXX: Minified version of <https://github.com/nodeca/pako>.
f1e9de4d
MB
124 "third_party/catapult/tracing/third_party/pako" ;Expat
125 "third_party/ced" ;BSD-3
126 "third_party/cld_3" ;ASL2.0
ba261f63 127 "third_party/closure_compiler" ;ASL2.0
f1e9de4d 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
ba261f63 135 "third_party/depot_tools/owners.py" ;BSD-3
f613d459 136 "third_party/devtools-frontend" ;BSD-3
c91c132f 137 "third_party/devtools-frontend/src/front_end/third_party/acorn" ;Expat
689d8845 138 "third_party/devtools-frontend/src/front_end/third_party/axe-core" ;MPL2.0
f01ec472 139 "third_party/devtools-frontend/src/front_end/third_party/chromium" ;BSD-3
c91c132f 140 "third_party/devtools-frontend/src/front_end/third_party/codemirror" ;Expat
25c93be6 141 "third_party/devtools-frontend/src/front_end/third_party/fabricjs" ;Expat
f01ec472
MB
142 "third_party/devtools-frontend/src/front_end/third_party/i18n" ;ASL2.0
143 "third_party/devtools-frontend/src/front_end/third_party/intl-messageformat" ;BSD-3
75527eb1 144 "third_party/devtools-frontend/src/front_end/third_party/lighthouse" ;ASL2.0
f01ec472
MB
145 "third_party/devtools-frontend/src/front_end/third_party/lit-html" ;BSD-3
146 "third_party/devtools-frontend/src/front_end/third_party/lodash-isequal" ;Expat
147 "third_party/devtools-frontend/src/front_end/third_party/marked" ;Expat, BSD-3
689d8845 148 "third_party/devtools-frontend/src/front_end/third_party/puppeteer" ;ASL2.0
25c93be6 149 "third_party/devtools-frontend/src/front_end/third_party/wasmparser" ;ASL2.0
d64584cf 150 "third_party/devtools-frontend/src/third_party/pyjson5" ;ASL2.0
25c93be6 151 "third_party/devtools-frontend/src/third_party/typescript" ;ASL2.0
f1e9de4d 152 "third_party/dom_distiller_js" ;BSD-3
af74e435 153 "third_party/emoji-segmenter" ;ASL2.0
f1e9de4d 154 "third_party/flatbuffers" ;ASL2.0
91bfb6d1 155 "third_party/fusejs" ;ASL2.0
f1e9de4d
MB
156 "third_party/google_input_tools" ;ASL2.0
157 "third_party/google_input_tools/third_party/closure_library" ;ASL2.0
158 "third_party/google_input_tools/third_party/closure_library/third_party/closure" ;Expat
159 "third_party/googletest" ;BSD-3
75527eb1 160 "third_party/harfbuzz-ng" ;Expat
f1e9de4d
MB
161 "third_party/hunspell" ;MPL1.1/GPL2+/LGPL2.1+
162 "third_party/iccjpeg" ;IJG
163 "third_party/inspector_protocol" ;BSD-3
164 "third_party/jinja2" ;BSD-3
f01ec472
MB
165 ;; XXX: Unbundle this when switching back to libstdc++.
166 "third_party/jsoncpp" ;Public Domain or Expat
f1e9de4d
MB
167 "third_party/jstemplate" ;ASL2.0
168 "third_party/khronos" ;Expat, SGI
169 "third_party/leveldatabase" ;BSD-3
c91c132f 170 "third_party/libavif" ;BSD-2
f1e9de4d
MB
171 "third_party/libXNVCtrl" ;Expat
172 "third_party/libaddressinput" ;ASL2.0
173 "third_party/libaom" ;BSD-2 or "Alliance for Open Media Patent License 1.0"
174 "third_party/libaom/source/libaom/third_party/vector" ;Expat
175 "third_party/libaom/source/libaom/third_party/x86inc" ;ISC
f613d459 176 "third_party/libgifcodec" ;MPL1.1/GPL2+/LGPL2.1+, BSD-3, BSD-2
f1e9de4d
MB
177 "third_party/libjingle_xmpp" ;BSD-3
178 "third_party/libphonenumber" ;ASL2.0
179 "third_party/libsecret" ;LGPL2.1+
180 "third_party/libsrtp" ;BSD-3
181 "third_party/libsync" ;ASL2.0
182 "third_party/libudev" ;LGPL2.1+
1155a883
MB
183 "third_party/liburlpattern" ;Expat
184 "third_party/libva_protected_content" ;Expat
f01ec472
MB
185
186 ;; FIXME: build/linux/unbundle/libvpx.gn does not work for all users.
187 "third_party/libvpx" ;BSD-3
188 "third_party/libvpx/source/libvpx/third_party/x86inc" ;Expat
189
f1e9de4d
MB
190 "third_party/libwebm" ;BSD-3
191 "third_party/libxml/chromium" ;BSD-3
192 "third_party/libyuv" ;BSD-3
c91c132f 193 "third_party/lottie" ;Expat
f1e9de4d 194 "third_party/lss" ;BSD-3
75527eb1 195 "third_party/mako" ;Expat
f1e9de4d
MB
196 "third_party/markupsafe" ;BSD-3
197 "third_party/mesa_headers" ;Expat, SGI
198 "third_party/metrics_proto" ;BSD-3
1155a883 199 "third_party/minigbm" ;BSD-3
f1e9de4d
MB
200 "third_party/modp_b64" ;BSD-3
201 "third_party/nasm" ;BSD-2
f01ec472 202 "third_party/nearby" ;ASL2.0
f1e9de4d
MB
203 "third_party/node" ;Expat
204 "third_party/node/node_modules/polymer-bundler/lib/third_party/UglifyJS2" ;BSD-2
ba261f63 205 "third_party/one_euro_filter" ;BSD-3
7f2e8522 206 "third_party/openscreen" ;BSD-3
ba261f63 207 "third_party/openscreen/src/third_party/tinycbor" ;Expat
c91c132f 208 "third_party/openscreen/src/third_party/mozilla" ;MPL1.1/GPL2+/LGPL2.1+, BSD-3
f1e9de4d
MB
209 "third_party/ots" ;BSD-3
210 "third_party/pdfium" ;BSD-3
211 "third_party/pdfium/third_party/agg23" ;Expat
212 "third_party/pdfium/third_party/base" ;BSD-3
213 "third_party/pdfium/third_party/bigint" ;Public domain, BSD-3
214 "third_party/pdfium/third_party/skia_shared" ;BSD-3
215 "third_party/pdfium/third_party/freetype/include/pstables.h" ;FreeType
d64584cf 216 "third_party/perfetto" ;ASL2.0
1155a883
MB
217 "third_party/perfetto/protos/third_party/chromium" ;BSD-3
218 "third_party/pffft" ;the "FFTPACK" license
f1e9de4d
MB
219 "third_party/ply" ;BSD-3
220 "third_party/polymer" ;BSD-3
689d8845 221 "third_party/private_membership" ;ASL2.0
ba261f63 222 "third_party/private-join-and-compute" ;ASL2.0
f1e9de4d
MB
223 "third_party/protobuf" ;BSD-3
224 "third_party/protobuf/third_party/six" ;Expat
225 "third_party/pyjson5" ;ASL2.0
226 "third_party/qcms" ;Expat
f01ec472
MB
227 ;; XXX: System re2 cannot be used when Chromium uses libc++ because the re2
228 ;; ABI relies on libstdc++ internals. See build/linux/unbundle/re2.gn.
229 "third_party/re2" ;BSD-3
f1e9de4d
MB
230 "third_party/rnnoise" ;BSD-3
231 "third_party/s2cellid" ;ASL2.0
75527eb1 232 "third_party/schema_org" ;CC-BY-SA3.0
f01ec472 233 "third_party/securemessage" ;ASL2.0
689d8845 234 "third_party/shell-encryption" ;ASL2.0
f1e9de4d 235 "third_party/skia" ;BSD-3
7f2e8522 236 "third_party/skia/include/third_party/skcms" ;BSD-3
f1e9de4d 237 "third_party/skia/third_party/skcms" ;BSD-3
7f2e8522 238 "third_party/skia/third_party/vulkanmemoryallocator" ;BSD-3, Expat
f1e9de4d
MB
239 "third_party/smhasher" ;Expat, public domain
240 "third_party/speech-dispatcher" ;GPL2+
f1e9de4d 241 "third_party/sqlite" ;Public domain
75527eb1
MB
242 "third_party/swiftshader" ;ASL2.0
243 "third_party/swiftshader/third_party/astc-encoder" ;ASL2.0
f01ec472 244 "third_party/swiftshader/third_party/llvm-10.0" ;ASL2.0, with LLVM exception
75527eb1
MB
245 "third_party/swiftshader/third_party/llvm-subzero" ;NCSA
246 "third_party/swiftshader/third_party/marl" ;ASL2.0
247 "third_party/swiftshader/third_party/subzero" ;NCSA
248 "third_party/swiftshader/third_party/SPIRV-Headers" ;X11-style
ccc1d743 249 "third_party/tcmalloc/chromium" ;BSD-3
f01ec472 250 "third_party/ukey2" ;ASL2.0
f1e9de4d
MB
251 "third_party/usb_ids" ;BSD-3
252 "third_party/usrsctp" ;BSD-2
1155a883 253 "third_party/vulkan-deps" ;ASL2.0, BSD-3, Expat
c91c132f 254 "third_party/vulkan_memory_allocator" ;Expat
689d8845
MB
255 "third_party/wayland/protocol" ;Expat
256 "third_party/wayland/stubs" ;BSD-3, Expat
82ccfb1d
MB
257 "third_party/wayland/wayland_scanner_wrapper.py" ;BSD-3
258 "third_party/wayland-protocols" ;Expat
f1e9de4d
MB
259 "third_party/web-animations-js" ;ASL2.0
260 "third_party/webdriver" ;ASL2.0
261 "third_party/webrtc" ;BSD-3
c91c132f 262 "third_party/webrtc/common_audio/third_party/ooura" ;Non-copyleft
f1e9de4d
MB
263 "third_party/webrtc/common_audio/third_party/spl_sqrt_floor" ;Public domain
264 "third_party/webrtc/modules/third_party/fft" ;Non-copyleft
265 "third_party/webrtc/modules/third_party/g711" ;Public domain
266 "third_party/webrtc/modules/third_party/g722" ;Public domain
267 "third_party/webrtc/rtc_base/third_party/base64" ;Non-copyleft
268 "third_party/webrtc/rtc_base/third_party/sigslot" ;Public domain
269 "third_party/widevine/cdm/widevine_cdm_version.h" ;BSD-3
270 "third_party/widevine/cdm/widevine_cdm_common.h" ;BSD-3
271 "third_party/woff2" ;ASL2.0
f01ec472 272 "third_party/xcbproto" ;X11
f1e9de4d 273 "third_party/xdg-utils" ;Expat
91bfb6d1
MB
274
275 ;; These are forked components of the X11 keybinding code.
276 "third_party/libxcb-keysyms" ;X11
277 "third_party/libx11/src/KeyBind.c" ;X11
278 "third_party/libx11/src/xkb/XKBBind.c" ;X11
279 "third_party/x11proto/keysymdef.h" ;X11
280
f1e9de4d 281 "third_party/zlib/google" ;BSD-3
f01ec472 282 "third_party/zxcvbn-cpp" ;Expat
f1e9de4d 283 "url/third_party/mozilla" ;BSD-3, MPL1.1/GPL2+/LGPL2.1+
105fa9fc 284 "v8/src/third_party/siphash" ;Public domain
f1e9de4d
MB
285 "v8/src/third_party/utf8-decoder" ;Expat
286 "v8/src/third_party/valgrind" ;BSD-4
287 "v8/third_party/inspector_protocol" ;BSD-3
288 "v8/third_party/v8/builtins")) ;PSFL
289
e6db8912
MB
290(define %blacklisted-files
291 ;; 'third_party/blink/perf_tests/resources/svg/HarveyRayner.svg' carries a
292 ;; nonfree license according to LICENSES in the same directory. As we don't
f01ec472 293 ;; run the Blink performance tests, just remove everything to save ~70MiB.
e6db8912
MB
294 '("third_party/blink/perf_tests"))
295
75527eb1
MB
296(define (debian-patch name revision hash)
297 (origin
298 (method url-fetch)
299 (uri (string-append "https://salsa.debian.org/chromium-team/chromium/-/raw/"
300 revision "/debian/patches/" name))
301 (file-name (match (string-split name #\/)
302 ((category name)
303 (string-append "ungoogled-chromium-" category "-" name))))
304 (sha256 (base32 hash))))
305
b7bcd1ec 306(define %ungoogled-revision "89.0.4389.114-1")
f01ec472 307(define %debian-revision "debian/84.0.4147.105-1")
c91c132f 308
75527eb1 309(define %debian-patches
c91c132f 310 (list (debian-patch "system/zlib.patch" %debian-revision
f01ec472 311 "09vqgs37w9ycc7par14wa7rnvmg9bm0z9pqg6fyl3iqvpghyjyr4")
75527eb1
MB
312 (debian-patch "system/openjpeg.patch" %debian-revision
313 "0zd6v5njx1pc7i0y6mslxvpx5j4cq01mmyx55qcqx8qzkm0gm48j")))
314
d0804ea0
MB
315(define %ungoogled-origin
316 (origin
317 (method git-fetch)
d46f9f83 318 (uri (git-reference (url "https://github.com/Eloston/ungoogled-chromium")
d0804ea0
MB
319 (commit %ungoogled-revision)))
320 (file-name (git-file-name "ungoogled-chromium"
1155a883
MB
321 (if (= 40 (string-length %ungoogled-revision))
322 (string-take %ungoogled-revision 7)
323 %ungoogled-revision)))
d0804ea0
MB
324 (sha256
325 (base32
b7bcd1ec 326 "0cr2i51gxhgl55c8f9w0ra3m5q2dk03sf7p2qn4bqq1l1l72hw6s"))))
7f2e8522 327
867e3830 328(define %guix-patches
a5945a60
LC
329 (list (local-file
330 (assume-valid-file-name
331 (search-patch "ungoogled-chromium-system-nspr.patch")))
1155a883
MB
332 (local-file
333 (assume-valid-file-name
334 (search-patch "ungoogled-chromium-system-opus.patch")))
a5945a60
LC
335 (local-file
336 (assume-valid-file-name
337 (search-patch "ungoogled-chromium-extension-search-path.patch")))))
867e3830 338
7eb8ae5f
MB
339;; This is a source 'snippet' that does the following:
340;; *) Applies various patches for unbundling purposes and libstdc++ compatibility.
341;; *) Runs the ungoogled patch-, domain substitution-, and scrubbing scripts.
105fa9fc
MB
342;; *) Prunes all third_party directories that are not explicitly preserved.
343;; *) Adjusts "GN" build files such that system libraries are preferred.
7eb8ae5f
MB
344(define ungoogled-chromium-snippet
345 ;; Note: delay to cope with cyclic module imports at the top level.
346 (delay
347 #~(begin
348 (let ((chromium-dir (getcwd)))
349 (set-path-environment-variable
350 "PATH" '("bin")
351 (list #+patch #+python-wrapper #+xz))
7f2e8522 352
7eb8ae5f
MB
353 ;; Apply patches before running the ungoogled scripts because
354 ;; domain substitution may break some of the patches.
355 (format #t "Applying assorted build fixes...~%")
356 (force-output)
357 (for-each (lambda (patch)
358 (invoke "patch" "-p1" "--force" "--input"
359 patch "--no-backup-if-mismatch"))
689d8845 360 (append '#+%debian-patches '#+%guix-patches))
f1e9de4d 361
7eb8ae5f
MB
362 (with-directory-excursion #+%ungoogled-origin
363 (format #t "Ungooglifying...~%")
364 (force-output)
365 (invoke "python" "utils/prune_binaries.py" chromium-dir
366 "pruning.list")
f01ec472
MB
367 (invoke "python" "utils/patches.py" "apply" chromium-dir
368 "patches")
7eb8ae5f
MB
369 (invoke "python" "utils/domain_substitution.py" "apply" "-r"
370 "domain_regex.list" "-f" "domain_substitution.list"
371 "-c" "/tmp/domainscache.tar.gz" chromium-dir))
f1e9de4d 372
e6db8912
MB
373 ;; Run after the ungoogled scripts to avoid interfering with
374 ;; patches or file lists.
375 (format #t "Removing blacklisted files...~%")
376 (force-output)
377 (for-each delete-file-recursively '#$%blacklisted-files)
378
7eb8ae5f
MB
379 (format #t "Pruning third party files...~%")
380 (force-output)
381 (apply invoke (string-append #+python-2 "/bin/python")
382 "build/linux/unbundle/remove_bundled_libraries.py"
383 "--do-remove" '#$%preserved-third-party-files)
f1e9de4d 384
7eb8ae5f
MB
385 (format #t "Replacing GN files...~%")
386 (force-output)
71c237bd
MB
387 (substitute* "tools/generate_shim_headers/generate_shim_headers.py"
388 ;; The "is_official_build" configure option enables certain
389 ;; release optimizations like those used in the commercial
390 ;; Chrome browser. Unfortunately it also requires using the
391 ;; bundled libraries: lose that restriction.
392 (("#if defined\\(OFFICIAL_BUILD\\)")
393 "#if 0"))
7eb8ae5f
MB
394 (invoke "python" "build/linux/unbundle/replace_gn_files.py"
395 "--system-libraries" "ffmpeg" "flac" "fontconfig"
396 "freetype" "harfbuzz-ng" "icu" "libdrm" "libevent"
f01ec472
MB
397 "libjpeg" "libpng" "libwebp" "libxml" "libxslt"
398 "openh264" "opus" "snappy" "zlib")
7eb8ae5f 399 #t))))
f1e9de4d
MB
400
401(define opus+custom
402 (package/inherit opus
403 (name "opus+custom")
404 (arguments
405 (substitute-keyword-arguments (package-arguments opus)
406 ((#:configure-flags flags ''())
407 ;; Opus Custom is an optional extension of the Opus
408 ;; specification that allows for unsupported frame
409 ;; sizes. Chromium requires that this is enabled.
410 `(cons "--enable-custom-modes"
411 ,flags))))))
412
91bfb6d1
MB
413;; WebRTC in Chromium 88 requires an unreleased version of libvpx. Use the
414;; commit mentioned in "third_party/libvpx/README.chromium".
415(define libvpx/chromium
416 (package
417 (inherit libvpx)
1155a883 418 (version "1.9.0-104-gb5d77a48d")
91bfb6d1
MB
419 (source (origin
420 (inherit (package-source libvpx))
421 (uri (git-reference
422 (url "https://chromium.googlesource.com/webm/libvpx")
423 (commit (string-append "v" version))))
424 (file-name (git-file-name "libvpx" version))
425 (sha256
426 (base32
1155a883 427 "07nkpx8myw5nd4bkaj6l4wr5ipk2c6lg9cwirz0i5qbr659051rk"))))))
91bfb6d1 428
71c237bd
MB
429;; 'make-ld-wrapper' can only work with an 'ld' executable, so we need
430;; this trick to make it wrap 'lld'.
e165a249
MB
431(define (make-lld-wrapper lld)
432 (define lld-as-ld
433 (computed-file "lld-ld"
434 #~(begin
435 (mkdir #$output)
436 (mkdir (string-append #$output "/bin"))
437 (symlink #$(file-append lld "/bin/lld")
438 (string-append #$output "/bin/ld")))))
439
440 ;; Create a wrapper for LLD that inserts appropriate -rpath entries.
441 (define lld-wrapper
442 (make-ld-wrapper "lld-wrapper"
443 #:binutils lld-as-ld))
444
445 ;; Clang looks for an 'ld.lld' executable, so we need to symlink it back.
71c237bd
MB
446 (computed-file "lld-wrapped"
447 #~(begin
448 (mkdir #$output)
449 (mkdir (string-append #$output "/bin"))
450 (symlink #$(file-append lld-wrapper "/bin/ld")
451 (string-append #$output "/bin/lld"))
452 (symlink "lld" (string-append #$output "/bin/ld.lld")))))
453
f1e9de4d
MB
454(define-public ungoogled-chromium
455 (package
456 (name "ungoogled-chromium")
1155a883 457 (version %ungoogled-revision)
f1e9de4d 458 (synopsis "Graphical web browser")
7eb8ae5f
MB
459 (source (origin
460 (method url-fetch)
461 (uri (string-append "https://commondatastorage.googleapis.com"
462 "/chromium-browser-official/chromium-"
1155a883
MB
463 (string-drop-right %ungoogled-revision 2)
464 ".tar.xz"))
7eb8ae5f
MB
465 (sha256
466 (base32
b7bcd1ec 467 "007df9p78bbmk3iyfi8qn57mmn68qqrdhx6z8n2hl8ksd7lspw7j"))
7eb8ae5f
MB
468 (modules '((guix build utils)))
469 (snippet (force ungoogled-chromium-snippet))))
f1e9de4d
MB
470 (build-system gnu-build-system)
471 (arguments
472 `(#:tests? #f
f8157512 473 ;; FIXME: Chromiums RUNPATH lacks entries for some libraries.
f1e9de4d
MB
474 #:validate-runpath? #f
475 #:modules ((guix build gnu-build-system)
476 (guix build utils)
f1e9de4d
MB
477 (srfi srfi-26))
478 #:configure-flags
479 ;; See tools/gn/docs/cookbook.md and
480 ;; https://www.chromium.org/developers/gn-build-configuration
689d8845 481 ;; for usage. Run "gn args . --list" in the Release
f1e9de4d
MB
482 ;; directory for an exhaustive list of supported flags.
483 ;; (Note: The 'configure' phase will do that for you.)
484 (list "is_debug=false"
71c237bd
MB
485 ;; Use the "official" release optimizations, as opposed to
486 ;; a developer build.
487 "is_official_build=true"
f613d459 488 "clang_use_chrome_plugins=false"
689d8845 489 "chrome_pgo_phase=0"
f1e9de4d 490 "use_sysroot=false"
f1e9de4d
MB
491 "goma_dir=\"\""
492 "enable_nacl=false"
493 "enable_nacl_nonsfi=false"
f1e9de4d
MB
494 "use_unofficial_version_number=false"
495 "treat_warnings_as_errors=false"
496 "use_official_google_api_keys=false"
497 "fieldtrial_testing_like_official_build=true"
498 "safe_browsing_mode=0"
499 "enable_mdns=false"
500 "enable_one_click_signin=false"
501 "enable_reading_list=false"
502 "enable_remoting=false"
503 "enable_reporting=false"
504 "enable_service_discovery=false"
136eeb0b 505 "enable_vr=false"
78a64543 506 "enable_widevine=false"
f1e9de4d 507 ;; Disable type-checking for the Web UI to avoid a Java dependency.
f01ec472 508 "enable_js_type_check=false"
f1e9de4d
MB
509
510 ;; Define a custom toolchain that simply looks up CC, AR and
511 ;; friends from the environment.
512 "custom_toolchain=\"//build/toolchain/linux/unbundle:default\""
513 "host_toolchain=\"//build/toolchain/linux/unbundle:default\""
f1e9de4d
MB
514
515 ;; Prefer system libraries.
516 "use_system_freetype=true"
517 "use_system_harfbuzz=true"
518 "use_system_lcms2=true"
519 "use_system_libdrm=true"
520 "use_system_libjpeg=true"
ca86b0ba 521 "use_system_libopenjpeg2=true"
f1e9de4d 522 "use_system_libpng=true"
689d8845
MB
523 "use_system_wayland_scanner=true"
524 (string-append "system_wayland_scanner_path=\""
525 (assoc-ref %build-inputs "wayland-scanner")
526 "/bin/wayland-scanner\"")
527
f1e9de4d
MB
528 "use_system_zlib=true"
529 "use_gnome_keyring=false" ;deprecated by libsecret
f1e9de4d
MB
530 "use_pulseaudio=true"
531 "link_pulseaudio=true"
75527eb1 532 "icu_use_data_file=false"
71c237bd
MB
533
534 ;; FIXME: Using system protobuf with "is_official_build" causes an
535 ;; invalid opcode and "protoc-gen-plugin: Plugin killed by signal 4".
536 ;;"perfetto_use_system_protobuf=true"
799aebd7
MB
537
538 ;; VA-API acceleration is currently only supported on x86_64-linux.
539 ,@(if (string-prefix? "x86_64" (or (%current-target-system)
540 (%current-system)))
541 '("use_vaapi=true")
542 '())
f1e9de4d 543
1155a883
MB
544 "media_use_ffmpeg=true"
545 "media_use_libvpx=true"
546 "media_use_openh264=true"
547
7f2e8522 548 ;; Do not artifically restrict formats supported by system ffmpeg.
f1e9de4d
MB
549 "proprietary_codecs=true"
550 "ffmpeg_branding=\"Chrome\""
551
552 ;; WebRTC stuff.
553 "rtc_use_h264=true"
689d8845
MB
554 "rtc_use_pipewire=true"
555 "rtc_link_pipewire=true"
1155a883 556 "rtc_pipewire_version=\"0.3\""
f1e9de4d 557 ;; Don't use bundled sources.
f01ec472 558 "rtc_build_json=true" ;FIXME: libc++ std::string ABI difference
f1e9de4d
MB
559 "rtc_build_libevent=false"
560 "rtc_build_libvpx=false"
561 "rtc_build_opus=false"
f1e9de4d
MB
562 "rtc_build_libsrtp=true" ;FIXME: fails to find headers
563 "rtc_build_usrsctp=true" ;TODO: package this
1155a883 564 "rtc_build_ssl=true") ;XXX: the bundled BoringSSL is required?
f1e9de4d
MB
565 #:phases
566 (modify-phases %standard-phases
567 (add-after 'unpack 'patch-stuff
f8157512 568 (lambda _
f1e9de4d
MB
569 (substitute*
570 '("base/process/launch_posix.cc"
571 "base/third_party/dynamic_annotations/dynamic_annotations.c"
572 "sandbox/linux/seccomp-bpf/sandbox_bpf.cc"
573 "sandbox/linux/services/credentials.cc"
574 "sandbox/linux/services/namespace_utils.cc"
575 "sandbox/linux/services/syscall_wrappers.cc"
576 "sandbox/linux/syscall_broker/broker_host.cc")
577 (("include \"base/third_party/valgrind/") "include \"valgrind/"))
578
579 (for-each (lambda (file)
580 (substitute* file
581 ;; Fix opus include path.
582 ;; Do not substitute opus_private.h.
583 (("#include \"opus\\.h\"")
584 "#include \"opus/opus.h\"")
585 (("#include \"opus_custom\\.h\"")
586 "#include \"opus/opus_custom.h\"")
587 (("#include \"opus_defines\\.h\"")
588 "#include \"opus/opus_defines.h\"")
589 (("#include \"opus_multistream\\.h\"")
590 "#include \"opus/opus_multistream.h\"")
591 (("#include \"opus_types\\.h\"")
592 "#include \"opus/opus_types.h\"")))
593 (find-files (string-append "third_party/webrtc/modules"
594 "/audio_coding/codecs/opus")))
595
ba261f63
MB
596 ;; Many files try to include ICU headers from "third_party/icu/...".
597 ;; Remove the "third_party/" prefix to use system headers instead.
598 (substitute* (find-files "chrome" "\\.cc$")
599 (("third_party/icu/source/(common|i18n)/")
600 ""))
601
f1e9de4d 602 ;; XXX: Should be unnecessary when use_system_lcms2=true.
ba261f63 603 (substitute* "third_party/pdfium/core/fxcodec/icc/iccmodule.h"
f1e9de4d
MB
604 (("include \"third_party/lcms/include/lcms2\\.h\"")
605 "include \"lcms2.h\""))
606
607 (substitute*
608 "third_party/breakpad/breakpad/src/common/linux/libcurl_wrapper.h"
f01ec472
MB
609 (("include \"third_party/curl")
610 "include \"curl"))
f1e9de4d 611
7f2e8522 612 (substitute* '("components/viz/common/gpu/vulkan_context_provider.h"
c91c132f
MB
613 "components/viz/common/resources/resource_format_utils.h"
614 "gpu/config/gpu_util.cc")
615 (("third_party/vulkan_headers/include/") ""))
f1e9de4d 616
105fa9fc 617 (substitute* "third_party/skia/include/gpu/vk/GrVkVulkan.h"
7f2e8522 618 (("include/third_party/vulkan/") ""))
105fa9fc 619
f1e9de4d 620 #t))
f8157512
MB
621 (add-after 'patch-stuff 'add-absolute-references
622 (lambda* (#:key inputs #:allow-other-keys)
623 (let ((cups (assoc-ref inputs "cups"))
624 (nss (assoc-ref inputs "nss"))
625 (mesa (assoc-ref inputs "mesa"))
626 (udev (assoc-ref inputs "udev")))
627 (substitute* "printing/cups_config_helper.py"
628 (("cups_config =.*")
629 (string-append "cups_config = '" cups
630 "/bin/cups-config'\n")))
631 (substitute* "crypto/nss_util.cc"
632 (("libnssckbi\\.so")
633 (string-append nss "/lib/nss/libnssckbi.so")))
634 (substitute* "device/udev_linux/udev1_loader.cc"
635 (("libudev\\.so\\.1")
636 (string-append udev "/lib/libudev.so.1")))
b10fdd51 637
fddc8706
MB
638 (substitute*
639 '("ui/ozone/platform/x11/gl_ozone_glx.cc"
640 "ui/ozone/common/egl_util.cc"
641 "ui/gl/init/gl_initializer_linux_x11.cc"
642 "third_party/angle/src/libANGLE/renderer/gl/glx/FunctionsGLX.cpp")
b10fdd51
MB
643 (("libGL\\.so\\.1")
644 (string-append mesa "/lib/libGL.so.1"))
645 (("libEGL\\.so\\.1")
646 (string-append mesa "/lib/libEGL.so.1"))
647 (("libGLESv2\\.so\\.2")
648 (string-append mesa "/lib/libGLESv2.so.2")))
f8157512 649 #t)))
f1e9de4d
MB
650 (add-before 'configure 'prepare-build-environment
651 (lambda* (#:key inputs #:allow-other-keys)
652
f01ec472 653 ;; Define the GN toolchain.
71c237bd 654 (setenv "AR" "llvm-ar") (setenv "NM" "llvm-nm")
f613d459 655 (setenv "CC" "clang") (setenv "CXX" "clang++")
f1e9de4d 656
f01ec472
MB
657 (let ((gcc (assoc-ref inputs "gcc")))
658 ;; Remove the default compiler from CPLUS_INCLUDE_PATH to
659 ;; prevent header conflict with the bundled libcxx.
660 (setenv "CPLUS_INCLUDE_PATH"
661 (string-join
662 (delete (string-append gcc "/include/c++")
663 (string-split (getenv "CPLUS_INCLUDE_PATH")
664 #\:))
665 ":"))
666 (format #t
667 "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
668 (getenv "CPLUS_INCLUDE_PATH")))
669
25c93be6
MB
670 (setenv "CXXFLAGS"
671 (string-join
672 '(;; Do not optimize away null pointer safety checks.
673 "-fno-delete-null-pointer-checks"
674 ;; Disable warnings about unknown warnings that require
675 ;; Clang plugins or newer versions.
676 "-Wno-unknown-warning-option")))
7f2e8522 677
75527eb1
MB
678 (setenv "CFLAGS" "-Wno-unknown-warning-option")
679
f1e9de4d
MB
680 ;; TODO: pre-compile instead. Avoids a race condition.
681 (setenv "PYTHONDONTWRITEBYTECODE" "1")
682
683 ;; XXX: How portable is this.
684 (mkdir-p "third_party/node/linux/node-linux-x64")
685 (symlink (string-append (assoc-ref inputs "node") "/bin")
686 "third_party/node/linux/node-linux-x64/bin")
687
688 #t))
689 (replace 'configure
690 (lambda* (#:key configure-flags #:allow-other-keys)
691 (let ((args (string-join configure-flags " ")))
692 ;; Generate ninja build files.
693 (invoke "gn" "gen" "out/Release"
694 (string-append "--args=" args))
695
696 ;; Print the full list of supported arguments as well as
697 ;; their current status for convenience.
698 (format #t "Dumping configure flags...\n")
699 (invoke "gn" "args" "out/Release" "--list"))))
664fa4b1
MB
700 (add-before 'build 'increase-resource-limits
701 (lambda _
ba261f63
MB
702 ;; XXX: Chromiums linking step requires a lot of simultaneous file
703 ;; accesses. Having a too low ulimit will result in bogus linker
704 ;; errors such as "foo.a: error adding symbols: malformed archive".
705
07b10725 706 ;; Try increasing the soft resource limit of max open files to 2048,
ba261f63
MB
707 ;; or equal to the hard limit, whichever is lower.
708 (call-with-values (lambda () (getrlimit 'nofile))
709 (lambda (soft hard)
07b10725 710 (when (and soft (< soft 2048))
ba261f63 711 (if hard
07b10725
MB
712 (setrlimit 'nofile (min hard 2048) hard)
713 (setrlimit 'nofile 2048 #f))
ba261f63
MB
714 (format #t
715 "increased maximum number of open files from ~d to ~d~%"
07b10725 716 soft (if hard (min hard 2048) 2048)))))
664fa4b1
MB
717 #t))
718 (replace 'build
719 (lambda* (#:key (parallel-build? #t) #:allow-other-keys)
f1e9de4d 720 (invoke "ninja" "-C" "out/Release"
9a2e5fe5
MB
721 "-j" (if parallel-build?
722 (number->string (parallel-job-count))
723 "1")
f1e9de4d
MB
724 "chrome"
725 "chromedriver")))
726 (replace 'install
727 (lambda* (#:key inputs outputs #:allow-other-keys)
728 (let* ((out (assoc-ref outputs "out"))
729 (bin (string-append out "/bin"))
730 (exe (string-append bin "/chromium"))
731 (lib (string-append out "/lib"))
732 (man (string-append out "/share/man/man1"))
733 (applications (string-append out "/share/applications"))
f01ec472
MB
734 (libs '("chrome_100_percent.pak"
735 "chrome_200_percent.pak"
736 "resources.pak"
fddc8706
MB
737 "v8_context_snapshot.bin"
738 ;; Chromium ships its own libGL
739 ;; implementation called ANGLE.
740 "libEGL.so" "libGLESv2.so"))
f1e9de4d
MB
741 (locales (string-append lib "/locales"))
742 (resources (string-append lib "/resources"))
743 (preferences (assoc-ref inputs "master-preferences"))
744 (gtk+ (assoc-ref inputs "gtk+"))
00c1793c 745 (xdg-utils (assoc-ref inputs "xdg-utils"))
f1e9de4d
MB
746 (sh (which "sh")))
747
748 (substitute* '("chrome/app/resources/manpage.1.in"
749 "chrome/installer/linux/common/desktop.template")
750 (("@@MENUNAME@@") "Chromium")
751 (("@@PACKAGE@@") "chromium")
752 (("/usr/bin/@@USR_BIN_SYMLINK_NAME@@") exe))
753
754 (mkdir-p man)
755 (copy-file "chrome/app/resources/manpage.1.in"
756 (string-append man "/chromium.1"))
757
758 (mkdir-p applications)
759 (copy-file "chrome/installer/linux/common/desktop.template"
760 (string-append applications "/chromium.desktop"))
761
762 (mkdir-p lib)
763 (copy-file preferences (string-append lib "/master_preferences"))
764
765 (with-directory-excursion "out/Release"
f01ec472 766 (for-each (cut install-file <> lib) libs)
f1e9de4d
MB
767 (copy-file "chrome" (string-append lib "/chromium"))
768
f1e9de4d
MB
769 (copy-recursively "locales" locales)
770 (copy-recursively "resources" resources)
771
772 (mkdir-p bin)
773 (symlink "../lib/chromium" exe)
774 (install-file "chromedriver" bin)
775
75527eb1
MB
776 (for-each (lambda (so)
777 (install-file so (string-append lib "/swiftshader")))
778 (find-files "swiftshader" "\\.so$"))
779
f1e9de4d 780 (wrap-program exe
f1e9de4d 781 ;; Avoid file manager crash. See <https://bugs.gnu.org/26593>.
00c1793c
LLB
782 `("XDG_DATA_DIRS" ":" prefix (,(string-append gtk+ "/share")))
783 `("PATH" ":" prefix (,(string-append xdg-utils "/bin")))))
3df7b15e
AG
784
785 (with-directory-excursion "chrome/app/theme/chromium"
786 (for-each
787 (lambda (size)
788 (let ((icons (string-append out "/share/icons/hicolor/"
789 size "x" size "/apps")))
790 (mkdir-p icons)
791 (copy-file (string-append "product_logo_" size ".png")
792 (string-append icons "/chromium.png"))))
ba261f63 793 '("24" "48" "64" "128" "256")))
3df7b15e 794 #t))))))
f1e9de4d
MB
795 (native-inputs
796 `(("bison" ,bison)
f01ec472 797 ("clang" ,clang-11)
f1e9de4d
MB
798 ("gn" ,gn)
799 ("gperf" ,gperf)
e165a249 800 ("ld-wrapper" ,(make-lld-wrapper lld))
f1e9de4d
MB
801 ("ninja" ,ninja)
802 ("node" ,node)
803 ("pkg-config" ,pkg-config)
804 ("which" ,which)
f1e9de4d
MB
805
806 ;; This file contains defaults for new user profiles.
807 ("master-preferences" ,(local-file "aux-files/chromium/master-preferences.json"))
808
809 ("python-beautifulsoup4" ,python2-beautifulsoup4)
810 ("python-html5lib" ,python2-html5lib)
689d8845
MB
811 ("python" ,python-2)
812 ("wayland-scanner" ,wayland)))
f1e9de4d
MB
813 (inputs
814 `(("alsa-lib" ,alsa-lib)
815 ("atk" ,atk)
816 ("cups" ,cups)
817 ("curl" ,curl)
818 ("dbus" ,dbus)
f1e9de4d
MB
819 ("expat" ,expat)
820 ("flac" ,flac)
c91c132f 821 ("ffmpeg" ,ffmpeg)
f1e9de4d
MB
822 ("fontconfig" ,fontconfig)
823 ("freetype" ,freetype)
824 ("gdk-pixbuf" ,gdk-pixbuf)
825 ("glib" ,glib)
826 ("gtk+" ,gtk+)
827 ("harfbuzz" ,harfbuzz)
91bfb6d1 828 ("icu4c" ,icu4c-68)
f1e9de4d
MB
829 ("lcms" ,lcms)
830 ("libevent" ,libevent)
831 ("libffi" ,libffi)
832 ("libjpeg-turbo" ,libjpeg-turbo)
833 ("libpng" ,libpng)
834 ("libva" ,libva)
91bfb6d1 835 ("libvpx" ,libvpx/chromium)
f1e9de4d
MB
836 ("libwebp" ,libwebp)
837 ("libx11" ,libx11)
838 ("libxcb" ,libxcb)
839 ("libxcomposite" ,libxcomposite)
840 ("libxcursor" ,libxcursor)
841 ("libxdamage" ,libxdamage)
842 ("libxext" ,libxext)
843 ("libxfixes" ,libxfixes)
844 ("libxi" ,libxi)
845 ("libxml2" ,libxml2)
846 ("libxrandr" ,libxrandr)
847 ("libxrender" ,libxrender)
848 ("libxscrnsaver" ,libxscrnsaver)
849 ("libxslt" ,libxslt)
850 ("libxtst" ,libxtst)
851 ("mesa" ,mesa)
852 ("minizip" ,minizip)
853 ("mit-krb5" ,mit-krb5)
854 ("nss" ,nss)
855 ("openh264" ,openh264)
856 ("openjpeg" ,openjpeg) ;PDFium only
f1e9de4d
MB
857 ("opus" ,opus+custom)
858 ("pango" ,pango)
859 ("pciutils" ,pciutils)
1155a883 860 ("pipewire" ,pipewire-0.3)
f1e9de4d 861 ("pulseaudio" ,pulseaudio)
f1e9de4d
MB
862 ("snappy" ,snappy)
863 ("speech-dispatcher" ,speech-dispatcher)
864 ("udev" ,eudev)
865 ("valgrind" ,valgrind)
689d8845 866 ("vulkan-headers" ,vulkan-headers)
00c1793c
LLB
867 ("wayland" ,wayland)
868 ("xdg-utils" ,xdg-utils)))
867e3830
MB
869 (native-search-paths
870 (list (search-path-specification
871 (variable "CHROMIUM_EXTENSION_DIRECTORY")
872 (separator #f) ;single entry
873 (files '("share/chromium/extensions")))))
c94cc6de 874
760d90cc
MB
875 ;; Building Chromium takes ... a very long time. On a single core, a busy
876 ;; mid-end x86 system may need more than 24 hours to complete the build.
a009a3ee
MB
877 (properties '((timeout . 144000) ;40 hours
878 ;; The linking step may take more than an hour on some hardware.
acac3b94
MB
879 (max-silent-time . 7200)
880 (cpe-name . "chrome")))
c94cc6de 881
f1e9de4d
MB
882 (home-page "https://github.com/Eloston/ungoogled-chromium")
883 (description
884 "Ungoogled-Chromium is the Chromium web browser, with some functionality
885disabled in order to protect the users privacy.")
886 ;; Chromium is developed as BSD-3, but bundles a large number of third-party
887 ;; components with other licenses. For full information, see chrome://credits.
888 (license (list license:bsd-3
889 license:bsd-2
890 license:expat
891 license:asl2.0
892 license:mpl1.1
893 license:mpl2.0
894 license:public-domain
895 license:isc
896 (license:non-copyleft "chrome://credits"
897 "See chrome://credits for more information.")
898 license:lgpl2.1+))))
82ccfb1d
MB
899
900(define-public ungoogled-chromium/wayland
689d8845
MB
901 (package
902 (inherit ungoogled-chromium)
82ccfb1d 903 (name "ungoogled-chromium-wayland")
689d8845 904 (native-inputs '())
82ccfb1d 905 (inputs
689d8845
MB
906 `(("bash" ,bash-minimal)
907 ("glibc-locales" ,glibc-utf8-locales)
908 ("ungoogled-chromium" ,ungoogled-chromium)))
909 (build-system trivial-build-system)
82ccfb1d 910 (arguments
689d8845
MB
911 '(#:modules ((guix build utils))
912 #:builder
913 (begin
914 (use-modules (guix build utils))
915 (let* ((bash (assoc-ref %build-inputs "bash"))
916 (chromium (assoc-ref %build-inputs "ungoogled-chromium"))
917 (locales (assoc-ref %build-inputs "glibc-locales"))
918 (out (assoc-ref %outputs "out"))
919 (exe (string-append out "/bin/chromium")))
920
921 ;; Use a Unicode locale so we can substitute the file below.
922 (setenv "GUIX_LOCPATH" (string-append locales "/lib/locale"))
923 (setlocale LC_ALL "en_US.utf8")
924
925 (mkdir-p (dirname exe))
926 (symlink (string-append chromium "/bin/chromedriver")
927 (string-append out "/bin/chromedriver"))
928
929 (call-with-output-file exe
930 (lambda (port)
931 (format port "#!~a
932exec ~a --enable-features=UseOzonePlatform --ozone-platform=wayland $@"
933 (string-append bash "/bin/bash")
934 (string-append chromium "/bin/chromium"))))
935 (chmod exe #o555)
936
937 ;; Provide the manual and .desktop file.
938 (copy-recursively (string-append chromium "/share")
939 (string-append out "/share"))
940 (substitute* (string-append
941 out "/share/applications/chromium.desktop")
942 ((chromium) out))
943 #t))))))