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