Commit | Line | Data |
---|---|---|
f1e9de4d MB |
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 | #:system system | |
224 | #:guile-for-build guile))) | |
225 | ||
226 | (define %chromium-version "72.0.3626.109") | |
227 | (define %ungoogled-revision "a58db880c15e5077e881cad7b07d1a277ecd463a") | |
228 | ||
229 | ;; This is a "computed" origin that does the following: | |
230 | ;; 1) Runs the Ungoogled scripts on a pristine Chromium tarball. | |
231 | ;; 2) Prunes all third_party folders that are not explicitly preserved. | |
232 | ;; 3) Adjusts "GN" build files such that system libraries are preferred. | |
233 | (define ungoogled-chromium-source | |
234 | (let* ((chromium-source | |
235 | (origin | |
236 | (method url-fetch) | |
237 | (uri (string-append "https://commondatastorage.googleapis.com" | |
238 | "/chromium-browser-official/chromium-" | |
239 | %chromium-version ".tar.xz")) | |
240 | (sha256 | |
241 | (base32 | |
242 | "0bcc0iksk2v30drwd5zbw7v6sfbw16jqllc12ks2nifrvh058jjp")))) | |
243 | (ungoogled-source | |
244 | (origin | |
245 | (method git-fetch) | |
246 | (uri (git-reference (url "https://github.com/Eloston/ungoogled-chromium") | |
247 | (commit %ungoogled-revision))) | |
248 | (file-name (git-file-name "ungoogled-chromium" | |
249 | (string-take %ungoogled-revision 7))) | |
250 | (sha256 | |
251 | (base32 | |
252 | "19w60b71rcccp32b7rcpw75kfg4sw2xfr32rfk0hcyaj5rq0mm69"))))) | |
253 | ||
254 | (origin | |
255 | (method computed-origin-method) | |
256 | (file-name (string-append "ungoogled-chromium-" %chromium-version ".tar.xz")) | |
257 | (sha256 #f) | |
258 | (uri | |
259 | (delay | |
260 | (with-imported-modules '((guix build utils)) | |
261 | #~(begin | |
262 | (use-modules (guix build utils)) | |
263 | (let ((chromium-dir (string-append "chromium-" #$%chromium-version)) | |
264 | (preserved-files (list #$@%preserved-third-party-files))) | |
265 | ||
266 | (set-path-environment-variable | |
267 | "PATH" '("bin") | |
268 | (list #+(canonical-package patch) | |
269 | #+(canonical-package xz) | |
270 | #+(canonical-package tar) | |
271 | #+python-2 | |
272 | #+python)) | |
273 | ||
274 | (copy-recursively #+ungoogled-source "/tmp/ungoogled") | |
275 | ||
276 | (with-directory-excursion "/tmp/ungoogled" | |
277 | ||
278 | ;; Create a custom "bundle" that inherits from linux_rooted | |
279 | ;; and adds an additional patch. | |
280 | (format #t "Creating Guix config bundle...~%") | |
281 | (force-output) | |
282 | (mkdir-p "config_bundles/guix") | |
283 | (call-with-output-file "config_bundles/guix/bundlemeta.ini" | |
284 | (lambda (port) | |
285 | (format port | |
286 | "[bundle] | |
287 | display_name = GNU Guix | |
288 | depends = linux_rooted\n"))) | |
289 | (call-with-output-file "config_bundles/guix/patch_order.list" | |
290 | (lambda (port) | |
291 | (format port "debian_buster/system/openjpeg.patch\n"))) | |
292 | ||
293 | (format #t "Unpacking chromium tarball...~%") | |
294 | (force-output) | |
295 | (invoke "tar" "xf" #+chromium-source) | |
296 | ||
297 | (format #t "Ungooglifying...~%") | |
298 | (force-output) | |
299 | (invoke "python3" "run_buildkit_cli.py" "prune" | |
300 | "-b" "config_bundles/guix" chromium-dir) | |
301 | (invoke "python3" "run_buildkit_cli.py" "patches" "apply" | |
302 | "-b" "config_bundles/guix" chromium-dir) | |
303 | (invoke "python3" "run_buildkit_cli.py" "domains" "apply" | |
304 | "-b" "config_bundles/linux_rooted" | |
305 | "-c" "/tmp/domainscache.tar.gz" chromium-dir) | |
306 | ||
307 | (with-directory-excursion chromium-dir | |
308 | (format #t "Pruning third party files...~%") | |
309 | (force-output) | |
310 | (apply invoke "python" | |
311 | "build/linux/unbundle/remove_bundled_libraries.py" | |
312 | "--do-remove" preserved-files) | |
313 | ||
314 | (format #t "Replacing GN files...~%") | |
315 | (force-output) | |
316 | (invoke "python3" "build/linux/unbundle/replace_gn_files.py" | |
317 | "--system-libraries" "ffmpeg" "flac" "fontconfig" | |
318 | "freetype" "harfbuzz-ng" "icu" "libdrm" "libevent" | |
319 | "libjpeg" "libpng" "libvpx" "libwebp" "libxml" | |
320 | "libxslt" "openh264" "opus" "re2" "snappy" "yasm" | |
321 | "zlib")) | |
322 | ||
323 | (format #t (string-append "Packing new ungoogled tarball ...~%")) | |
324 | (force-output) | |
325 | (invoke "tar" "cvfa" #$output | |
326 | ;; Avoid non-determinism in the archive. | |
327 | "--mtime=@0" | |
328 | "--owner=root:0" | |
329 | "--group=root:0" | |
330 | "--sort=name" | |
331 | chromium-dir) | |
332 | ||
333 | #t))))))))) | |
334 | ||
335 | (define opus+custom | |
336 | (package/inherit opus | |
337 | (name "opus+custom") | |
338 | (arguments | |
339 | (substitute-keyword-arguments (package-arguments opus) | |
340 | ((#:configure-flags flags ''()) | |
341 | ;; Opus Custom is an optional extension of the Opus | |
342 | ;; specification that allows for unsupported frame | |
343 | ;; sizes. Chromium requires that this is enabled. | |
344 | `(cons "--enable-custom-modes" | |
345 | ,flags)))))) | |
346 | ||
347 | (define-public ungoogled-chromium | |
348 | (package | |
349 | (name "ungoogled-chromium") | |
350 | (version %chromium-version) | |
351 | (synopsis "Graphical web browser") | |
352 | (source ungoogled-chromium-source) | |
353 | (build-system gnu-build-system) | |
354 | (arguments | |
355 | `(#:tests? #f | |
356 | ;; FIXME: Chromiums RUNPATH lacks entries for some libraries, so | |
357 | ;; we have to disable validation and add a wrapper below. | |
358 | #:validate-runpath? #f | |
359 | #:modules ((guix build gnu-build-system) | |
360 | (guix build utils) | |
361 | (ice-9 ftw) | |
362 | (ice-9 regex) | |
363 | (srfi srfi-26)) | |
364 | #:configure-flags | |
365 | ;; See tools/gn/docs/cookbook.md and | |
366 | ;; https://www.chromium.org/developers/gn-build-configuration | |
367 | ;; for usage. Run "./gn args . --list" in the Release | |
368 | ;; directory for an exhaustive list of supported flags. | |
369 | ;; (Note: The 'configure' phase will do that for you.) | |
370 | (list "is_debug=false" | |
371 | "use_gold=false" | |
372 | "use_lld=false" | |
373 | "linux_use_bundled_binutils=false" | |
374 | "use_custom_libcxx=false" | |
375 | "use_sysroot=false" | |
376 | "enable_precompiled_headers=false" | |
377 | "goma_dir=\"\"" | |
378 | "enable_nacl=false" | |
379 | "enable_nacl_nonsfi=false" | |
380 | "use_allocator=\"none\"" | |
381 | "use_unofficial_version_number=false" | |
382 | "treat_warnings_as_errors=false" | |
383 | "use_official_google_api_keys=false" | |
384 | "fieldtrial_testing_like_official_build=true" | |
385 | "safe_browsing_mode=0" | |
386 | "enable_mdns=false" | |
387 | "enable_one_click_signin=false" | |
388 | "enable_reading_list=false" | |
389 | "enable_remoting=false" | |
390 | "enable_reporting=false" | |
391 | "enable_service_discovery=false" | |
392 | "enable_swiftshader=false" | |
393 | ;; Disable type-checking for the Web UI to avoid a Java dependency. | |
394 | "closure_compile=false" | |
395 | ||
396 | ;; Define a custom toolchain that simply looks up CC, AR and | |
397 | ;; friends from the environment. | |
398 | "custom_toolchain=\"//build/toolchain/linux/unbundle:default\"" | |
399 | "host_toolchain=\"//build/toolchain/linux/unbundle:default\"" | |
400 | ;; Don't assume it's clang. | |
401 | "is_clang=false" | |
402 | ;; Disable debugging features to save space. These are normally | |
403 | ;; pulled in by "is_official_build", but that requires "is_clang". | |
404 | "blink_symbol_level=0" | |
405 | "enable_iterator_debugging=false" | |
406 | "exclude_unwind_tables=true" | |
407 | ;; Optimize for building everything at once, as opposed to | |
408 | ;; incrementally for development. See "docs/jumbo.md". | |
409 | "use_jumbo_build=true" | |
410 | ||
411 | ;; Prefer system libraries. | |
412 | "use_system_freetype=true" | |
413 | "use_system_harfbuzz=true" | |
414 | "use_system_lcms2=true" | |
415 | "use_system_libdrm=true" | |
416 | "use_system_libjpeg=true" | |
417 | "use_system_libpng=true" | |
418 | "use_system_zlib=true" | |
419 | "use_gnome_keyring=false" ;deprecated by libsecret | |
420 | "use_openh264=true" | |
421 | "use_pulseaudio=true" | |
422 | "link_pulseaudio=true" | |
423 | "use_vaapi=true" | |
424 | ||
425 | ;; Don't arbitrarily restrict formats supported by system ffmpeg. | |
426 | "proprietary_codecs=true" | |
427 | "ffmpeg_branding=\"Chrome\"" | |
428 | ||
429 | ;; WebRTC stuff. | |
430 | "rtc_use_h264=true" | |
431 | ;; Don't use bundled sources. | |
432 | "rtc_build_json=false" | |
433 | "rtc_build_libevent=false" | |
434 | "rtc_build_libvpx=false" | |
435 | "rtc_build_opus=false" | |
436 | "rtc_build_ssl=false" | |
437 | "rtc_build_libsrtp=true" ;FIXME: fails to find headers | |
438 | "rtc_build_usrsctp=true" ;TODO: package this | |
439 | (string-append "rtc_jsoncpp_root=\"" | |
440 | (assoc-ref %build-inputs "jsoncpp") | |
441 | "/include/jsoncpp/json\"") | |
442 | (string-append "rtc_ssl_root=\"" | |
443 | (assoc-ref %build-inputs "openssl") | |
444 | "/include/openssl\"")) | |
445 | #:phases | |
446 | (modify-phases %standard-phases | |
447 | (add-after 'unpack 'patch-stuff | |
448 | (lambda* (#:key inputs #:allow-other-keys) | |
449 | (substitute* "printing/cups_config_helper.py" | |
450 | (("cups_config =.*") | |
451 | (string-append "cups_config = '" (assoc-ref inputs "cups") | |
452 | "/bin/cups-config'\n"))) | |
453 | ||
454 | (substitute* | |
455 | '("base/process/launch_posix.cc" | |
456 | "base/third_party/dynamic_annotations/dynamic_annotations.c" | |
457 | "sandbox/linux/seccomp-bpf/sandbox_bpf.cc" | |
458 | "sandbox/linux/services/credentials.cc" | |
459 | "sandbox/linux/services/namespace_utils.cc" | |
460 | "sandbox/linux/services/syscall_wrappers.cc" | |
461 | "sandbox/linux/syscall_broker/broker_host.cc") | |
462 | (("include \"base/third_party/valgrind/") "include \"valgrind/")) | |
463 | ||
464 | (for-each (lambda (file) | |
465 | (substitute* file | |
466 | ;; Fix opus include path. | |
467 | ;; Do not substitute opus_private.h. | |
468 | (("#include \"opus\\.h\"") | |
469 | "#include \"opus/opus.h\"") | |
470 | (("#include \"opus_custom\\.h\"") | |
471 | "#include \"opus/opus_custom.h\"") | |
472 | (("#include \"opus_defines\\.h\"") | |
473 | "#include \"opus/opus_defines.h\"") | |
474 | (("#include \"opus_multistream\\.h\"") | |
475 | "#include \"opus/opus_multistream.h\"") | |
476 | (("#include \"opus_types\\.h\"") | |
477 | "#include \"opus/opus_types.h\""))) | |
478 | (find-files (string-append "third_party/webrtc/modules" | |
479 | "/audio_coding/codecs/opus"))) | |
480 | ||
481 | (substitute* "chrome/common/chrome_paths.cc" | |
482 | (("/usr/share/chromium/extensions") | |
483 | ;; TODO: Add ~/.guix-profile. | |
484 | "/run/current-system/profile/share/chromium/extensions")) | |
485 | ||
486 | ;; XXX: Should be unnecessary when use_system_lcms2=true. | |
487 | (substitute* "third_party/pdfium/core/fxcodec/codec/ccodec_iccmodule.h" | |
488 | (("include \"third_party/lcms/include/lcms2\\.h\"") | |
489 | "include \"lcms2.h\"")) | |
490 | ||
491 | (substitute* | |
492 | "third_party/breakpad/breakpad/src/common/linux/libcurl_wrapper.h" | |
493 | (("include \"third_party/curl") "include \"curl")) | |
494 | ||
495 | (substitute* "third_party/webrtc/rtc_base/strings/json.h" | |
496 | (("#include \"third_party/jsoncpp/") "#include \"json/")) | |
497 | ||
498 | (substitute* "media/base/decode_capabilities.cc" | |
499 | (("third_party/libvpx/source/libvpx/") "")) | |
500 | ||
501 | (substitute* "ui/gfx/skia_util.h" | |
502 | (("third_party/vulkan/include/") "")) | |
503 | ||
504 | ;; Building chromedriver embeds some files using the ZIP | |
505 | ;; format which doesn't support timestamps before | |
506 | ;; 1980. Therefore, advance the timestamps of the files | |
507 | ;; which are included so that building chromedriver | |
508 | ;; works. | |
509 | (let ((circa-1980 (* 10 366 24 60 60))) | |
510 | (for-each (lambda (file) | |
511 | (utime file circa-1980 circa-1980)) | |
512 | '("chrome/test/chromedriver/extension/background.js" | |
513 | "chrome/test/chromedriver/extension/manifest.json"))) | |
514 | ||
515 | #t)) | |
516 | (add-before 'configure 'prepare-build-environment | |
517 | (lambda* (#:key inputs #:allow-other-keys) | |
518 | ||
519 | ;; Make sure the right build tools are used. | |
520 | (setenv "AR" "ar") (setenv "NM" "nm") | |
521 | (setenv "CC" "gcc") (setenv "CXX" "g++") | |
522 | ||
523 | ;; Work around <https://bugs.gnu.org/30756>. | |
524 | (unsetenv "C_INCLUDE_PATH") | |
525 | (unsetenv "CPLUS_INCLUDE_PATH") | |
526 | ||
527 | ;; TODO: pre-compile instead. Avoids a race condition. | |
528 | (setenv "PYTHONDONTWRITEBYTECODE" "1") | |
529 | ||
530 | ;; XXX: How portable is this. | |
531 | (mkdir-p "third_party/node/linux/node-linux-x64") | |
532 | (symlink (string-append (assoc-ref inputs "node") "/bin") | |
533 | "third_party/node/linux/node-linux-x64/bin") | |
534 | ||
535 | #t)) | |
536 | (replace 'configure | |
537 | (lambda* (#:key configure-flags #:allow-other-keys) | |
538 | (let ((args (string-join configure-flags " "))) | |
539 | ;; Generate ninja build files. | |
540 | (invoke "gn" "gen" "out/Release" | |
541 | (string-append "--args=" args)) | |
542 | ||
543 | ;; Print the full list of supported arguments as well as | |
544 | ;; their current status for convenience. | |
545 | (format #t "Dumping configure flags...\n") | |
546 | (invoke "gn" "args" "out/Release" "--list")))) | |
547 | (replace 'build | |
548 | (lambda* (#:key outputs #:allow-other-keys) | |
549 | (invoke "ninja" "-C" "out/Release" | |
550 | "-j" (number->string (parallel-job-count)) | |
551 | "chrome" | |
552 | "chromedriver"))) | |
553 | (replace 'install | |
554 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
555 | (let* ((out (assoc-ref outputs "out")) | |
556 | (bin (string-append out "/bin")) | |
557 | (exe (string-append bin "/chromium")) | |
558 | (lib (string-append out "/lib")) | |
559 | (man (string-append out "/share/man/man1")) | |
560 | (applications (string-append out "/share/applications")) | |
561 | (install-regexp (make-regexp "\\.(bin|pak)$")) | |
562 | (locales (string-append lib "/locales")) | |
563 | (resources (string-append lib "/resources")) | |
564 | (preferences (assoc-ref inputs "master-preferences")) | |
565 | (gtk+ (assoc-ref inputs "gtk+")) | |
566 | (mesa (assoc-ref inputs "mesa")) | |
567 | (nss (assoc-ref inputs "nss")) | |
568 | (udev (assoc-ref inputs "udev")) | |
569 | (sh (which "sh"))) | |
570 | ||
571 | (substitute* '("chrome/app/resources/manpage.1.in" | |
572 | "chrome/installer/linux/common/desktop.template") | |
573 | (("@@MENUNAME@@") "Chromium") | |
574 | (("@@PACKAGE@@") "chromium") | |
575 | (("/usr/bin/@@USR_BIN_SYMLINK_NAME@@") exe)) | |
576 | ||
577 | (mkdir-p man) | |
578 | (copy-file "chrome/app/resources/manpage.1.in" | |
579 | (string-append man "/chromium.1")) | |
580 | ||
581 | (mkdir-p applications) | |
582 | (copy-file "chrome/installer/linux/common/desktop.template" | |
583 | (string-append applications "/chromium.desktop")) | |
584 | ||
585 | (mkdir-p lib) | |
586 | (copy-file preferences (string-append lib "/master_preferences")) | |
587 | ||
588 | (with-directory-excursion "out/Release" | |
589 | (for-each (lambda (file) | |
590 | (install-file file lib)) | |
591 | (scandir "." (cut regexp-exec install-regexp <>))) | |
592 | (copy-file "chrome" (string-append lib "/chromium")) | |
593 | ||
594 | ;; TODO: Install icons from "../../chrome/app/themes" into | |
595 | ;; "out/share/icons/hicolor/$size". | |
596 | (install-file | |
597 | "product_logo_48.png" | |
598 | (string-append out "/share/icons/48x48/chromium.png")) | |
599 | ||
600 | (copy-recursively "locales" locales) | |
601 | (copy-recursively "resources" resources) | |
602 | ||
603 | (mkdir-p bin) | |
604 | (symlink "../lib/chromium" exe) | |
605 | (install-file "chromedriver" bin) | |
606 | ||
607 | (wrap-program exe | |
608 | ;; TODO: Get these in RUNPATH. | |
609 | `("LD_LIBRARY_PATH" ":" prefix | |
610 | (,(string-append lib ":" nss "/lib/nss:" mesa "/lib:" | |
611 | udev "/lib"))) | |
612 | ;; Avoid file manager crash. See <https://bugs.gnu.org/26593>. | |
613 | `("XDG_DATA_DIRS" ":" prefix (,(string-append gtk+ "/share")))) | |
614 | #t))))))) | |
615 | (native-inputs | |
616 | `(("bison" ,bison) | |
617 | ("gcc" ,gcc-8) | |
618 | ("gn" ,gn) | |
619 | ("gperf" ,gperf) | |
620 | ("ninja" ,ninja) | |
621 | ("node" ,node) | |
622 | ("pkg-config" ,pkg-config) | |
623 | ("which" ,which) | |
624 | ("yasm" ,yasm) | |
625 | ||
626 | ;; This file contains defaults for new user profiles. | |
627 | ("master-preferences" ,(local-file "aux-files/chromium/master-preferences.json")) | |
628 | ||
629 | ("python-beautifulsoup4" ,python2-beautifulsoup4) | |
630 | ("python-html5lib" ,python2-html5lib) | |
631 | ("python" ,python-2))) | |
632 | (inputs | |
633 | `(("alsa-lib" ,alsa-lib) | |
634 | ("atk" ,atk) | |
635 | ("cups" ,cups) | |
636 | ("curl" ,curl) | |
637 | ("dbus" ,dbus) | |
638 | ("dbus-glib" ,dbus-glib) | |
639 | ("expat" ,expat) | |
640 | ("flac" ,flac) | |
641 | ("ffmpeg" ,ffmpeg) | |
642 | ("fontconfig" ,fontconfig) | |
643 | ("freetype" ,freetype) | |
644 | ("gdk-pixbuf" ,gdk-pixbuf) | |
645 | ("glib" ,glib) | |
646 | ("gtk+" ,gtk+) | |
647 | ("harfbuzz" ,harfbuzz) | |
648 | ("icu4c" ,icu4c) | |
649 | ("jsoncpp" ,jsoncpp) | |
650 | ("lcms" ,lcms) | |
651 | ("libevent" ,libevent) | |
652 | ("libffi" ,libffi) | |
653 | ("libjpeg-turbo" ,libjpeg-turbo) | |
654 | ("libpng" ,libpng) | |
655 | ("libva" ,libva) | |
656 | ("libvpx" ,libvpx) | |
657 | ("libwebp" ,libwebp) | |
658 | ("libx11" ,libx11) | |
659 | ("libxcb" ,libxcb) | |
660 | ("libxcomposite" ,libxcomposite) | |
661 | ("libxcursor" ,libxcursor) | |
662 | ("libxdamage" ,libxdamage) | |
663 | ("libxext" ,libxext) | |
664 | ("libxfixes" ,libxfixes) | |
665 | ("libxi" ,libxi) | |
666 | ("libxml2" ,libxml2) | |
667 | ("libxrandr" ,libxrandr) | |
668 | ("libxrender" ,libxrender) | |
669 | ("libxscrnsaver" ,libxscrnsaver) | |
670 | ("libxslt" ,libxslt) | |
671 | ("libxtst" ,libxtst) | |
672 | ("mesa" ,mesa) | |
673 | ("minizip" ,minizip) | |
674 | ("mit-krb5" ,mit-krb5) | |
675 | ("nss" ,nss) | |
676 | ("openh264" ,openh264) | |
677 | ("openjpeg" ,openjpeg) ;PDFium only | |
678 | ("openssl" ,openssl) | |
679 | ("opus" ,opus+custom) | |
680 | ("pango" ,pango) | |
681 | ("pciutils" ,pciutils) | |
682 | ("pulseaudio" ,pulseaudio) | |
683 | ("re2" ,re2) | |
684 | ("snappy" ,snappy) | |
685 | ("speech-dispatcher" ,speech-dispatcher) | |
686 | ("udev" ,eudev) | |
687 | ("valgrind" ,valgrind) | |
688 | ("vulkan-headers" ,vulkan-headers))) | |
689 | (home-page "https://github.com/Eloston/ungoogled-chromium") | |
690 | (description | |
691 | "Ungoogled-Chromium is the Chromium web browser, with some functionality | |
692 | disabled in order to protect the users privacy.") | |
693 | ;; Chromium is developed as BSD-3, but bundles a large number of third-party | |
694 | ;; components with other licenses. For full information, see chrome://credits. | |
695 | (license (list license:bsd-3 | |
696 | license:bsd-2 | |
697 | license:expat | |
698 | license:asl2.0 | |
699 | license:mpl1.1 | |
700 | license:mpl2.0 | |
701 | license:public-domain | |
702 | license:isc | |
703 | (license:non-copyleft "chrome://credits" | |
704 | "See chrome://credits for more information.") | |
705 | license:lgpl2.1+)))) |