gnu: icecat: Unbundle nss and nspr.
[jackhill/guix/guix.git] / gnu / packages / gnuzilla.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2015 Andreas Enge <andreas@enge.fr>
3 ;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
4 ;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Mark H Weaver <mhw@netris.org>
5 ;;; Copyright © 2015 Sou Bunnbu <iyzsong@gmail.com>
6 ;;; Copyright © 2016, 2017, 2018, 2019, 2021 Efraim Flashner <efraim@flashner.co.il>
7 ;;; Copyright © 2016 Alex Griffin <a@ajgrf.com>
8 ;;; Copyright © 2017 Clément Lassieur <clement@lassieur.org>
9 ;;; Copyright © 2017, 2018 Nikita <nikita@n0.is>
10 ;;; Copyright © 2017, 2018, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
11 ;;; Copyright © 2018, 2020 Ricardo Wurmus <rekado@elephly.net>
12 ;;; Copyright © 2019 Ivan Petkov <ivanppetkov@gmail.com>
13 ;;; Copyright © 2020 Oleg Pykhalov <go.wigust@gmail.com>
14 ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
15 ;;; Copyright © 2019, 2020 Adrian Malacoda <malacoda@monarch-pass.net>
16 ;;; Copyright © 2020, 2021, 2022 Jonathan Brielmaier <jonathan.brielmaier@web.de>
17 ;;; Copyright © 2020, 2022 Marius Bakke <marius@gnu.org>
18 ;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re>
19 ;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
20 ;;; Copyright © 2021, 2022, 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
21 ;;; Copyright © 2021 Baptiste Strazzul <bstrazzull@hotmail.fr>
22 ;;;
23 ;;; This file is part of GNU Guix.
24 ;;;
25 ;;; GNU Guix is free software; you can redistribute it and/or modify it
26 ;;; under the terms of the GNU General Public License as published by
27 ;;; the Free Software Foundation; either version 3 of the License, or (at
28 ;;; your option) any later version.
29 ;;;
30 ;;; GNU Guix is distributed in the hope that it will be useful, but
31 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
32 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 ;;; GNU General Public License for more details.
34 ;;;
35 ;;; You should have received a copy of the GNU General Public License
36 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
37
38 (define-module (gnu packages gnuzilla)
39 #:use-module ((srfi srfi-1) #:hide (zip))
40 #:use-module (ice-9 format)
41 #:use-module (ice-9 match)
42 #:use-module (gnu packages)
43 #:use-module ((guix licenses) #:prefix license:)
44 #:use-module (guix packages)
45 #:use-module (guix download)
46 #:use-module (guix git-download)
47 #:use-module (guix hg-download)
48 #:use-module (guix gexp)
49 #:use-module (guix store)
50 #:use-module (guix modules)
51 #:use-module (guix monads)
52 #:use-module (guix utils)
53 #:use-module (guix build-system gnu)
54 #:use-module (guix build-system cargo)
55 #:use-module (guix build-system trivial)
56 #:use-module (gnu packages admin)
57 #:use-module (gnu packages audio)
58 #:use-module (gnu packages autotools)
59 #:use-module (gnu packages m4)
60 #:use-module (gnu packages base)
61 #:use-module (gnu packages bash)
62 #:use-module (gnu packages databases)
63 #:use-module (gnu packages glib)
64 #:use-module (gnu packages gtk)
65 #:use-module (gnu packages gnome)
66 #:use-module (gnu packages libcanberra)
67 #:use-module (gnu packages cups)
68 #:use-module (gnu packages kerberos)
69 #:use-module (gnu packages linux)
70 #:use-module (gnu packages perl)
71 #:use-module (gnu packages pkg-config)
72 #:use-module (gnu packages compression)
73 #:use-module (gnu packages fontutils)
74 #:use-module (gnu packages fonts)
75 #:use-module (gnu packages hunspell)
76 #:use-module (gnu packages libevent)
77 #:use-module (gnu packages image)
78 #:use-module (gnu packages libffi)
79 #:use-module (gnu packages pulseaudio)
80 #:use-module (gnu packages python)
81 #:use-module (gnu packages python-xyz)
82 #:use-module (gnu packages node)
83 #:use-module (gnu packages xorg)
84 #:use-module (gnu packages gl)
85 #:use-module (gnu packages pciutils)
86 #:use-module (gnu packages assembly)
87 #:use-module (gnu packages rust)
88 #:use-module (gnu packages rust-apps)
89 #:use-module (gnu packages llvm)
90 #:use-module (gnu packages nss)
91 #:use-module (gnu packages icu4c)
92 #:use-module (gnu packages video)
93 #:use-module (gnu packages xiph)
94 #:use-module (gnu packages xdisorg)
95 #:use-module (gnu packages readline)
96 #:use-module (gnu packages sqlite)
97 #:autoload (json parser) (json->scm))
98
99 (define-public mozjs
100 (package
101 (name "mozjs")
102 (version "102.2.0")
103 (source (origin
104 (method url-fetch)
105 ;; TODO: Switch to IceCat source once available on ftp.gnu.org.
106 (uri (string-append "https://ftp.mozilla.org/pub/firefox"
107 "/releases/" version "esr/source/firefox-"
108 version "esr.source.tar.xz"))
109 (sha256
110 (base32
111 "1zwpgis7py1bf8p88pz3mpai6a02qrdb8ww2fa9kxxdl9b8r2k81"))))
112 (build-system gnu-build-system)
113 (arguments
114 (list
115 #:imported-modules %cargo-utils-modules ;for `generate-all-checksums'
116 #:modules `((guix build cargo-utils)
117 ,@%gnu-build-system-modules)
118 #:test-target "check-jstests"
119 #:configure-flags
120 #~(list
121 ;; Disable debugging symbols to save space.
122 "--disable-debug"
123 "--disable-debug-symbols"
124 ;; This is important because without it gjs will segfault during the
125 ;; configure phase. With jemalloc only the standalone mozjs console
126 ;; will work.
127 "--disable-jemalloc"
128 "--enable-tests"
129 "--enable-hardening"
130 "--enable-optimize"
131 "--enable-release"
132 "--enable-readline"
133 "--enable-shared-js"
134 "--with-system-icu"
135 "--with-system-nspr"
136 "--with-system-zlib"
137 "--with-intl-api")
138 #:phases
139 #~(modify-phases %standard-phases
140 (add-after 'patch-source-shebangs 'patch-cargo-checksums
141 (lambda _
142 (let ((null-hash
143 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"))
144 (for-each (lambda (file)
145 (format #t "patching checksums in ~a~%" file)
146 (substitute* file
147 (("^checksum = \".*\"")
148 (string-append "checksum = \"" null-hash "\""))))
149 (find-files "." "Cargo\\.lock$"))
150 (for-each generate-all-checksums
151 '("js" "third_party/rust")))))
152 (replace 'configure
153 (lambda* (#:key configure-flags #:allow-other-keys)
154 ;; The configure script does not accept environment variables as
155 ;; arguments. It also must be run from a different directory,
156 ;; but not the root directory either.
157 (mkdir "run-configure-from-here")
158 (chdir "run-configure-from-here")
159 (setenv "SHELL" (which "sh"))
160 (setenv "CONFIG_SHELL" (which "sh"))
161 (setenv "AUTOCONF" (which "autoconf"))
162 (apply invoke "python" "../configure.py"
163 "--enable-project=js"
164 (string-append "--prefix=" #$output)
165 configure-flags)))
166 (add-before 'check 'adjust-tests
167 (lambda _
168 (with-directory-excursion "../js/src/tests"
169 (substitute* "shell/os.js"
170 ;; FIXME: Why does the killed process have an exit status?
171 ((".*killed process should not have exitStatus.*")
172 ""))
173
174 ;; The test suite expects a lightly patched ICU. Disable tests
175 ;; that do not work with the system version. See
176 ;; "intl/icu-patches" for clues.
177
178 ;; See <https://unicode-org.atlassian.net/browse/ICU-20992> and
179 ;; <https://bugzilla.mozilla.org/show_bug.cgi?id=1636984> and
180 ;; related patch for why this is failing.
181 (delete-file "non262/Intl/DateTimeFormat/\
182 fractional-second-digits-append-item.js")
183 ;; FIXME: got "0 \u251CAM/PM: noon\u2524", expected "0 (AM/PM: noon)"
184 (delete-file "non262/Intl/DateTimeFormat/day-period-hour-cycle.js")
185 ;; FIXME: got "en-US-posix", expected "en-US-POSIX".
186 (delete-file "non262/Intl/available-locales-supported.js")
187 ;; FIXME: got "en-US", expected "en-US-POSIX"
188 (delete-file "non262/Intl/available-locales-resolved.js"))))
189 (add-before 'check 'pre-check
190 (lambda _
191 (setenv "JSTESTS_EXTRA_ARGS"
192 (string-join
193 (list
194 ;; Do not run tests marked as "random".
195 "--exclude-random"
196 ;; Exclude web platform tests.
197 "--wpt=disabled"
198 ;; Respect the daemons configured number of jobs.
199 (string-append "--worker-count="
200 (number->string (parallel-job-count)))))))))))
201 (native-inputs
202 (list autoconf
203 llvm ;for llvm-objdump
204 m4
205 perl
206 pkg-config
207 python-wrapper
208 rust
209 `(,rust "cargo")))
210 (inputs
211 (list icu4c-71 readline zlib))
212 (propagated-inputs
213 (list nspr)) ; in the Requires.private field of mozjs-*.pc
214 (home-page
215 "https://spidermonkey.dev/")
216 (synopsis "Mozilla JavaScript engine")
217 (description "SpiderMonkey is Mozilla's JavaScript engine written
218 in C/C++.")
219 (license license:mpl2.0))) ; and others for some files
220
221 (define-public mozjs-91
222 (package
223 (inherit mozjs)
224 (version "91.13.0")
225 (source (origin
226 (method url-fetch)
227 (uri (string-append "https://ftp.mozilla.org/pub/firefox"
228 "/releases/" version "esr/source/firefox-"
229 version "esr.source.tar.xz"))
230 (sha256
231 (base32
232 "0qh7j960wdp5zcfqhkj8ki47spp9i9ms12xx0v0kxvmmw36jpgjk"))))
233 (arguments
234 (substitute-keyword-arguments (package-arguments mozjs)
235 ((#:phases phases)
236 #~(modify-phases #$phases
237 (add-before 'check 'disable-timezone-tests
238 (lambda _
239 (with-directory-excursion "../js/src/tests"
240 ;; FIXME: Assertion failed: got "2021a", expected "2021a3"?
241 (delete-file "non262/Intl/DateTimeFormat/timeZone_version.js")
242 ;; XXX: Delete all tests that test time zone functionality,
243 ;; because the test suite uses /etc/localtime to figure out
244 ;; the offset from the hardware clock, which does not work
245 ;; in the build container. See <tests/non262/Date/shell.js>.
246 (delete-file-recursively "non262/Date")
247 (delete-file
248 "non262/Intl/DateTimeFormat/tz-environment-variable.js"))))))))
249 (inputs (modify-inputs (package-inputs mozjs)
250 (replace "icu4c" icu4c)))))
251
252 (define-public mozjs-78
253 (package
254 (inherit mozjs)
255 (name "mozjs")
256 (version "78.15.0")
257 (source (origin
258 (method url-fetch)
259 (uri (string-append "https://archive.mozilla.org/pub/firefox"
260 "/releases/" version "esr/source/firefox-"
261 version "esr.source.tar.xz"))
262 (sha256
263 (base32
264 "0l91cxdc5v9fps79ckb1kid4gw6v5qng1jd9zvaacwaiv628shx4"))))
265 (build-system gnu-build-system)
266 (arguments
267 (substitute-keyword-arguments (package-arguments mozjs)
268 ((#:phases phases)
269 #~(modify-phases #$phases
270 (replace 'configure
271 (lambda* (#:key configure-flags #:allow-other-keys)
272 ;; The configure script does not accept environment variables as
273 ;; arguments. It also must be run from a different directory,
274 ;; but not the root directory either.
275 (mkdir "run-configure-from-here")
276 (chdir "run-configure-from-here")
277 (setenv "SHELL" (which "sh"))
278 (setenv "CONFIG_SHELL" (which "sh"))
279 (setenv "AUTOCONF" (which "autoconf"))
280 (apply invoke "../js/src/configure"
281 (cons (string-append "--prefix=" #$output)
282 configure-flags))))
283 (replace 'adjust-tests
284 (lambda _
285 (with-directory-excursion "../js/src/tests"
286 ;; The test suite expects a lightly patched ICU 67. Since
287 ;; Guix is about to switch to ICU 68, massage the tests to
288 ;; work with that instead of patching ICU. Try removing this
289 ;; phase for newer versions of mozjs.
290
291 ;; These tests look up locale names and expects to get
292 ;; "GB" instead of "UK".
293 (substitute* "non262/Intl/DisplayNames/language.js"
294 (("Traditionell, GB")
295 "Traditionell, UK"))
296 (substitute* "non262/Intl/DisplayNames/region.js"
297 (("\"GB\": \"GB\"")
298 "\"GB\": \"UK\""))
299
300 ;; XXX: Some localized time formats have changed, and
301 ;; substitution fails for accented characters, even though
302 ;; it works in the REPL(?). Just delete these for now.
303 (delete-file "non262/Intl/Date/toLocaleString_timeZone.js")
304 (delete-file "non262/Intl/Date/toLocaleDateString_timeZone.js")
305
306 ;; Similarly, these get an unexpected "A" suffix when looking
307 ;; up a time in the "ar-MA-u-ca-islamicc" locale, which is
308 ;; tricky to substitute.
309 (delete-file "non262/Intl/DateTimeFormat/format_timeZone.js")
310 (delete-file "non262/Intl/DateTimeFormat/format.js")
311
312 ;; This file compares a generated list of ICU locale names
313 ;; with actual lookups. Some have changed slightly, i.e.
314 ;; daf-Latn-ZZ -> daf-Latn-CI, so drop it for simplicity.
315 (delete-file "non262/Intl/Locale/likely-subtags-generated.js"))))
316 (replace 'pre-check
317 (lambda _
318 (with-directory-excursion "../js/src/tests"
319 (substitute* "shell/os.js"
320 ;; FIXME: Why does the killed process have an exit status?
321 ((".*killed process should not have exitStatus.*")
322 ""))
323
324 ;; XXX: Delete all tests that test time zone functionality,
325 ;; because the test suite uses /etc/localtime to figure out
326 ;; the offset from the hardware clock, which does not work
327 ;; in the build container. See <tests/non262/Date/shell.js>.
328 (delete-file-recursively "non262/Date")
329 (delete-file "non262/Intl/DateTimeFormat/tz-environment-variable.js")
330
331 (setenv "JSTESTS_EXTRA_ARGS"
332 (string-join
333 (list
334 ;; Do not run tests marked as "random".
335 "--exclude-random"
336 ;; Exclude web platform tests.
337 "--wpt=disabled"
338 ;; Respect the daemons configured number of jobs.
339 (string-append "--worker-count="
340 (number->string
341 (parallel-job-count)))))))))))))
342 (native-inputs
343 (list autoconf-2.13
344 automake
345 llvm ;for llvm-objdump
346 perl
347 pkg-config
348 python-3
349 rust
350 `(,rust "cargo")))
351 (inputs
352 (list icu4c readline zlib))))
353
354 \f
355 ;;;
356 ;;; Localization helper procedures.
357 ;;;
358 (define mozilla-compare-locales
359 (origin
360 (method hg-fetch)
361 (uri (hg-reference
362 (url "https://hg.mozilla.org/l10n/compare-locales/")
363 (changeset "RELEASE_8_1_0")))
364 (file-name "mozilla-compare-locales")
365 (sha256 (base32 "00bpkaqf2ng1nn9ajyb5mli0jq58q5fm2n3yy90jy0hp4q2gbs50"))))
366
367 (define (mozilla-locale locale changeset hash-string)
368 (origin
369 (method hg-fetch)
370 (uri (hg-reference
371 (url (string-append "https://hg.mozilla.org/l10n-central/"
372 locale))
373 (changeset changeset)))
374 (file-name (string-append "mozilla-locale-" locale))
375 (sha256 (base32 hash-string))))
376
377 (define-syntax-rule (mozilla-locales (hash-string changeset locale) ...)
378 (list (mozilla-locale locale changeset hash-string)
379 ...))
380
381 (define (update-mozilla-locales changesets.json)
382 "Output a new list of Mozilla locales, to update the ALL-MOZILLA-LOCALES
383 variable defined below. It requires guile-json to be installed."
384 (match (call-with-input-file changesets.json json->scm)
385 (((lang ("revision" . revision) platforms pin) ...)
386 (let ((data (reverse (map (lambda (rev lang)
387 `(,(list->string (make-list 40 #\0))
388 ,(string-take rev 12) ,lang))
389 revision lang))))
390 (format #t "~{~s~%~}" data)
391 data))))
392
393 (define all-mozilla-locales
394 (mozilla-locales
395 ;; sha256 changeset locale
396 ;;---------------------------------------------------------------------------
397 ("1s59ihmj8x6z0ssq4xav689jb5azrpdnay8csgjm1b9pw7wmvcli" "a6940ae1a02f" "ach")
398 ("1cqixlk9f8p63jz20wzsvnfb7xa82ba725gzdydlwz2axgp09c26" "4e2c7d1ddbed" "af")
399 ("19r1yhmfxqasyslc8gr9as5w1scscz1xr8iqy9zi4b90fdjzs0ac" "06897e40a7ea" "an")
400 ("0nfknb1p03j9fgmkwlm1mzdyh10g0l33x34ab39kc072apziyv0n" "9272819b09e2" "ar")
401 ("11qqblqfffbmkdr5b6mxzq02i8rj1hjq3iy6xv5i5xxy311b3vpb" "f706d22e6910" "ast")
402 ("0q2p1a437qr2nshdd4934qkv2sblmykiwzir149c8p9m5sjk0dyw" "f5c2a9800add" "az")
403 ("0gxxm3lv18kj0922bw0g897azc4nkrszm5irgwdkgmkbyr97li83" "98ba7d51484f" "be")
404 ("10vrbbaabjns824ndya6c09znm815pak2xpvqgjydl3r5qvacx65" "5c79c77311cd" "bg")
405 ("1il7yyifx5xzj0v2lna315mppl5pk1vi4m9r66hdz1lzc485m1wp" "c80c87ef7193" "bn")
406 ("1p1ig4v9pczzrnnxzr20r61g7xk85k5lgnxhzgn1rx518p85xrkm" "6a1bcb9851b2" "br")
407 ("08q33bk9kdvbyc4ib58bsn2b67ki3d2yzskkf5r2n5zlglblksa2" "939779cb58d6" "bs")
408 ("1bdkywrqah85fh8kfnz163qnc02ffx0a4vlnx5pq1wg9j4f1gznf" "9a45ccf144f1" "ca")
409 ("0hhmp5dzc0rssykl0b2n9h0vfy4svwhxmhpsr3rcfpbg2s0r5h6l" "4f60e18fc248" "ca-valencia")
410 ("18phbl9raqsbys9wa8z0gq0h0pw3b55v6ngn67r4373lfc0s9cxv" "b4ef404c7de8" "cak")
411 ("0147qyw1y97mgqhkb46wblxv61lq2mvvm5n5ihwf49l5cyizi0jg" "f56ef18f05df" "cs")
412 ("08sbhnsxndlsaijnxndc367qcbrzb29m7bpkcawinz9fg6mz3573" "4f9d92f04f5e" "cy")
413 ("09cm5kk1sh2a6ws1fj185jrknhfa6n4bhj7nfnr4lsk339n0kvv9" "902503567e30" "da")
414 ("0r630bki5d4ylicq6lzh6s2mvsq225933szswmm0sap507rj75cm" "6000baf7a412" "de")
415 ("0749qjsfv3rn94rnci3ydgndw27qlr3w3w97kfwma2gmsf3m3r0p" "4a948952d1f4" "dsb")
416 ("0yc64i7mpxhs4qlyyh59i2aiz0vpap0bn8slcsk8b71wd1d7cy5m" "153a16a13733" "el")
417 ("0d4m5ji6ii10yap8y24cxx3fr60ba1jqi10hy3j1cq6ni7hzavga" "7ce17ae529ac" "en-CA")
418 ("12jzqcfbgdhfm8f2gqp15bdnin62li07jwicjc8ynn4cl9a19xiz" "a25d9eea7c23" "en-GB")
419 ("0gbb8hfc5yvjah63mapjxm53wxrf98srbrbg43b9g734zfi4n8y5" "4ed3471dad5d" "eo")
420 ("19lw7zmqx2irjmv5y6r7nncp6nysn06abf10n3dzj5nzgays6sln" "853fe7acb415" "es-AR")
421 ("0rq4pa380b77rkv6dq7sqx8a8i33jk3vs5rgcl8fv7slqvsw23kd" "921b67bf27a5" "es-CL")
422 ("1dyxzab9hln5spch66wmfagfzmfdiaxgpq7qlzvdfg98wkqdj25n" "c9a210ea496c" "es-ES")
423 ("1gwpmfl37wxl7rynqswgj41liljflgxydvljd4zdhk3jzqn605fb" "ddd35183d81c" "es-MX")
424 ("0c3blniddklapifnjbz03f2frw24jjgwgwn6swl5mwm2z0y6wa9f" "82d23ffaa7d3" "et")
425 ("05mq2df6n6fr8m5m2xwl0f6n1q3zgjrnk465ldx1nfr9agrhd36c" "13975626d549" "eu")
426 ("1l1jyqqiy551903j6yzh9ayg1pf26q2hr9h3jj4l51xzp7x4ms2q" "039e1fdb7c71" "fa")
427 ("091l05y9sggxznv0y11b9zy5qf146p0hb5faw4ix7yn5p5kca2f5" "7bd3722d82de" "ff")
428 ("1lllwjvmbl5dx44fcvsqg08fbflkc8dx5as9n6nf4xlkzydx6izm" "39808e88c9d1" "fi")
429 ("10ha955vvyf5vbciricm72kplj9j0s00g2333lmg46jiwi7aviiv" "426d373db6a7" "fr")
430 ("11zdfk8jvdy1k9z1q162cwapplcbz35l3dq4mv45brdin3v0x8kr" "96cd93d18389" "fy-NL")
431 ("1l5xr25gmssyachwmfprlnp2v2xj4b0hp8gxrf7fi5bvv9c2fynb" "de3daf7d3f9d" "ga-IE")
432 ("06h9ijfsn1cgz5fvxxbisk7fvqhgsw99id92575hgyg1p8xb1n69" "f04aea656d9e" "gd")
433 ("19913i5n8yyfhz9j21krlk7wqsyy89vggxc1m1swv94y2ix8rpaj" "1b8cdb87bf69" "gl")
434 ("0k5x31bfl2l0r9b5dkn03frm1gd8n6igai7ch2f1kj0skflynwww" "82df570c4241" "gn")
435 ("03rygnj9xhfvykark7dls117kwhid13ghvrsqiial0vp8m7ymx79" "e2e41d7beaa5" "gu-IN")
436 ("0vyraplj1x7b5im15anhzdaq03k2gqfyybgklrd4f9ry6msh5jhx" "de724e943805" "he")
437 ("1zqps586jrgxpf7xx2l3qw3ch3fr31r9a25y861fpxrpvh7ygw7g" "898598e1a5c6" "hi-IN")
438 ("0czq68l3qdhdc0mgazlrh8x83a6d5qrjwgjv8xvsmmzi7h68ww0l" "2711d1515af0" "hr")
439 ("1wwvrnm38gk2rnw4vmcranh8hk61gjcj9292pck3ckiv6mq7kd4s" "03e02f3d0676" "hsb")
440 ("0yvgdxlbyhhg3lk43hxx9gx66rcm7gaj02zzzx5zni8dhvlk2v6m" "d423ada9dc00" "hu")
441 ("1kjm7bg4990jhfbxwc38r4lqm2fbcxc82nc2d4qkqwikr4aah4b9" "06836af0bd6e" "hy-AM")
442 ("1dla7r3snvagb7m985xxqyi7gl498cr5xsz8msw0zpg6xmi05rlx" "299bd950d538" "ia")
443 ("0w8w9xn93akir7nqcp5iwr3kqvba5gbirg7gmzlzg7mgrhw8pcsa" "dee087477b99" "id")
444 ("10iakv1c1d20ihxg1s7c3zc1zfw18vr2kspcw7bk5k02rmrffgcn" "320095d063ed" "is")
445 ("1xn5pa3rc7l6k2migm3c0dx71q1hk7mjls045xpv9cy8gvirnj94" "4722680fb5bf" "it")
446 ("0va9zfj3wqh1yvbgh3x808yvdyxkg780vazjg887wbxpfk1n6hxa" "cb3cfe294621" "ja")
447 ("0qvjc3fhk6jg2c3g6mymmnslg1rkkxmv9gi3whf2bc5mzfgyc5zw" "7efe92bd7780" "ja-JP-mac")
448 ("0zfiwwz0axbd219ar32c7a6b8h816sf04ajx6jl74s5kyij79y82" "4c1fe3a18da9" "ka")
449 ("1aiik4758r5df76q2a132y5fjdjrsxshjylk7irwsr7yy0c7f63g" "acdf76048aa0" "kab")
450 ("0icxh4sgv6m1yykycb9d9c43k3r6w02f9c6jr04wm8hvqq5icfl5" "9b418ff7936b" "kk")
451 ("1cqlhggf46lr7w399k7qb7a1hc56f32w1dy26i2racpppzza5plc" "9771ada0b5f8" "km")
452 ("0p04irnb7x7y37m6lz388x9dynn8rnk000avpp296barajnhs5i8" "645aa37a2112" "kn")
453 ("1lbc1fxr5i0ccymlsd8axz3633cqggg5k8ak5yqwi704g7kvv9g2" "1cd68952d119" "ko")
454 ("11b55bxg73zqfdn5gy9nn5imab2mv0hxr603whggp7vymllgb7kb" "26bb83959bfe" "lij")
455 ("15jsijm6d26i0105gz0f7sh2yh2v4pmw4j95cwkdrb1d8m935jlz" "b9829891f153" "lt")
456 ("0liwwv13fgyw97nizhsyy53xrbf8jks5ics7qkkxfccawjrg5rlb" "e5f09d03d959" "lv")
457 ("0w420yf3hdnl7dp9mn9ghc20cq79k24fn9adn3syk723ppl6mkb0" "7884845e94f3" "mk")
458 ("13wkr7rgqsv9w3d9w7k8lnxdzgfixsq4bmc27zsyc770l6062ml6" "030db7412202" "mr")
459 ("06nsadcnxx0ssdp67x47dj9crihn1ycgd5mwvn5m7lkb97r4ch9f" "40a7703e875c" "ms")
460 ("0mlnjdzck6dp9p59ajj3sr63r36fn0qi8r9scrqrqcisgfclw9sg" "daca40056531" "my")
461 ("0z1hgx9d5i9w20f9k9azzng1y3lmm5d6hdjkj7rf6r5710bhhzh5" "664bd049e105" "nb-NO")
462 ("1466qvrs13g2iix1k35cknb2pia9b66li2ncvdyqf0jsd92z9k8x" "eaa6ae781ba0" "ne-NP")
463 ("0jgmz2lkzj0aspd9mabygzic6li5s2b25y0r6vjg8mv3jm5pi86j" "5ef8f1c9739e" "nl")
464 ("1m46x0h20vdfbzjxlz0ac43dbaq40xnyldr2yzbf7pk5di9pzxa6" "f08e15466d5d" "nn-NO")
465 ("0r3zvihqh6iya3z1qm7if0m3zfgf81s9qp7x7qc701h2q357wkgf" "6712c0e12ec2" "oc")
466 ("102j89jm28c223yhhkrj76xxj4kmy58hcs2r0jn15xa1qkqv1fdk" "8f36cc819e00" "pa-IN")
467 ("1j9za6s0i46abn8dsrlkpck3qxxw35rhfcg1xs1vp8sc4ckg8qwi" "c3b0c1c02b94" "pl")
468 ("1k9lbsvckpwl4xax8kxp5yxsfkspq2mhqm77jh5nl9aw88dsn55b" "cc32bf9630fe" "pt-BR")
469 ("0f0jyvbn2sa5m66wqdzh4607g4gd0270xq37ipd9ls52b4764bd8" "5478d7242086" "pt-PT")
470 ("19znkkialh1d4np7qcp80xkagrf1j2xah2s1xxzsh854p3d30zs7" "dd934a76fb01" "rm")
471 ("1xn26r8g8zzkb5myfgmnjbk8k4i0brkvbrvnhp7k5nkrnsin25di" "d57ab3dee73d" "ro")
472 ("04rhkxlmpp5pyzw85ldbfkmiigqr2p9y5cbns5dqs6sz1633ccxp" "7aea98f33a20" "ru")
473 ("1zzkkxl7ayxh5gx9snyvp5czflsvi77hp48li613h3c2fii4n9qk" "7c986f4b5044" "sco")
474 ("1219i0ghhqj3s1i0rm68jjkvivh6y40938wav7z4ifck527sq6r1" "bc9e55d4e3ea" "si")
475 ("05i5p3n3a6hgl6rf10yjs4vag7y3rn2jwgxsddcdcqiv6405zn81" "8814afd7f67e" "sk")
476 ("1wcqdbm1py1ldq6cj2g201m715nql79r6szr71jvrxacb711c62a" "20013dc06e96" "sl")
477 ("0g2izkaa4ipwgwyhy77ciyrxxpf4pxzj9mjqvxriy5prmkhm3zjs" "d86d5d2b6eef" "son")
478 ("1cc99m6srjg8698dkc3il70crby0mdv43v3ijwy069k4w50hyjjg" "49bb5fae5d9b" "sq")
479 ("13kfssq4fhq9mb36as6sxiaffl17qyg1wdw8kpz3ilqm86bsjrgl" "d6a0ab79b06f" "sr")
480 ("1wx9snbm0431q97i0q0nv4wbsqcv9nhllwfr88crlp7bfj5w8czw" "4bab04993da3" "sv-SE")
481 ("0laglkfl8ml0ip5vmm3z2q790hgwax9gfqwq3wm68a2nnsyck8fw" "4b3316c4aa48" "szl")
482 ("15pnlic4q7m48y0mc5yh8w5yscjwzx0mmfrbj3f2b9jxxa44nx4h" "48c7aab86db8" "ta")
483 ("16qar5y0wns75ryi8bfv7yln3mjsyn7qi4345zcniz3ydgkczh46" "7bbb3dac8f47" "te")
484 ("112g7x8h0qz16r5faam386x4a0rgwd4zy02d5agmg9m0kbficdfx" "009fd0852454" "th")
485 ("1l80kh9byqxnz5vkz357rb39g4y9sgn9pr0v29ywp6d009img1qg" "dad9caecd7a9" "tl")
486 ("1nalvjlxxsa9wldhhdb93bgfc7dl084xayh7i7mgg93yjgrym93x" "0c48082d37cd" "tr")
487 ("0wkxqcfgsra2ljws28kiwajv73w9aa8drsc4fqlg9krbicnjl2n8" "f6d105faedcc" "trs")
488 ("18jf4ysrfv3635fyxc1vwr970dr2r05bl3h8v599pwp2g7jzyjpm" "e1011388a55e" "uk")
489 ("1ihmksjsz54yii23qda5iv8cxrj9144afy75hzhvfi6m182kj4h8" "c4e927eab511" "ur")
490 ("0d42dhfa2vcw24wsvwf95pw20np0pz8c0is6p4307n981n8s207y" "7063df917cb3" "uz")
491 ("04khnkrg8css55hyna01jqay9c2ppxk5znbx2zj9i25knhvvx1lq" "1753054e6ab8" "vi")
492 ("0fi5kxn78xp7s15svkqlf4748j4pzxh941nm52n6kbbrhyi3qcqn" "93bc595dc32e" "xh")
493 ("0jg676vd37wqgzjnm0yynj7xrvm6fsgdwg296h78wnyc33zc4ads" "edd4e468bc31" "zh-CN")
494 ("1y4wldm3z95mfjlficp994jyqg0lj07wi35b79dy1s8ljy3jilil" "0bad1f7d2b2d" "zh-TW")))
495
496 ;; XXXX: Workaround 'snippet' limitations.
497 (define computed-origin-method (@@ (guix packages) computed-origin-method))
498
499 (define %icecat-base-version "102.8.0")
500 (define %icecat-version (string-append %icecat-base-version "-guix0-preview1"))
501 (define %icecat-build-id "20230214000000") ;must be of the form YYYYMMDDhhmmss
502
503 ;; 'icecat-source' is a "computed" origin that generates an IceCat tarball
504 ;; from the corresponding upstream Firefox ESR tarball, using the 'makeicecat'
505 ;; script from the upstream IceCat project.
506 (define icecat-source
507 (let* ((major-version (first (string-split %icecat-base-version #\.)))
508 (minor-version (second (string-split %icecat-base-version #\.)))
509 (sub-version (third (string-split %icecat-base-version #\.)))
510
511 (upstream-firefox-version (string-append %icecat-base-version "esr"))
512 (upstream-firefox-source
513 (origin
514 (method url-fetch)
515 (uri (string-append
516 "https://ftp.mozilla.org/pub/firefox/releases/"
517 upstream-firefox-version "/source/"
518 "firefox-" upstream-firefox-version ".source.tar.xz"))
519 (sha256
520 (base32
521 "0j6afrgfsmd0adbbmffw4p1f2hznpck9d36z3bsjx36f7cjgdy27"))))
522
523 ;; The upstream-icecat-base-version may be older than the
524 ;; %icecat-base-version.
525 (upstream-icecat-base-version "102.8.0")
526 (gnuzilla-commit "f23f8b609ef4afcc7d8ac5fa795093f1c403f8da")
527 (gnuzilla-source
528 (origin
529 (method git-fetch)
530 (uri (git-reference
531 (url "git://git.savannah.gnu.org/gnuzilla.git")
532 (commit gnuzilla-commit)))
533 (file-name (git-file-name "gnuzilla"
534 ;;upstream-icecat-base-version
535 (string-take gnuzilla-commit 8)))
536 (sha256
537 (base32
538 "1zvvgjvsj7k8753f7xmpmkq35dqzyik95943hzl84v2j5mnahhj4"))))
539
540 ;; 'search-patch' returns either a valid file name or #f, so wrap it
541 ;; in 'assume-valid-file-name' to avoid 'local-file' warnings.
542 (makeicecat-patch
543 (local-file (assume-valid-file-name
544 (search-patch "icecat-makeicecat.patch")))))
545
546 (origin
547 (method computed-origin-method)
548 (file-name (string-append "icecat-" %icecat-version ".tar.xz"))
549 (sha256 #f)
550 (uri
551 (delay
552 (with-imported-modules '((guix build utils))
553 #~(begin
554 (use-modules (guix build utils))
555 (let ((firefox-dir
556 (string-append "firefox-" #$%icecat-base-version))
557 (icecat-dir
558 (string-append "icecat-" #$%icecat-version)))
559
560 (set-path-environment-variable
561 "PATH" '("bin")
562 (list #+python
563 #+(canonical-package bash)
564 #+(canonical-package coreutils)
565 #+(canonical-package findutils)
566 #+(canonical-package patch)
567 #+(canonical-package xz)
568 #+(canonical-package sed)
569 #+(canonical-package grep)
570 #+(canonical-package bzip2)
571 #+(canonical-package gzip)
572 #+(canonical-package tar)))
573
574 (set-path-environment-variable
575 "PYTHONPATH"
576 (list #+(format #f "lib/python~a/site-packages"
577 (version-major+minor
578 (package-version python))))
579 '#+(cons python-jsonschema
580 (map second
581 (package-transitive-propagated-inputs
582 python-jsonschema))))
583
584 ;; Needed by the 'makeicecat' script.
585 (setenv "RENAME_CMD" "rename")
586
587 ;; We copy the gnuzilla source directory because it is
588 ;; read-only in 'gnuzilla-source', and the makeicecat script
589 ;; uses "cp -a" to copy parts of it and assumes that the
590 ;; copies will be writable.
591 (copy-recursively #+gnuzilla-source "/tmp/gnuzilla"
592 #:log (%make-void-port "w"))
593
594 (with-directory-excursion "/tmp/gnuzilla"
595 (make-file-writable "makeicecat")
596 (invoke "patch" "--force" "--no-backup-if-mismatch"
597 "-p1" "--input" #+makeicecat-patch)
598 (patch-shebang "makeicecat")
599 (substitute* "makeicecat"
600 (("^readonly FFMAJOR=(.*)" all ffmajor)
601 (unless (string=? #$major-version
602 (string-trim-both ffmajor))
603 ;; The makeicecat script cannot be expected to work
604 ;; properly on a different version of Firefox, even if
605 ;; no errors occur during execution.
606 (error "makeicecat major version mismatch"))
607 (string-append "readonly FFMAJOR=" #$major-version "\n"))
608 (("^readonly FFMINOR=.*")
609 (string-append "readonly FFMINOR=" #$minor-version "\n"))
610 (("^readonly FFSUB=.*")
611 (string-append "readonly FFSUB=" #$sub-version "\n"))
612 (("^readonly DATADIR=.*")
613 "readonly DATADIR=/tmp/gnuzilla/data\n")
614 (("^readonly SOURCEDIR=.*")
615 (string-append "readonly SOURCEDIR=" icecat-dir "\n"))
616 (("/bin/sed")
617 #+(file-append (canonical-package sed) "/bin/sed"))))
618
619 (format #t "Unpacking upstream firefox tarball...~%")
620 (force-output)
621 (invoke "tar" "xf" #+upstream-firefox-source)
622 (rename-file firefox-dir icecat-dir)
623
624 (with-directory-excursion icecat-dir
625 (format #t "Populating l10n directory...~%")
626 (force-output)
627 (mkdir "l10n")
628 (with-directory-excursion "l10n"
629 (for-each
630 (lambda (locale-dir)
631 (let ((locale
632 (string-drop (basename locale-dir)
633 (+ 32 ; length of hash
634 (string-length "-mozilla-locale-")))))
635 (format #t " ~a~%" locale)
636 (force-output)
637 (copy-recursively locale-dir locale
638 #:log (%make-void-port "w"))
639 (for-each make-file-writable (find-files locale))
640 (with-directory-excursion locale
641 (when (file-exists? ".hgtags")
642 (delete-file ".hgtags"))
643 (mkdir-p "browser/chrome/browser/preferences")
644 (call-with-output-file
645 "browser/chrome/browser/preferences/advanced-scripts.dtd"
646 (lambda (port) #f)))))
647 '#+all-mozilla-locales)
648 (copy-recursively #+mozilla-compare-locales
649 "compare-locales"
650 #:log (%make-void-port "w"))
651 (delete-file "compare-locales/.gitignore")
652 (delete-file "compare-locales/.hgignore")
653 (delete-file "compare-locales/.hgtags")))
654
655 (format #t "Running makeicecat script...~%")
656 (force-output)
657 (invoke "bash" "/tmp/gnuzilla/makeicecat")
658
659 (format #t "Packing IceCat source tarball...~%")
660 (force-output)
661 (setenv "XZ_DEFAULTS" (string-join (%xz-parallel-args)))
662 (invoke "tar" "cfa" #$output
663 ;; Avoid non-determinism in the archive. We set the
664 ;; mtime of files in the archive to early 1980 because
665 ;; the build process fails if the mtime of source
666 ;; files is pre-1980, due to the creation of zip
667 ;; archives.
668 "--mtime=@315619200" ; 1980-01-02 UTC
669 "--owner=root:0"
670 "--group=root:0"
671 "--sort=name"
672 icecat-dir)))))))))
673
674 (define-public icecat-minimal
675 (package
676 (name "icecat-minimal")
677 (version %icecat-version)
678 (source icecat-source)
679 (build-system gnu-build-system)
680 (inputs
681 (list alsa-lib
682 bzip2
683 cups
684 dbus-glib
685 gdk-pixbuf
686 glib
687 gtk+
688 ;; UNBUNDLE-ME! graphite2
689 cairo
690 pango
691 freetype
692 font-dejavu
693 ;; UNBUNDLE-ME! harfbuzz
694 libcanberra
695 libgnome
696 libjpeg-turbo
697 libpng-apng
698 ;; UNBUNDLE-ME! libogg
699 ;; UNBUNDLE-ME! libtheora ; wants theora-1.2, not yet released
700 ;; UNBUNDLE-ME! libvorbis
701 libxft
702 libevent
703 libxinerama
704 libxscrnsaver
705 libxcomposite
706 libxt
707 libffi
708 ffmpeg
709 libvpx
710 icu4c-71 ; TODO: Change to 'icu4c' when its version is >= 71.
711 pixman
712 pulseaudio
713 mesa
714 pciutils
715 mit-krb5
716 hunspell
717 libnotify
718 nspr-next
719 nss-next
720 shared-mime-info
721 sqlite
722 eudev
723 unzip
724 zip
725 zlib))
726 (native-inputs
727 ;; The following patches are specific to the Guix packaging of IceCat,
728 ;; and therefore we prefer to leave them out of 'source', which should be
729 ;; a tarball suitable for compilation on any system that IceCat supports.
730 ;; (Bug fixes and security fixes, however, should go in 'source').
731 (list
732 ;; XXX TODO: Adapt these patches to IceCat 102.
733 ;; ("icecat-avoid-bundled-libraries.patch"
734 ;; ,(search-patch "icecat-avoid-bundled-libraries.patch"))
735 ;; ("icecat-use-system-graphite2+harfbuzz.patch"
736 ;; ,(search-patch "icecat-use-system-graphite2+harfbuzz.patch"))
737 ;; ("icecat-use-system-media-libs.patch"
738 ;; ,(search-patch "icecat-use-system-media-libs.patch"))
739 rust
740 `(,rust "cargo")
741 rust-cbindgen-0.23
742 llvm
743 clang
744 perl
745 node
746 python-wrapper
747 yasm
748 nasm ; XXX FIXME: only needed on x86_64 and i686
749 pkg-config
750 m4
751 which))
752 (arguments
753 (list
754 #:tests? #f ;not worth the cost
755
756 ;; Some dynamic lib was determined at runtime, so rpath check may fail.
757 #:validate-runpath? #f
758
759 #:configure-flags
760 #~(list
761 "--enable-application=browser"
762 "--with-distribution-id=org.gnu"
763 "--enable-geckodriver"
764 ;; Do not require addons in the global app or system directories to
765 ;; be signed by Mozilla.
766 "--with-unsigned-addon-scopes=app,system"
767 "--allow-addon-sideload"
768
769 "--enable-pulseaudio"
770
771 "--disable-tests"
772 "--disable-updater"
773 "--disable-crashreporter"
774 "--disable-eme"
775
776 ;; Building with debugging symbols takes ~5GiB, so disable it.
777 "--disable-debug"
778 "--disable-debug-symbols"
779
780 "--enable-rust-simd"
781 "--enable-release"
782 "--enable-optimize"
783 "--enable-strip"
784 "--disable-elf-hack"
785
786 ;; Clang is needed to build Stylo, Mozilla's new CSS engine. We must
787 ;; specify the clang paths manually, because otherwise the Mozilla
788 ;; build system looks in the directories returned by llvm-config
789 ;; --bindir and llvm-config --libdir, which return paths in the llvm
790 ;; package where clang is not found.
791 (string-append "--with-clang-path="
792 (search-input-file %build-inputs "bin/clang"))
793 (string-append "--with-libclang-path="
794 (dirname (search-input-file %build-inputs
795 "lib/libclang.so")))
796
797 ;; Hack to work around missing "unofficial" branding in icecat.
798 "--enable-official-branding"
799
800 ;; TODO: Add support for wasm sandboxed libraries.
801 "--without-wasm-sandboxed-libraries"
802
803 ;; Avoid bundled libraries.
804 "--with-system-jpeg" ;must be libjpeg-turbo
805 "--with-system-png" ;must be libpng-apng
806 "--with-system-zlib"
807 ;; UNBUNDLE-ME! "--with-system-bz2"
808 ;; UNBUNDLE-ME! "--with-system-libevent"
809 ;; UNBUNDLE-ME! "--with-system-ogg"
810 ;; UNBUNDLE-ME! "--with-system-vorbis"
811 ;; UNBUNDLE-ME! "--with-system-theora" ; wants theora-1.2, not yet released
812 ;; UNBUNDLE-ME! "--with-system-libvpx"
813 "--with-system-icu"
814 "--with-system-nspr"
815 "--with-system-nss"
816
817 ;; UNBUNDLE-ME! "--with-system-harfbuzz"
818 ;; UNBUNDLE-ME! "--with-system-graphite2"
819 "--enable-system-pixman"
820 "--enable-system-ffi"
821 ;; UNBUNDLE-ME! "--enable-system-sqlite"
822 )
823
824 #:imported-modules %cargo-utils-modules ;for `generate-all-checksums'
825
826 #:modules `((ice-9 ftw)
827 (ice-9 match)
828 (srfi srfi-1)
829 (srfi srfi-26)
830 (rnrs bytevectors)
831 (rnrs io ports)
832 (guix elf)
833 (guix build gremlin)
834 ,@%gnu-build-system-modules)
835 #:phases
836 #~(modify-phases %standard-phases
837 (add-after 'unpack 'apply-guix-specific-patches
838 (lambda* (#:key inputs native-inputs #:allow-other-keys)
839 (let ((patch (search-input-file inputs "bin/patch")))
840 (for-each (match-lambda
841 ((label . file)
842 (when (and (string-prefix? "icecat-" label)
843 (string-suffix? ".patch" label))
844 (format #t "applying '~a'...~%" file)
845 (invoke patch "--force" "--no-backup-if-mismatch"
846 "-p1" "--input" file))))
847 (or native-inputs inputs)))))
848 (add-after 'apply-guix-specific-patches 'remove-bundled-libraries
849 (lambda _
850 ;; Remove bundled libraries that we don't use, since they may
851 ;; contain unpatched security flaws, they waste disk space and
852 ;; memory, and may cause confusion.
853 (for-each (lambda (file)
854 (format #t "deleting '~a'...~%" file)
855 (delete-file-recursively file))
856 '( ;; FIXME: Removing the bundled icu breaks configure.
857 ;; * The bundled icu headers are used in some places.
858 ;; * The version number is taken from the bundled copy.
859 ;;"intl/icu"
860 ;;
861 ;; FIXME: A script from the bundled nspr is used.
862 ;;"nsprpub"
863 ;;
864 ;; FIXME: Some of the bundled NSS sources are used
865 ;; to build third_party/prio.
866 ;;"security/nss"
867 ;;
868 ;; TODO: Use more system media libraries. See:
869 ;; <https://bugzilla.mozilla.org/show_bug.cgi?id=517422>
870 ;; * libtheora: esr60 wants v1.2, not yet released.
871 ;; * soundtouch: avoiding the bundled library would
872 ;; result in some loss of functionality. There's
873 ;; also an issue with exception handling
874 ;; configuration. It seems that this is needed in
875 ;; some moz.build:
876 ;; DEFINES['ST_NO_EXCEPTION_HANDLING'] = 1
877 ;; * libopus
878 ;; * speex
879 ;;
880 "modules/freetype2"
881 ;; "media/libjpeg" ; needed for now, because media/libjpeg/moz.build is referenced from config/external/moz.build
882 ;; UNBUNDLE-ME! "modules/zlib"
883 ;; UNBUNDLE-ME! "ipc/chromium/src/third_party/libevent"
884 ;; UNBUNDLE-ME! "media/libvpx"
885 ;; UNBUNDLE-ME! "media/libogg"
886 ;; UNBUNDLE-ME! "media/libvorbis"
887 ;; UNBUNDLE-ME! "media/libtheora" ; wants theora-1.2, not yet released
888 ;; UNBUNDLE-ME! "media/libtremor"
889 ;; UNBUNDLE-ME! "gfx/harfbuzz"
890 ;; UNBUNDLE-ME! "gfx/graphite2"
891 "js/src/ctypes/libffi"
892 ;; UNBUNDLE-ME! "db/sqlite3"
893 ))))
894 (add-after 'remove-bundled-libraries 'fix-ffmpeg-runtime-linker
895 (lambda* (#:key inputs #:allow-other-keys)
896 ;; Arrange to load libavcodec.so by its absolute file name.
897 (substitute* "dom/media/platforms/ffmpeg/FFmpegRuntimeLinker.cpp"
898 (("libavcodec\\.so")
899 (search-input-file inputs "lib/libavcodec.so")))))
900 (add-after 'fix-ffmpeg-runtime-linker 'build-sandbox-whitelist
901 (lambda* (#:key inputs #:allow-other-keys)
902 (define (runpath-of lib)
903 (call-with-input-file lib
904 (compose elf-dynamic-info-runpath
905 elf-dynamic-info
906 parse-elf
907 get-bytevector-all)))
908 (define (runpaths-of-input label)
909 (let* ((dir (string-append (assoc-ref inputs label) "/lib"))
910 (libs (find-files dir "\\.so$")))
911 (append-map runpath-of libs)))
912 ;; Populate the sandbox read-path whitelist as needed by ffmpeg.
913 (let* ((whitelist
914 (map (cut string-append <> "/")
915 (delete-duplicates
916 `(,(string-append (assoc-ref inputs "shared-mime-info")
917 "/share/mime")
918 ,(string-append (assoc-ref inputs "font-dejavu")
919 "/share/fonts")
920 "/run/current-system/profile/share/fonts"
921 ,@(append-map runpaths-of-input
922 '("mesa" "ffmpeg"))))))
923 (whitelist-string (string-join whitelist ","))
924 (port (open-file "browser/app/profile/icecat.js" "a")))
925 (format #t "setting 'security.sandbox.content.read_path_whitelist' to '~a'~%"
926 whitelist-string)
927 (format port "~%pref(\"security.sandbox.content.read_path_whitelist\", ~S);~%"
928 whitelist-string)
929 (close-output-port port))))
930 (add-after 'patch-source-shebangs 'patch-cargo-checksums
931 (lambda _
932 (use-modules (guix build cargo-utils))
933 (let ((null-hash "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"))
934 (for-each (lambda (file)
935 (format #t "patching checksums in ~a~%" file)
936 (substitute* file
937 (("^checksum = \".*\"")
938 (string-append "checksum = \"" null-hash "\""))))
939 (find-files "." "Cargo.lock$"))
940 (for-each generate-all-checksums
941 '("services"
942 "js"
943 "third_party/rust"
944 "dom/media"
945 "dom/webauthn"
946 "toolkit"
947 "gfx"
948 "storage"
949 "modules"
950 "xpcom/rust"
951 "media"
952 "mozglue/static/rust"
953 "netwerk"
954 "remote"
955 "intl"
956 "servo"
957 "security/manager/ssl"
958 "build")))))
959 (add-after 'patch-cargo-checksums 'remove-cargo-frozen-flag
960 (lambda _
961 ;; Remove --frozen flag from cargo invokation, otherwise it'll
962 ;; complain that it's not able to change Cargo.lock.
963 ;; https://bugzilla.mozilla.org/show_bug.cgi?id=1726373
964 (substitute* "build/RunCbindgen.py"
965 (("\"--frozen\",") ""))))
966 (delete 'bootstrap)
967 (replace 'configure
968 ;; configure does not work followed by both "SHELL=..." and
969 ;; "CONFIG_SHELL=..."; set environment variables instead
970 (lambda* (#:key outputs configure-flags #:allow-other-keys)
971 (let* ((bash (which "bash"))
972 (abs-srcdir (getcwd))
973 (flags `(,(string-append "--prefix=" #$output)
974 ,(string-append "--with-l10n-base="
975 abs-srcdir "/l10n")
976 ,@configure-flags)))
977 (setenv "SHELL" bash)
978 (setenv "CONFIG_SHELL" bash)
979
980 (setenv "AR" "llvm-ar")
981 (setenv "NM" "llvm-nm")
982 (setenv "CC" "clang")
983 (setenv "CXX" "clang++")
984 (setenv "LDFLAGS" (string-append "-Wl,-rpath="
985 #$output "/lib/icecat"))
986
987 (setenv "MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE" "system")
988 (setenv "MOZ_BUILD_DATE" #$%icecat-build-id) ; avoid timestamp
989
990 ;; XXX TODO: Fix this to work on systems other than x86_64-linux.
991 (setenv "GUIX_PYTHONPATH"
992 (string-append (getcwd)
993 "/obj-x86_64-pc-linux-gnu/_virtualenvs/build"))
994
995 (mkdir ".mozbuild")
996 (setenv "MOZBUILD_STATE_PATH"
997 (string-append (getcwd) "/.mozbuild"))
998
999 (format #t "build directory: ~s~%" (getcwd))
1000 (format #t "configure flags: ~s~%" flags)
1001
1002 (call-with-output-file "mozconfig"
1003 (lambda (port)
1004 (for-each (lambda (flag)
1005 (format port "ac_add_options ~a\n" flag))
1006 flags)))
1007
1008 (invoke "./mach" "configure"))))
1009 (replace 'build
1010 (lambda* (#:key (make-flags '()) (parallel-build? #t)
1011 #:allow-other-keys)
1012 (apply invoke "./mach" "build"
1013 ;; mach will use parallel build if possible by default
1014 `(,@(if parallel-build?
1015 '()
1016 '("-j1"))
1017 ,@make-flags))))
1018 (add-after 'build 'neutralise-store-references
1019 (lambda _
1020 ;; Mangle the store references to compilers & other build tools in
1021 ;; about:buildconfig, reducing IceCat's closure by 1 GiB on x86-64.
1022 (let* ((obj-dir (match (scandir "." (cut string-prefix? "obj-" <>))
1023 ((dir) dir)))
1024 (file (string-append
1025 obj-dir
1026 "/dist/bin/chrome/toolkit/content/global/buildconfig.html")))
1027 (substitute* file
1028 (("[0-9a-df-np-sv-z]{32}" hash)
1029 (string-append (string-take hash 8)
1030 "<!-- Guix: not a runtime dependency -->"
1031 (string-drop hash 8)))))))
1032 (replace 'install
1033 (lambda* (#:key outputs #:allow-other-keys)
1034 (invoke "./mach" "install")
1035 ;; The geckodriver binary is not installed by the above, for some
1036 ;; reason. Use 'find-files' to avoid having to deal with the
1037 ;; system/architecture-specific file name.
1038 (install-file (first (find-files "." "geckodriver"))
1039 (string-append #$output "/bin"))))
1040 (add-after 'install 'wrap-program
1041 (lambda* (#:key inputs #:allow-other-keys)
1042 (let* ((lib (string-append #$output "/lib"))
1043 (gtk #$(this-package-input "gtk+"))
1044 (gtk-share (string-append gtk "/share"))
1045 (ld-libs '#$(map (lambda (label)
1046 (file-append (this-package-input label) "/lib"))
1047 '("libpng-apng"
1048 "libxscrnsaver"
1049 "mesa"
1050 "pciutils"
1051 "mit-krb5"
1052 "eudev"
1053 "pulseaudio"
1054 ;; For the integration of native notifications
1055 "libnotify"))))
1056 (wrap-program (car (find-files lib "^icecat$"))
1057 `("XDG_DATA_DIRS" prefix (,gtk-share))
1058 ;; The following line is commented out because the icecat
1059 ;; package on guix has been observed to be unstable when
1060 ;; using wayland, and the bundled extensions stop working.
1061 ;; `("MOZ_ENABLE_WAYLAND" = ("1"))
1062 `("LD_LIBRARY_PATH" prefix ,ld-libs)))))
1063 (add-after 'wrap-program 'install-desktop-entry
1064 (lambda _
1065 ;; Install the '.desktop' file.
1066 (let* ((desktop-file "taskcluster/docker/icecat-snap/icecat.desktop")
1067 (applications (string-append #$output "/share/applications")))
1068 (substitute* desktop-file
1069 (("^Exec=icecat") (string-append "Exec=" #$output "/bin/icecat"))
1070 (("IceCat") "GNU IceCat")
1071 (("Icon=.*") "Icon=icecat\n")
1072 (("NewWindow") "new-window")
1073 (("NewPrivateWindow") "new-private-window")
1074 (("StartupNotify=true")
1075 "StartupNotify=true\nStartupWMClass=Navigator"))
1076 (install-file desktop-file applications))))
1077 (add-after 'install-desktop-entry 'install-icons
1078 (lambda _
1079 (with-directory-excursion "browser/branding/official"
1080 (for-each
1081 (lambda (file)
1082 (let* ((size (string-filter char-numeric? file))
1083 (icons (string-append #$output "/share/icons/hicolor/"
1084 size "x" size "/apps")))
1085 (mkdir-p icons)
1086 (copy-file file (string-append icons "/icecat.png"))))
1087 '("default16.png" "default22.png" "default24.png"
1088 "default32.png" "default48.png" "content/icon64.png"
1089 "mozicon128.png" "default256.png"))))))))
1090 (home-page "https://www.gnu.org/software/gnuzilla/")
1091 (synopsis "Entirely free browser derived from Mozilla Firefox")
1092 (description
1093 "IceCat is the GNU version of the Firefox browser. It is entirely free
1094 software, which does not recommend non-free plugins and addons. It also
1095 features built-in privacy-protecting features. This package also includes the
1096 @command{geckodriver} command, which can be useful for automated web
1097 testing.
1098
1099 WARNING: IceCat 102 has not yet been released by the upstream IceCat project.
1100 This is a preview release, and does not currently meet the privacy-respecting
1101 standards of the IceCat project.")
1102 (license license:mpl2.0) ;and others, see toolkit/content/license.html
1103 (properties
1104 `((ftp-directory . "/gnu/gnuzilla")
1105 (cpe-name . "firefox_esr")
1106 (cpe-version . ,(first (string-split version #\-)))))))
1107
1108 (define %icecat-locales
1109 '("ach" "af" "an" "ar" "ast" "az" "be" "bg" "bn" "br" "bs" "ca" "cak"
1110 "ca-valencia" "cs" "cy" "da" "de" "dsb" "el" "en-CA" "en-GB" "eo" "es-AR"
1111 "es-CL" "es-ES" "es-MX" "et" "eu" "fa" "ff" "fi" "fr" "fy-NL" "ga-IE" "gd"
1112 "gl" "gn" "gu-IN" "he" "hi-IN" "hr" "hsb" "hu" "hy-AM" "ia" "id" "is" "it"
1113 "ja" "ja-JP-mac" "ka" "kab" "kk" "km" "kn" "ko" "lij" "lt" "lv" "mk" "mr" "ms"
1114 "my" "nb-NO" "ne-NP" "nl" "nn-NO" "oc" "pa-IN" "pl" "pt-BR" "pt-PT" "rm" "ro"
1115 "ru" "sco" "si" "sk" "sl" "son" "sq" "sr" "sv-SE" "szl" "ta" "te" "th" "tl"
1116 "tr" "trs" "uk" "ur" "uz" "vi" "xh" "zh-CN" "zh-TW"))
1117
1118 (define %icedove-build-id "20230207000000") ;must be of the form YYYYMMDDhhmmss
1119 (define %icedove-version "102.7.2")
1120
1121 ;; Provides the "comm" folder which is inserted into the icecat source.
1122 ;; Avoids the duplication of Icecat's source tarball.
1123 (define thunderbird-comm-source
1124 (origin
1125 (method hg-fetch)
1126 (uri (hg-reference
1127 (url "https://hg.mozilla.org/releases/comm-esr102")
1128 (changeset "0f6deed0752b618055c34e06c268af3da9d1548d")))
1129 (file-name (string-append "thunderbird-" %icedove-version "-checkout"))
1130 (sha256
1131 (base32
1132 "071q0pcfvfpzx741ly1sl8anlmzx02h17w4ylfnrkwrpaclq3p6p"))))
1133
1134 (define (comm-source->locales+changeset source)
1135 "Given SOURCE, a checkout of the Thunderbird 'comm' component, return the
1136 list of languages supported as well as the currently used changeset."
1137 (match (update-mozilla-locales
1138 (string-append source "/mail/locales/l10n-changesets.json"))
1139 (((_ changeset locale) ...)
1140 (values locale (first changeset)))))
1141
1142 ;;; Generated with comm-source->locales+changeset.
1143 (define %icedove-locales
1144 '("af" "ar" "ast" "be" "bg" "br" "ca" "cak" "cs" "cy" "da" "de" "dsb" "el"
1145 "en-CA" "en-GB" "es-AR" "es-ES" "es-MX" "et" "eu" "fi" "fr" "fy-NL" "ga-IE"
1146 "gd" "gl" "he" "hr" "hsb" "hu" "hy-AM" "id" "is" "it" "ja" "ja-JP-mac" "ka"
1147 "kab" "kk" "ko" "lt" "lv" "ms" "nb-NO" "nl" "nn-NO" "pa-IN" "pl" "pt-BR"
1148 "pt-PT" "rm" "ro" "ru" "sk" "sl" "sq" "sr" "sv-SE" "th" "tr" "uk" "uz" "vi"
1149 "zh-CN" "zh-TW"))
1150
1151 ;;; To find out which changeset to use for the comm-l10n repo, use the
1152 ;;; 'comm-source->locales+changeset' procedure on the thunderbird-comm-source
1153 ;;; checkout directory. The complete localization data should be released as
1154 ;;; a tarball in the next release (see:
1155 ;;; https://bugzilla.mozilla.org/show_bug.cgi?id=1817086). When this tarball
1156 ;;; is available, it should replace the complete 'l10n' directory at the root
1157 ;;; of the IceCat source, instead of only the 'calendar', chat and mail
1158 ;;; directories that it provides.
1159 (define thunderbird-comm-l10n
1160 (let* ((changeset "5b6788295358")
1161 (version (git-version %icedove-version "0" changeset)))
1162 (origin
1163 (method hg-fetch)
1164 (uri (hg-reference
1165 (url "https://hg.mozilla.org/projects/comm-l10n")
1166 (changeset changeset)))
1167 (file-name (git-file-name "comm-l10n" version))
1168 (sha256
1169 (base32
1170 "1jrsmkscjjllcfawi3788vwm53wn25inbhdis5nk4vfpr7wk5ill")))))
1171
1172 (define icedove-source
1173 (let ((name (string-append "icedove-" %icedove-version)))
1174 (origin
1175 (method computed-origin-method)
1176 (file-name (string-append name ".tar.xz"))
1177 (sha256 #f)
1178 (uri
1179 (delay
1180 (with-imported-modules (source-module-closure '((guix build utils)))
1181 #~(begin
1182 (use-modules (guix build utils)
1183 (sxml simple))
1184
1185 (set-path-environment-variable
1186 "PATH" '("bin")
1187 (list #+(canonical-package tar)
1188 #+(canonical-package xz)))
1189
1190 ;; Extract the base Icecat tarball, renaming its top-level
1191 ;; directory.
1192 (invoke "tar" "--transform" (string-append "s,[^/]*," #$name ",")
1193 "-xf" #$icecat-source)
1194 (chdir #$name)
1195
1196 ;; Merge the Thunderdbird localization data.
1197 (copy-recursively #$thunderbird-comm-l10n "l10n")
1198
1199 ;; Add the Thunderbird-specific "comm" directory..
1200 (mkdir "comm")
1201 (copy-recursively #$thunderbird-comm-source "comm")
1202 (delete-file "sourcestamp.txt")
1203
1204 ;; Adjust the application name.
1205 (substitute* "comm/mail/confvars.sh"
1206 (("MOZ_APP_NAME=thunderbird")
1207 "MOZ_APP_NAME=icedove")
1208 (("MOZ_UPDATER=1")
1209 "MOZ_UPDATER=0"))
1210
1211 ;; Remove branding to comply with Mozilla's trademark policy
1212 (with-directory-excursion "comm/mail/branding/nightly"
1213 (delete-file "content/about-wordmark.svg")
1214 (call-with-output-file "content/about-wordmark.svg"
1215 (lambda (port)
1216 (sxml->xml '(svg (@ (xmlns "http://www.w3.org/2000/svg")
1217 (viewBox "0 0 789.1 90.78")
1218 (width "333")
1219 (height "48")
1220 (fill "#fff"))
1221 (text (@ (x "400") (y "70")
1222 (text-anchor "middle")
1223 (font-size "90"))
1224 "Icedove Daily"))
1225 port)))
1226 (substitute* '("locales/en-US/brand.properties"
1227 "locales/en-US/brand.ftl"
1228 "locales/en-US/brand.dtd"
1229 "configure.sh")
1230 (("Thunderbird") "Icedove")
1231 (("mozilla.org") "guix.gnu.org")))
1232 ;; Remove other mentions of Thunderbird in user-visible text.
1233 (with-directory-excursion "comm/mail/base/content"
1234 (substitute* '("overrides/app-license-name.html")
1235 (("Thunderbird") "Icedove")))
1236 (with-directory-excursion "comm/mail/components/"
1237 (substitute* '("MailGlue.jsm"
1238 "extensions/schemas/addressBook.json"
1239 "extensions/schemas/tabs.json"
1240 "extensions/schemas/cloudFile.json"
1241 "extensions/schemas/chrome_settings_overrides.json"
1242 "extensions/schemas/windows.json"
1243 "extensions/parent/ext-mail.js"
1244 "im/messages/mail/Info.plist"
1245 "enterprisepolicies/moz.build"
1246 "enterprisepolicies/helpers/moz.build"
1247 "enterprisepolicies/schemas/moz.build")
1248 (("Thunderbird") "Icedove")))
1249 (substitute* '("comm/mailnews/base/prefs/content/accountUtils.js"
1250 "comm/mail/base/content/customizeToolbar.js"
1251 "comm/suite/components/customizeToolbar.js")
1252 (("AppConstants.MOZ_APP_NAME (.)= \"thunderbird" _ e)
1253 (format #f "AppConstants.MOZ_APP_NAME ~a= \"icedove" e)))
1254
1255 ;; Override addon URLs and settings
1256 (substitute* "comm/mail/app/profile/all-thunderbird.js"
1257 (("(pref\\(\"extensions.webservice.discoverURL\").*" _ m)
1258 (string-append m ", \"https://directory.fsf.org/wiki/Icedove\");"))
1259 (("(pref\\(\"extensions.getAddons.search.url\").*" _ m)
1260 (string-append m ", \"https://guix.gnu.org/packages\");"))
1261 (("(pref\\(\"extensions.update.enabled\").*" _ m)
1262 (string-append m ", false);"))
1263 (("(pref\\(\"extensions.systemAddon.update.enabled\").*" _ m)
1264 (string-append m ", false);"))
1265 (("(pref\\(\"lightweightThemes.update.enabled\").*" _ m)
1266 (string-append m ", false);"))
1267
1268 ;; XXX: The autoDisableScopes is tweaked by the makeicecat
1269 ;; script, but it doesn't know about Thunderbird. This is
1270 ;; necessary to allow picking up the extensions found in the
1271 ;; system global application directory, such as the language
1272 ;; packs.
1273 (("\"extensions.autoDisableScopes\", 15")
1274 "\"extensions.autoDisableScopes\", 3")
1275
1276 ;; Set the default locale to that of the operating system.
1277 ((".*extensions.autoDisableScopes.*" anchor)
1278 (string-append anchor
1279 "pref(\"intl.locale.requested\", \"\");\n")))
1280
1281 ;; Step out of the directory and create the tarball.
1282 (chdir "..")
1283 (format #t "Packing Icedove source tarball...~%")
1284 (force-output)
1285 (setenv "XZ_DEFAULTS" (string-join (%xz-parallel-args)))
1286 (invoke "tar" "cfa" #$output
1287 "--mtime=@315619200" ;1980-01-02 UTC
1288 "--owner=root:0"
1289 "--group=root:0"
1290 "--sort=name"
1291 #$name))))))))
1292
1293 (define-public icedove-minimal
1294 (package
1295 (name "icedove-minimal")
1296 (version %icedove-version)
1297 (source icedove-source)
1298 (properties
1299 `((cpe-name . "thunderbird_esr")))
1300 (build-system gnu-build-system)
1301 (arguments
1302 (list
1303 #:tests? #f ;no check target
1304 #:imported-modules %cargo-utils-modules ;for `generate-all-checksums'
1305 #:modules `((guix build utils) ;find-files
1306 (sxml simple)
1307 (ice-9 regex)
1308 ,@%gnu-build-system-modules)
1309 #:phases
1310 #~(modify-phases %standard-phases
1311 (add-after 'patch-source-shebangs 'patch-cargo-checksums
1312 (lambda _
1313 (use-modules (guix build cargo-utils))
1314 (let ((null-hash "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934\
1315 ca495991b7852b855"))
1316 (for-each (lambda (file)
1317 (format #t "patching checksums in ~a~%" file)
1318 (substitute* file
1319 (("^checksum = \".*\"")
1320 (string-append "checksum = \"" null-hash "\""))))
1321 (find-files "." "Cargo.lock$"))
1322 (for-each generate-all-checksums
1323 '("third_party/rust"
1324 "toolkit/library/rust")))))
1325 (add-after 'patch-cargo-checksums 'remove-cargo-frozen-flag
1326 (lambda _
1327 ;; Remove --frozen flag from cargo invokation, otherwise it'll
1328 ;; complain that it's not able to change Cargo.lock.
1329 ;; https://bugzilla.mozilla.org/show_bug.cgi?id=1726373
1330 (substitute* "build/RunCbindgen.py"
1331 (("\"--frozen\",") ""))))
1332 ;; Fixes issue where each installation directory generates its own
1333 ;; profile (see:
1334 ;; https://trac.torproject.org/projects/tor/ticket/31457).
1335 (add-after 'patch-source-shebangs 'fix-profile-setting
1336 (lambda _
1337 (substitute* "comm/mail/moz.configure"
1338 (("MOZ_DEDICATED_PROFILES, True")
1339 "MOZ_DEDICATED_PROFILES, False"))))
1340 (add-after 'build 'neutralize-store-references
1341 (lambda _
1342 ;; Mangle the store references to compilers & other build tools in
1343 ;; about:buildconfig, reducing Icedove's closure significant.
1344 ;; The resulting files are saved in lib/thunderbird/omni.ja
1345 (substitute*
1346 ;; Use find because the path "obj-x86_64-pc-linux-gnu" contains
1347 ;; the architecture and the system -> more complicated.
1348 (find-files "." "buildconfig.html")
1349 (((format #f "(~a/)([0-9a-df-np-sv-z]{32})"
1350 (regexp-quote (%store-directory)))
1351 _ store hash)
1352 (string-append store
1353 (string-take hash 8)
1354 "<!-- Guix: not a runtime dependency -->"
1355 (string-drop hash 8))))))
1356 (delete 'bootstrap)
1357 (replace 'configure
1358 (lambda* (#:key native-inputs inputs configure-flags
1359 #:allow-other-keys)
1360 (let* ((bash (which "bash"))
1361 (abs-srcdir (getcwd))
1362 (srcdir (string-append "../" (basename abs-srcdir)))
1363 (flags `(,(string-append "--prefix=" #$output)
1364 ,@configure-flags))
1365 (mozconfig (string-append (getcwd) "/.mozconfig")))
1366 (setenv "SHELL" bash)
1367 (setenv "CONFIG_SHELL" bash)
1368 (setenv "QA_CONFIGURE_OPTIONS" ".*")
1369 (setenv "MOZBUILD_STATE_PATH"
1370 (string-append (getcwd) "/mach_state"))
1371 (setenv "MOZCONFIG"
1372 (string-append (getcwd) "/.mozconfig"))
1373
1374 (setenv "AR" "llvm-ar")
1375 (setenv "NM" "llvm-nm")
1376 (setenv "CC" "clang")
1377 (setenv "CXX" "clang++")
1378
1379 (setenv "MOZ_NOSPAM" "1")
1380 (setenv "MACH_USE_SYSTEM_PYTHON" "1")
1381 (setenv "PYTHON"
1382 (search-input-file inputs "/bin/python"))
1383 (setenv "MOZ_BUILD_DATE" #$%icedove-build-id) ; avoid timestamp
1384 (setenv "MOZ_APP_NAME" "icedove")
1385 (setenv "LDFLAGS" (string-append "-Wl,-rpath=" #$output
1386 "/lib/icedove"))
1387 (mkdir-p (string-append (getcwd) "/builddir"))
1388 (with-output-to-file mozconfig
1389 (lambda ()
1390 (display
1391 (string-append
1392 "ac_add_options --allow-addon-sideload\n"
1393 "ac_add_options --with-unsigned-addon-scopes=app,system\n"
1394 "ac_add_options --disable-crashreporter\n"
1395 "ac_add_options --disable-debug\n"
1396 "ac_add_options --disable-debug-symbols\n"
1397 "ac_add_options --disable-elf-hack\n"
1398 "ac_add_options --disable-jit\n"
1399 "ac_add_options --disable-necko-wifi\n"
1400 "ac_add_options --disable-official-branding\n"
1401 "ac_add_options --disable-tests\n"
1402 "ac_add_options --disable-updater\n"
1403 "ac_add_options --disable-webrtc\n"
1404 "ac_add_options --enable-application=comm/mail\n"
1405 "ac_add_options --enable-default-toolkit=\"cairo-gtk3\"\n"
1406 "ac_add_options --enable-optimize\n"
1407 "ac_add_options --enable-pulseaudio\n"
1408 "ac_add_options --enable-release\n"
1409 "ac_add_options --enable-strip\n"
1410 "ac_add_options --enable-system-ffi\n"
1411 "ac_add_options --enable-system-pixman\n"
1412 "ac_add_options --prefix=" #$output "\n"
1413 "ac_add_options --with-clang-path="
1414 (search-input-file (or native-inputs inputs)
1415 "bin/clang") "\n"
1416 "ac_add_options --with-distribution-id=org.gnu\n"
1417 "ac_add_options --with-libclang-path="
1418 #$(this-package-native-input "clang") "/lib\n"
1419 "ac_add_options --with-system-bz2\n"
1420 "ac_add_options --with-system-icu\n"
1421 "ac_add_options --with-system-jpeg\n"
1422 "ac_add_options --with-system-libevent\n"
1423 "ac_add_options --with-system-nspr\n"
1424 "ac_add_options --with-system-nss\n"
1425 "ac_add_options --with-system-zlib\n"
1426 "ac_add_options --without-wasm-sandboxed-libraries\n"
1427 "mk_add_options MOZ_MAKE_FLAGS=-j"
1428 (number->string (parallel-job-count)) "\n"))))
1429 (display (getcwd))
1430 (newline)
1431 (display "mach configure")
1432 (invoke "./mach" "configure"))))
1433 (replace 'build
1434 (lambda _ (invoke "./mach" "build")))
1435 (replace 'install
1436 (lambda _ (invoke "./mach" "install")))
1437 ;; Thunderbird doesn't provide any .desktop file.
1438 ;; See https://bugzilla.mozilla.org/show_bug.cgi?id=1637575
1439 (add-after 'install 'install-desktop-file
1440 (lambda _
1441 (let ((apps (string-append #$output "/share/applications")))
1442 (mkdir-p apps)
1443 (with-output-to-file (string-append apps "/icedove.desktop")
1444 (lambda _
1445 (format #t
1446 "[Desktop Entry]~@
1447 Name=Icedove~@
1448 Exec=~a/bin/icedove~@
1449 Icon=icedove~@
1450 GenericName=Mail/News Client~@
1451 Categories=Network;Email;~@
1452 Terminal=false~@
1453 StartupNotify=true~@
1454 MimeType=x-scheme-handler/mailto;~@
1455 Type=Application~@
1456 Actions=ComposeMessage;~@
1457 [Desktop Action ComposeMessage]~@
1458 Name=Write new message~@
1459 Exec=~@*~a/bin/icedove -compose~%"
1460 #$output))))))
1461 (add-after 'install-desktop-file 'install-icons
1462 (lambda _
1463 (with-directory-excursion "browser/branding/official"
1464 (for-each
1465 (lambda (file)
1466 (let* ((size (string-filter char-numeric? file))
1467 (icons (string-append #$output "/share/icons/hicolor/"
1468 size "x" size "/apps")))
1469 (mkdir-p icons)
1470 (copy-file file (string-append icons "/icedove.png"))))
1471 '("default16.png" "default22.png" "default24.png"
1472 "default32.png" "default48.png" "content/icon64.png"
1473 "mozicon128.png" "default256.png")))))
1474 (add-after 'install 'wrap-program
1475 (lambda* (#:key inputs #:allow-other-keys)
1476 (let* ((lib (string-append #$output "/lib"))
1477 (gtk #$(this-package-input "gtk+"))
1478 (gtk-share (string-append gtk "/share"))
1479 (pulseaudio #$(this-package-input "pulseaudio"))
1480 (pulseaudio-lib (string-append pulseaudio "/lib"))
1481 (eudev #$(this-package-input "eudev"))
1482 (eudev-lib (string-append eudev "/lib")))
1483 (wrap-program (car (find-files lib "^icedove$"))
1484 `("XDG_DATA_DIRS" prefix (,gtk-share))
1485 `("LD_LIBRARY_PATH" prefix (,pulseaudio-lib ,eudev-lib)))))))))
1486 (inputs
1487 (list alsa-lib
1488 bzip2
1489 cairo
1490 cups
1491 dbus-glib
1492 ffmpeg
1493 freetype
1494 gdk-pixbuf
1495 glib
1496 gtk+
1497 gtk+-2
1498 hunspell
1499 icu4c-71
1500 libcanberra
1501 libevent
1502 libffi
1503 libgnome
1504 libjpeg-turbo
1505 libpng-apng
1506 libvpx
1507 libxcomposite
1508 libxft
1509 libxinerama
1510 libxscrnsaver
1511 libxt
1512 mesa
1513 mit-krb5
1514 nss-next
1515 pango
1516 pixman
1517 pulseaudio
1518 sqlite
1519 startup-notification
1520 eudev
1521 unzip
1522 zip
1523 zlib))
1524 (native-inputs
1525 (list `(,rust "cargo")
1526 clang
1527 llvm
1528 m4
1529 nasm
1530 node
1531 perl
1532 pkg-config
1533 python-wrapper
1534 rust
1535 rust-cbindgen-0.23
1536 which
1537 yasm))
1538 (home-page "https://www.thunderbird.net")
1539 (synopsis "Rebranded Mozilla Thunderbird email client")
1540 (description
1541 "This package provides an email client built based on Mozilla
1542 Thunderbird. It supports email, news feeds, chat, calendar and contacts.")
1543 (license license:mpl2.0)))
1544
1545 (define (make-l10n-package project version source locales)
1546 "Return a package for PROJECT, a symbol (either icecat or icedove), with
1547 their corresponding VERSION, SOURCE and LOCALES variables."
1548 (unless (member project '(icecat icedove))
1549 (error "only icecat or icedove components are currently supported"))
1550
1551 (let ((name (if (eq? 'icecat project)
1552 "IceCat"
1553 "Icedove")))
1554 (package
1555 (name (format #f "~a-l10n" project))
1556 (version version)
1557 (source source)
1558 (outputs (cons "out" locales))
1559 (build-system gnu-build-system)
1560 (arguments
1561 (list
1562 #:modules '((guix build gnu-build-system)
1563 (guix build utils)
1564 (ice-9 format)
1565 (ice-9 ftw)
1566 (srfi srfi-1)
1567 (srfi srfi-26))
1568 #:tests? #f ;no tests, this is data
1569 #:phases
1570 #~(modify-phases %standard-phases
1571 (delete 'bootstrap)
1572 (delete 'install)
1573 (replace 'configure
1574 (lambda _
1575 ;; The following configuration is inspired by guidance at
1576 ;; https://firefox-source-docs.mozilla.org/build/buildsystem/locales.html.
1577 (call-with-output-file ".mozconfig"
1578 (lambda (p)
1579 (format p "~{~a~%~}"
1580 (list (if (eq? 'icecat '#$project)
1581 "ac_add_options --enable-project=browser"
1582 "ac_add_options --enable-project=comm/mail")
1583 "ac_add_options --disable-compile-environment"
1584 (string-append
1585 "ac_add_options --with-l10n-base="
1586 (getcwd) "/l10n")
1587 ;; Hack, otherwise the build system throws:
1588 ;; 'RuntimeError: File "brand.dtd" not found'.
1589 "ac_add_options --enable-official-branding"
1590 "mk_add_options MOZ_OBJDIR=obj"))))
1591 (setenv "CONFIG_SHELL" (which "bash"))
1592 (setenv "MOZBUILD_STATE_PATH"
1593 (string-append (getcwd) "/mach_state"))
1594 (setenv "MOZCONFIG" (string-append (getcwd) "/.mozconfig"))
1595 (setenv "MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE" "system")
1596 (setenv "BUILD_BACKENDS" "FasterMake,RecursiveMake")))
1597 (replace 'build ;build and install data files
1598 (lambda* (#:key outputs #:allow-other-keys)
1599 (define (find-file dir name)
1600 (let ((files (find-files dir name)))
1601 (when (null? files)
1602 (error "could not find file in dir" name dir))
1603 (car files)))
1604
1605 (for-each
1606 (lambda (l)
1607 (let* ((out (assoc-ref outputs l))
1608 ;; The older lib/$project/distribution/extensions
1609 ;; directory is deprecated. Use the newer app-global
1610 ;; directory, which is lib/$project/extensions.
1611 (ext-dir-prefix
1612 (format
1613 #f "lib/~a/~:[~;browser/~]extensions"
1614 '#$project (eq? 'icecat '#$project)))
1615 (all-ext (string-append #$output "/" ext-dir-prefix))
1616 (ext-dir (string-append out "/" ext-dir-prefix))
1617 ;; XXX: Because Icedove doesn't have a makeicedove
1618 ;; script that substitutes all the Thunderbird
1619 ;; references to Icedove, the MOZ_LANGPACK_EID
1620 ;; defined in comm/mail/locales/Makefile.in uses
1621 ;; 'thunderbird' in its ID extension rather than
1622 ;; 'icedove'.
1623 (name (format #f "langpack-~a@~a.mozilla.org.xpi"
1624 l (if (eq? 'icedove '#$project)
1625 'thunderbird
1626 '#$project))))
1627 (format #t "processing locale `~a'...~%" l)
1628 (if (eq? 'icecat '#$project)
1629 ;; XXX: For some reasons, for IceCat, there are some
1630 ;; parsing errors that cause the build system to
1631 ;; return an unclean exit code; use system* to ignore
1632 ;; errors.
1633 (system* "./mach" "build" (string-append "langpack-" l))
1634 (invoke "./mach" "build" (string-append "langpack-" l)))
1635 (mkdir-p ext-dir)
1636 (let ((xpi (find-file "obj" (string-append
1637 "\\." l "\\.langpack\\.xpi$"))))
1638 (copy-file xpi (string-append ext-dir "/" name))
1639 ;; Symlink to the main output so that a user can
1640 ;; install all of the language packs at once.
1641 (mkdir-p all-ext)
1642 (symlink (string-append ext-dir "/" name)
1643 (string-append all-ext "/" name)))))
1644 (if (eq? 'icedove '#$project)
1645 '#$%icedove-locales
1646 '#$%icecat-locales)))))))
1647 (native-inputs
1648 (list m4
1649 perl
1650 python-wrapper
1651 node
1652 unzip))
1653 (home-page "https://www.mozilla.org/")
1654 (synopsis (string-append "Language localization data for " name))
1655 (description (string-append "This package contains the various language
1656 localization data files (language pack extensions) for " name ". The
1657 individual localization packages can be installed by using the output
1658 associated with their name."))
1659 (license license:mpl2.0))))
1660
1661 (define-public icecat-l10n
1662 (make-l10n-package 'icecat %icecat-version icecat-source %icecat-locales))
1663
1664 (define-public icedove-l10n
1665 (make-l10n-package 'icedove %icedove-version icedove-source %icedove-locales))
1666
1667 ;;; This hack exists because there's no way to configure extra extension
1668 ;;; search paths for IceCat or Icedove. The global extensions directory is
1669 ;;; constructed relatively to the executable file name.
1670 (define (make-mozilla-with-l10n project base l10n-package)
1671 "Return a package definition for PROJECT (a symbol such as 'icecat or
1672 'icedove) that combines the BASE package with L10N-PACKAGE."
1673
1674 (unless (member project '(icecat icedove))
1675 (error "only icecat or icedove components are currently supported"))
1676
1677 (let ((name (symbol->string project))
1678 (icecat? (eq? 'icecat project)))
1679 (package
1680 (inherit base)
1681 (name (symbol->string project))
1682 (build-system trivial-build-system)
1683 (arguments
1684 (list
1685 #:modules '((guix build union)
1686 (guix build utils))
1687 #:builder
1688 #~(begin
1689 (use-modules (guix build union)
1690 (guix build utils))
1691
1692 (union-build #$output (list #$base #$l10n-package)
1693 #:create-all-directories? #t)
1694
1695 (define* (expose name #:optional (proc copy-file)
1696 #:key (source #$base))
1697 (let ((dest (string-append #$output "/" name)))
1698 (mkdir-p (dirname dest))
1699 (proc (string-append source "/" name) dest)))
1700
1701 (let ((wrapper (string-append "lib/" #$name "/" #$name))
1702 (real-binary (string-append "lib/" #$name "/." #$name
1703 "-real"))
1704 (desktop-file (string-append "share/applications/"
1705 #$name ".desktop")))
1706 ;; Copy wrapper file.
1707 (delete-file (string-append #$output "/" wrapper))
1708 (expose wrapper)
1709
1710 ;; Recreate bin symlink.
1711 (delete-file (string-append #$output "/bin/" #$name))
1712 (symlink (string-append #$output "/" wrapper)
1713 (string-append #$output "/bin/" #$name))
1714
1715 ;; Copy actual binary.
1716 (delete-file (string-append #$output "/" real-binary))
1717 (expose real-binary)
1718
1719 ;; Copy desktop file.
1720 (delete-file (string-append #$output "/" desktop-file))
1721 (expose desktop-file)
1722
1723 ;; Adjust the references in the desktop file and wrapper.
1724 (substitute* (list (string-append #$output "/" desktop-file)
1725 (string-append #$output "/" wrapper))
1726 ((#$base) #$output)))))))))
1727
1728 (define-public icecat
1729 (make-mozilla-with-l10n 'icecat icecat-minimal icecat-l10n))
1730
1731 (define-public icedove
1732 (make-mozilla-with-l10n 'icedove icedove-minimal icedove-l10n))
1733
1734 (define-public icedove/wayland
1735 (package
1736 (inherit icedove)
1737 (name "icedove-wayland")
1738 (build-system trivial-build-system)
1739 (arguments
1740 (list
1741 #:modules '((guix build utils))
1742 #:builder
1743 #~(begin
1744 (use-modules (guix build utils))
1745 (let* ((exe (string-append #$output "/bin/icedove")))
1746 (mkdir-p (dirname exe))
1747 (call-with-output-file exe
1748 (lambda (port)
1749 (format port "#!~a
1750 MOZ_ENABLE_WAYLAND=1 exec ~a $@"
1751 #$(file-append bash-minimal "/bin/bash")
1752 #$(file-append icedove "/bin/icedove"))))
1753 (chmod exe #o555)
1754 ;; Provide the manual and .desktop file.
1755 (copy-recursively (string-append #$icedove "/share")
1756 (string-append #$output "/share"))
1757 (substitute* (string-append #$output
1758 "/share/applications/icedove.desktop")
1759 ((#$icedove) #$output))))))
1760 (native-inputs '())
1761 (inputs '())))
1762
1763 (define-public firefox-decrypt
1764 (package
1765 (name "firefox-decrypt")
1766 (version "0.7.0")
1767 (source (origin
1768 (method git-fetch)
1769 (uri (git-reference
1770 (url "https://github.com/Unode/firefox_decrypt")
1771 (commit version)))
1772 (file-name (git-file-name name version))
1773 (sha256
1774 (base32
1775 "17yyyxp47z4m8hnflcq34rc1y871515kr3f1y42j1l0yx3g0il07"))))
1776 (build-system trivial-build-system)
1777 (inputs
1778 (list nss python))
1779 (arguments
1780 `(#:modules ((guix build utils))
1781 #:builder
1782 (begin
1783 (use-modules (guix build utils))
1784 (setenv "PATH"
1785 (string-append
1786 (assoc-ref %build-inputs "python") "/bin"))
1787 (copy-file (string-append (assoc-ref %build-inputs "source")
1788 "/firefox_decrypt.py")
1789 "firefox_decrypt.py")
1790 (substitute* "firefox_decrypt.py"
1791 (("/usr/bin/env python") (which "python3"))
1792 (("libnss3.so") (string-append (assoc-ref %build-inputs "nss")
1793 "/lib/nss/libnss3.so")))
1794 (install-file "firefox_decrypt.py" (string-append %output "/bin"))
1795 #t)))
1796 (home-page "https://github.com/Unode/firefox_decrypt/")
1797 (synopsis "Tool to extract passwords from Mozilla profiles")
1798 (description "Firefox Decrypt is a tool to extract passwords from
1799 Mozilla (Firefox, Waterfox, Thunderbird, SeaMonkey) profiles.")
1800 (license license:gpl3+)))
1801
1802 (define-public lz4json
1803 (package
1804 (name "lz4json")
1805 (version "2")
1806 (source
1807 (origin
1808 (method git-fetch)
1809 (uri
1810 (git-reference
1811 (url "https://github.com/andikleen/lz4json")
1812 (commit (string-append "v" version))))
1813 (file-name (git-file-name name version))
1814 (sha256
1815 (base32 "1xxn8yzr6j8j6prmbj6mxspdczigarfiv3vlm9k70yxmky65ijh3"))))
1816 (build-system gnu-build-system)
1817 (native-inputs (list pkg-config))
1818 (inputs (list lz4))
1819 (arguments
1820 `(#:tests? #f ; no check target
1821 #:phases
1822 (modify-phases %standard-phases
1823 (delete 'configure) ; no configure script
1824 (replace 'install ; no install target
1825 (lambda* (#:key outputs #:allow-other-keys)
1826 (let* ((out (assoc-ref outputs "out"))
1827 (bin (string-append out "/bin"))
1828 (man (string-append out "/share/man/man1")))
1829 (install-file "lz4jsoncat" bin)
1830 (install-file "lz4jsoncat.1" man)))))
1831 #:make-flags `(,(string-append "CC=" ,(cc-for-target)))))
1832 (home-page "https://github.com/andikleen/lz4json")
1833 (synopsis "C decompress tool for mozilla lz4json format")
1834 (description
1835 "@code{lz4json} is a little utility to unpack lz4json files as generated
1836 by Firefox's bookmark backups and session restore. This is a different format
1837 from what the normal lz4 utility expects. The data is dumped to stdout.")
1838 (license license:bsd-2)))