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