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 Ludovic Courtès <ludo@gnu.org>
4 ;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019 Mark H Weaver <mhw@netris.org>
5 ;;; Copyright © 2015 Sou Bunnbu <iyzsong@gmail.com>
6 ;;; Copyright © 2016, 2017, 2018 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 ng0 <ng0@n0.is>
10 ;;; Copyright © 2017, 2018 Tobias Geerinckx-Rice <me@tobias.gr>
11 ;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
12 ;;; Copyright © 2019 Ivan Petkov <ivanppetkov@gmail.com>
14 ;;; This file is part of GNU Guix.
16 ;;; GNU Guix is free software; you can redistribute it and/or modify it
17 ;;; under the terms of the GNU General Public License as published by
18 ;;; the Free Software Foundation; either version 3 of the License, or (at
19 ;;; your option) any later version.
21 ;;; GNU Guix is distributed in the hope that it will be useful, but
22 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
23 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 ;;; GNU General Public License for more details.
26 ;;; You should have received a copy of the GNU General Public License
27 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
29 (define-module (gnu packages gnuzilla)
30 #:use-module ((srfi srfi-1) #:hide (zip))
31 #:use-module (ice-9 match)
32 #:use-module (gnu packages)
33 #:use-module ((guix licenses) #:prefix license:)
34 #:use-module (guix packages)
35 #:use-module (guix download)
36 #:use-module (guix git-download)
37 #:use-module (guix gexp)
38 #:use-module (guix store)
39 #:use-module (guix monads)
40 #:use-module (guix utils)
41 #:use-module (guix build-system gnu)
42 #:use-module (guix build-system cargo)
43 #:use-module (gnu packages admin)
44 #:use-module (gnu packages audio)
45 #:use-module (gnu packages autotools)
46 #:use-module (gnu packages base)
47 #:use-module (gnu packages bash)
48 #:use-module (gnu packages databases)
49 #:use-module (gnu packages glib)
50 #:use-module (gnu packages gtk)
51 #:use-module (gnu packages gnome)
52 #:use-module (gnu packages libcanberra)
53 #:use-module (gnu packages cups)
54 #:use-module (gnu packages kerberos)
55 #:use-module (gnu packages linux)
56 #:use-module (gnu packages perl)
57 #:use-module (gnu packages pkg-config)
58 #:use-module (gnu packages compression)
59 #:use-module (gnu packages fontutils)
60 #:use-module (gnu packages libevent)
61 #:use-module (gnu packages libreoffice) ;for hunspell
62 #:use-module (gnu packages image)
63 #:use-module (gnu packages libffi)
64 #:use-module (gnu packages pulseaudio)
65 #:use-module (gnu packages python)
66 #:use-module (gnu packages python-xyz)
67 #:use-module (gnu packages xorg)
68 #:use-module (gnu packages gl)
69 #:use-module (gnu packages assembly)
70 #:use-module (gnu packages rust)
71 #:use-module (gnu packages llvm)
72 #:use-module (gnu packages nss)
73 #:use-module (gnu packages icu4c)
74 #:use-module (gnu packages video)
75 #:use-module (gnu packages xiph)
76 #:use-module (gnu packages xdisorg)
77 #:use-module (gnu packages readline)
78 #:use-module (gnu packages sqlite))
87 "https://ftp.mozilla.org/pub/mozilla.org/js/"
88 name version ".tar.gz"))
91 "1fig2wf4f10v43mqx67y68z6h77sy900d1w0pz9qarrqx57rc7ij"))
92 (patches (search-patches "mozjs17-aarch64-support.patch"))
93 (modules '((guix build utils)))
95 ;; Fix incompatibility with Perl 5.22+.
97 (substitute* '("js/src/config/milestone.pl")
98 (("defined\\(@TEMPLATE_FILE)") "@TEMPLATE_FILE"))
100 (build-system gnu-build-system)
103 ("pkg-config" ,pkg-config)
104 ("python" ,python-2)))
106 `(("nspr" ,nspr))) ; in the Requires.private field of mozjs-17.0.pc
110 `(;; XXX: parallel build fails, lacking:
111 ;; mkdir -p "system_wrapper_js/"
114 (modify-phases %standard-phases
115 (add-after 'unpack 'delete-timedout-test
116 ;; This test times out on slower hardware.
118 (delete-file "js/src/jit-test/tests/basic/bug698584.js")
120 (add-before 'configure 'chdir
125 ;; configure fails if it is followed by SHELL and CONFIG_SHELL
126 (lambda* (#:key outputs #:allow-other-keys)
127 (let ((out (assoc-ref outputs "out")))
128 (setenv "SHELL" (which "sh"))
129 (setenv "CONFIG_SHELL" (which "sh"))
130 (invoke "./configure" (string-append "--prefix=" out)
131 ,@(if (string=? "aarch64-linux"
133 '("--host=aarch64-unknown-linux-gnu")
136 "https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey")
137 (synopsis "Mozilla javascript engine")
138 (description "SpiderMonkey is Mozilla's JavaScript engine written
140 (license license:mpl2.0))) ; and others for some files
142 (define-public mozjs-24
143 (package (inherit mozjs)
149 "https://ftp.mozilla.org/pub/mozilla.org/js/"
150 name "-" version ".tar.bz2"))
153 "1n1phk8r3l8icqrrap4czplnylawa0ddc2cc4cgdz46x3lrkybz6"))
154 (modules '((guix build utils)))
155 (patches (search-patches "mozjs24-aarch64-support.patch"))
157 ;; Fix incompatibility with Perl 5.22+.
159 (substitute* '("js/src/config/milestone.pl")
160 (("defined\\(@TEMPLATE_FILE)") "@TEMPLATE_FILE"))
163 (substitute-keyword-arguments (package-arguments mozjs)
165 `(modify-phases ,phases
167 (lambda* (#:key outputs #:allow-other-keys)
168 (let ((out (assoc-ref outputs "out")))
169 ;; configure fails if it is followed by SHELL and CONFIG_SHELL
170 (setenv "SHELL" (which "sh"))
171 (setenv "CONFIG_SHELL" (which "sh"))
172 (invoke "./configure"
173 (string-append "--prefix=" out)
175 "--enable-system-ffi"
176 "--enable-threadsafe"
177 ,@(if (string=? "aarch64-linux"
179 '("--host=aarch64-unknown-linux-gnu")
185 (define-public mozjs-38
189 (version "38.2.1.rc0")
193 "https://anduin.linuxfromscratch.org/BLFS/mozjs/"
194 name "-" version ".tar.bz2"))
197 "0p4bmbpgkfsj54xschcny0a118jdrdgg0q29rwxigg3lh5slr681"))
200 ;; See https://bugzilla.mozilla.org/show_bug.cgi?id=1269317 for
201 ;; GCC 6 compatibility.
203 "mozjs38-version-detection.patch" ; for 0ad
204 "mozjs38-tracelogger.patch"
206 ;; See https://bugzilla.mozilla.org/show_bug.cgi?id=1339931.
207 "mozjs38-pkg-config-version.patch"
208 "mozjs38-shell-version.patch"))
209 (modules '((guix build utils)))
212 ;; Fix incompatibility with sed 4.4.
213 (substitute* "js/src/configure"
214 (("\\^\\[:space:\\]") "^[[:space:]]"))
216 ;; The headers are symlinks to files that are in /tmp, so they
217 ;; end up broken. Copy them instead.
219 "python/mozbuild/mozbuild/backend/recursivemake.py"
220 (("\\['dist_include'\\].add_symlink")
221 "['dist_include'].add_copy"))
223 ;; Remove bundled libraries.
224 (for-each delete-file-recursively
226 "js/src/ctypes/libffi"
227 "js/src/ctypes/libffi-patches"
231 `(;; XXX: parallel build fails, lacking:
232 ;; mkdir -p "system_wrapper_js/"
234 ;; See https://bugzilla.mozilla.org/show_bug.cgi?id=1008470.
237 (modify-phases %standard-phases
239 (lambda* (#:key outputs #:allow-other-keys)
240 (let ((out (assoc-ref outputs "out")))
242 (setenv "SHELL" (which "sh"))
243 (setenv "CONFIG_SHELL" (which "sh"))
244 (invoke "./configure"
245 (string-append "--prefix=" out)
247 "--enable-gcgenerational"
252 "--enable-system-ffi"
253 "--enable-threadsafe"
254 "--enable-xterm-updates"
259 ;; Intl API requires bundled ICU.
260 "--without-intl-api")))))))
263 ("pkg-config" ,pkg-config)
264 ("python-2" ,python-2)))
267 ("readline" ,readline)
271 (define-public mozjs-52
272 ;; No releases yet at <https://archive.mozilla.org/pub/spidermonkey/releases/>.
273 ;; While we could take a snapshot of the complete mozilla-esr52 repository at
274 ;; <https://treeherder.mozilla.org/#/jobs?repo=mozilla-esr52&filter-searchStr=sm-tc>,
275 ;; we take the Debian version instead, because it is easier to work with.
276 (let ((commit "6507e63cc416fd7a3269e390efe712f8b56f374a")
278 (package (inherit mozjs-38)
279 (version (git-version "52.0" revision commit))
283 (url "https://salsa.debian.org/gnome-team/mozjs52.git")
285 (file-name (git-file-name "mozjs" version))
288 "1ny0s53r8wn4byys87h784xrq1xg767akmfm6gqrbvrz57mlm3q2"))))
290 `(#:tests? #f ; depends on repository metadata
297 "--enable-system-ffi"
302 ;; Intl API requires bundled ICU.
305 ;; Without this gnome-shell will crash at runtime.
306 "--disable-jemalloc")
308 (modify-phases %standard-phases
309 (add-after 'unpack 'patch-and-chdir
310 (lambda* (#:key inputs #:allow-other-keys)
311 ;; This patch prevents a segfault when executing JS_Init().
312 ;; The build does not fail without this patch, but the
313 ;; configure phase of the gjs package would fail.
314 ;; See https://bugzilla.mozilla.org/show_bug.cgi?id=1176787
315 (make-file-writable "js/src/old-configure.in")
316 (make-file-writable "js/src/old-configure")
317 (make-file-writable "mozglue/build/moz.build")
318 (invoke "patch" "-p1" "--force"
319 "--input" "debian/patches/disable-mozglue.patch")
320 (invoke "touch" "js/src/configure")
324 (lambda* (#:key inputs outputs configure-flags #:allow-other-keys)
325 ;; The configure script does not accept environment variables
327 (let ((out (assoc-ref outputs "out")))
328 (setenv "SHELL" (which "sh"))
329 (setenv "CONFIG_SHELL" (which "sh"))
330 (setenv "AUTOCONF" (string-append (assoc-ref inputs "autoconf")
332 (apply invoke "./configure"
333 (cons (string-append "--prefix=" out)
334 configure-flags))))))))
336 `(("autoconf" ,autoconf-2.13)
337 ("automake" ,automake)
338 ,@(package-native-inputs mozjs-38))))))
340 (define-public mozjs-60
341 ;; No releases yet at <https://archive.mozilla.org/pub/spidermonkey/releases/>.
342 ;; While we could take a snapshot of the complete mozilla-esr60 repository at
343 ;; <https://treeherder.mozilla.org/#/jobs?repo=mozilla-esr60&filter-searchStr=sm-tc>,
344 ;; we take the Debian version instead, because it is easier to work with.
351 (url "https://salsa.debian.org/gnome-team/mozjs60.git")
352 (commit (string-append "debian/" version))))
353 (file-name (git-file-name "mozjs" version))
356 "091w050rwzrdcbgyi934k2viyccmlqxrp13sm2mql71mabb5dai6"))))
358 `(#:tests? #f ; FIXME: all tests pass, but then the check phase fails anyway.
359 #:test-target "check-jstests"
366 "--enable-system-ffi"
371 ;; This is important because without it gjs will segfault during the
372 ;; configure phase. With jemalloc only the standalone mozjs console
374 "--disable-jemalloc")
376 (modify-phases %standard-phases
378 (lambda* (#:key inputs outputs configure-flags #:allow-other-keys)
379 ;; The configure script does not accept environment variables as
380 ;; arguments. It also must be run from a different directory,
381 ;; but not the root directory either.
382 (let ((out (assoc-ref outputs "out")))
383 (mkdir "run-configure-from-here")
384 (chdir "run-configure-from-here")
385 (setenv "SHELL" (which "sh"))
386 (setenv "CONFIG_SHELL" (which "sh"))
387 (setenv "AUTOCONF" (string-append (assoc-ref inputs "autoconf")
389 (apply invoke "../js/src/configure"
390 (cons (string-append "--prefix=" out)
393 (add-after 'unpack 'disable-broken-tests
395 ;; This test assumes that /bin exists and contains certain
397 (delete-file "js/src/tests/shell/os.js")
400 `(("autoconf" ,autoconf)
401 ("automake" ,automake)
404 ("pkg-config" ,pkg-config)
405 ("python" ,python-2)))))
407 (define (mozilla-patch file-name changeset hash)
408 "Return an origin for CHANGESET from the mozilla-esr60 repository."
411 (uri (string-append "https://hg.mozilla.org/releases/mozilla-esr60/raw-rev/"
413 (sha256 (base32 hash))
414 (file-name file-name)))
416 (define* (computed-origin-method gexp-promise hash-algo hash
417 #:optional (name "source")
418 #:key (system (%current-system))
419 (guile (default-guile)))
420 "Return a derivation that executes the G-expression that results
421 from forcing GEXP-PROMISE."
422 (mlet %store-monad ((guile (package->derivation guile system)))
423 (gexp->derivation (or name "computed-origin")
425 #:graft? #f ;nothing to graft
427 #:guile-for-build guile)))
429 (define %icecat-version "60.8.0-guix1")
431 ;; 'icecat-source' is a "computed" origin that generates an IceCat tarball
432 ;; from the corresponding upstream Firefox ESR tarball, using the 'makeicecat'
433 ;; script from the upstream IceCat project.
434 (define icecat-source
435 (let* ((base-version (first (string-split %icecat-version #\-)))
437 (major-version (first (string-split base-version #\.)))
438 (minor-version (second (string-split base-version #\.)))
439 (sub-version (third (string-split base-version #\.)))
441 (upstream-firefox-version (string-append base-version "esr"))
442 (upstream-firefox-source
446 "https://ftp.mozilla.org/pub/firefox/releases/"
447 upstream-firefox-version "/source/"
448 "firefox-" upstream-firefox-version ".source.tar.xz"))
451 "1gkz90clarbhgfxhq91s0is6lw6bfymyjb0xbyyswdg68kcqfcy1"))))
453 (upstream-icecat-base-version "60.7.0") ; maybe older than base-version
454 (upstream-icecat-gnu-version "1")
455 (upstream-icecat-version (string-append upstream-icecat-base-version
457 upstream-icecat-gnu-version))
458 (upstream-icecat-source
462 "mirror://gnu/gnuzilla/" upstream-icecat-base-version
463 "/icecat-" upstream-icecat-version ".tar.bz2"))
466 "09xqdfd8rwbn2n6m7n059qf1psbrj5v5kfzm7gg5xng22ddxawv8"))))
468 (gnuzilla-commit (string-append "v" upstream-icecat-base-version))
473 (url "git://git.savannah.gnu.org/gnuzilla.git")
474 (commit gnuzilla-commit)))
475 (file-name (git-file-name "gnuzilla" upstream-icecat-base-version))
478 "1vqhb0py28hnwcynbaad304ziciz1kn5bv1qg2q4f7g13js3b1hf"))))
481 (local-file (search-patch "icecat-makeicecat.patch"))))
484 (method computed-origin-method)
485 (file-name (string-append "icecat-" %icecat-version ".tar.xz"))
489 (with-imported-modules '((guix build utils))
491 (use-modules (guix build utils))
493 (string-append "firefox-" #$base-version))
495 (string-append "icecat-" #$%icecat-version))
497 (string-append "icecat-" #$upstream-icecat-base-version)))
500 (set-path-environment-variable
503 #+(canonical-package bash)
504 #+(canonical-package coreutils)
505 #+(canonical-package findutils)
506 #+(canonical-package patch)
507 #+(canonical-package xz)
508 #+(canonical-package sed)
509 #+(canonical-package grep)
510 #+(canonical-package bzip2)
511 #+(canonical-package gzip)
512 #+(canonical-package tar)
515 (symlink #+(file-append rename "/bin/rename")
518 ;; We copy the gnuzilla source directory because it is
519 ;; read-only in 'gnuzilla-source', and the makeicecat script
520 ;; uses "cp -a" to copy parts of it and assumes that the
521 ;; copies will be writable.
522 (copy-recursively #+gnuzilla-source "/tmp/gnuzilla"
523 #:log (%make-void-port "w"))
525 (with-directory-excursion "/tmp/gnuzilla"
526 (make-file-writable "makeicecat")
527 (invoke "patch" "--force" "--no-backup-if-mismatch"
528 "-p1" "--input" #+makeicecat-patch)
529 (patch-shebang "makeicecat")
530 (substitute* "makeicecat"
531 (("^FFMAJOR=(.*)" all ffmajor)
532 (unless (string=? #$major-version
533 (string-trim-both ffmajor))
534 ;; The makeicecat script cannot be expected to work
535 ;; properly on a different version of Firefox, even if
536 ;; no errors occur during execution.
537 (error "makeicecat major version mismatch"))
538 (string-append "FFMAJOR=" #$major-version "\n"))
540 (string-append "FFMINOR=" #$minor-version "\n"))
542 (string-append "FFSUB=" #$sub-version "\n"))
544 (string-append "GNUVERSION="
545 #$upstream-icecat-gnu-version "\n"))
547 "DATA=/tmp/gnuzilla/data\n")
548 (("^find extensions/gnu/ ")
549 "find extensions/gnu/ | sort ")
551 #+(file-append (canonical-package sed) "/bin/sed"))))
553 (format #t "Unpacking upstream firefox tarball...~%")
555 (invoke "tar" "xf" #+upstream-firefox-source)
556 (rename-file firefox-dir icecat-dir)
558 (with-directory-excursion icecat-dir
560 (format #t "Running makeicecat script...~%")
562 (invoke "bash" "/tmp/gnuzilla/makeicecat")
563 (delete-file-recursively "l10n"))
565 (format #t (string-append "Unpacking l10n/* from"
566 " upstream IceCat tarball...~%"))
568 (unless (string=? icecat-dir old-icecat-dir)
569 (symlink icecat-dir old-icecat-dir))
570 (invoke "tar" "xf" #+upstream-icecat-source
571 (string-append old-icecat-dir "/l10n"))
573 (format #t "Packing new IceCat tarball...~%")
575 (invoke "tar" "cfa" #$output
576 ;; Avoid non-determinism in the archive. We set the
577 ;; mtime of files in the archive to early 1980 because
578 ;; the build process fails if the mtime of source
579 ;; files is pre-1980, due to the creation of zip
581 "--mtime=@315619200" ; 1980-01-02 UTC
589 (define-public icecat
592 (version %icecat-version)
593 (source icecat-source)
594 (build-system gnu-build-system)
596 `(("alsa-lib" ,alsa-lib)
599 ("dbus-glib" ,dbus-glib)
600 ("gdk-pixbuf" ,gdk-pixbuf)
604 ("graphite2" ,graphite2)
606 ("freetype" ,freetype)
607 ("harfbuzz" ,harfbuzz)
608 ("hunspell" ,hunspell)
609 ("libcanberra" ,libcanberra)
610 ("libgnome" ,libgnome)
611 ("libjpeg-turbo" ,libjpeg-turbo)
613 ;; ("libtheora" ,libtheora) ; wants theora-1.2, not yet released
614 ("libvorbis" ,libvorbis)
616 ("libevent" ,libevent)
617 ("libxinerama" ,libxinerama)
618 ("libxscrnsaver" ,libxscrnsaver)
619 ("libxcomposite" ,libxcomposite)
623 ("libvpx" ,libvpx-1.7)
626 ("pulseaudio" ,pulseaudio)
628 ("mit-krb5" ,mit-krb5)
629 ;; See <https://bugs.gnu.org/32833>
630 ;; and related comments in the 'remove-bundled-libraries' phase.
631 ;; UNBUNDLE-ME! ("nspr" ,nspr)
632 ;; UNBUNDLE-ME! ("nss" ,nss)
634 ("startup-notification" ,startup-notification)
639 ;; The following patches are specific to the Guix packaging of IceCat,
640 ;; and therefore we prefer to leave them out of 'source', which should be
641 ;; a tarball suitable for compilation on any system that IceCat supports.
642 ;; (Bug fixes and security fixes, however, should go in 'source').
643 `(("icecat-avoid-bundled-libraries.patch"
644 ,(search-patch "icecat-avoid-bundled-libraries.patch"))
645 ("icecat-use-system-graphite2+harfbuzz.patch"
646 ,(search-patch "icecat-use-system-graphite2+harfbuzz.patch"))
647 ("icecat-use-system-media-libs.patch"
648 ,(search-patch "icecat-use-system-media-libs.patch"))
650 ("patch" ,(canonical-package patch))
652 ;; Icecat 60 checks for rust>=1.24
654 ("cargo" ,rust-1.24 "cargo")
656 ("clang" ,clang-3.9.1)
658 ("python" ,python-2) ; Python 3 not supported
659 ("python2-pysqlite" ,python2-pysqlite)
661 ("pkg-config" ,pkg-config)
662 ("autoconf" ,autoconf-2.13)
665 `(#:tests? #f ; no check target
666 #:out-of-source? #t ; must be built outside of the source directory
668 ;; XXX: There are RUNPATH issues such as
669 ;; $prefix/lib/icecat-31.6.0/plugin-container NEEDing libmozalloc.so,
670 ;; which is not in its RUNPATH, but they appear to be harmless in
671 ;; practice somehow. See <http://hydra.gnu.org/build/378133>.
672 #:validate-runpath? #f
674 #:configure-flags `("--enable-default-toolkit=cairo-gtk3"
676 "--with-distribution-id=org.gnu"
678 "--enable-startup-notification"
679 "--enable-pulseaudio"
683 "--disable-crashreporter"
684 "--disable-maintenance-service"
688 ;; Building with debugging symbols takes ~5GiB, so
691 "--disable-debug-symbols"
693 ;; Clang is needed to build Stylo, Mozilla's new
694 ;; CSS engine. We must specify the clang paths
695 ;; manually, because otherwise the Mozilla build
696 ;; system looks in the directories returned by
697 ;; llvm-config --bindir and llvm-config --libdir,
698 ;; which return paths in the llvm package where
699 ;; clang is not found.
700 ,(string-append "--with-clang-path="
701 (assoc-ref %build-inputs "clang")
703 ,(string-append "--with-libclang-path="
704 (assoc-ref %build-inputs "clang")
707 ;; Hack to work around missing
708 ;; "unofficial" branding in icecat.
709 "--enable-official-branding"
711 ;; Avoid bundled libraries.
714 "--with-system-jpeg" ; must be libjpeg-turbo
715 "--with-system-libevent"
717 "--with-system-vorbis"
718 ;; "--with-system-theora" ; wants theora-1.2, not yet released
719 "--with-system-libvpx"
722 ;; See <https://bugs.gnu.org/32833>
723 ;; and related comments in the
724 ;; 'remove-bundled-libraries' phase below.
725 ;; UNBUNDLE-ME! "--with-system-nspr"
726 ;; UNBUNDLE-ME! "--with-system-nss"
728 "--with-system-harfbuzz"
729 "--with-system-graphite2"
730 "--enable-system-pixman"
731 "--enable-system-ffi"
732 "--enable-system-hunspell"
733 "--enable-system-sqlite"
735 ;; Fails with "--with-system-png won't work because
736 ;; the system's libpng doesn't have APNG support".
738 ;; http://sourceforge.net/projects/libpng-apng/ ,
739 ;; "the Animated Portable Network Graphics (APNG)
740 ;; is an unofficial extension of the Portable
741 ;; Network Graphics (PNG) format";
742 ;; we probably do not wish to support it.
743 ;; "--with-system-png"
746 #:imported-modules ,%cargo-utils-modules ;for `generate-checksums'
748 #:modules ((ice-9 ftw)
751 ,@%gnu-build-system-modules)
753 (modify-phases %standard-phases
754 (add-after 'unpack 'apply-guix-specific-patches
755 (lambda* (#:key inputs native-inputs #:allow-other-keys)
756 (let ((patch (string-append (assoc-ref (or native-inputs inputs)
759 (for-each (match-lambda
761 (when (and (string-prefix? "icecat-" label)
762 (string-suffix? ".patch" label))
763 (format #t "applying '~a'...~%" file)
764 (invoke patch "--force" "--no-backup-if-mismatch"
765 "-p1" "--input" file))))
766 (or native-inputs inputs)))
768 (add-after 'apply-guix-specific-patches 'remove-bundled-libraries
770 ;; Remove bundled libraries that we don't use, since they may
771 ;; contain unpatched security flaws, they waste disk space and
772 ;; memory, and may cause confusion.
773 (for-each (lambda (file)
774 (format #t "deleting '~a'...~%" file)
775 (delete-file-recursively file))
776 '(;; FIXME: Removing the bundled icu breaks configure.
777 ;; * The bundled icu headers are used in some places.
778 ;; * The version number is taken from the bundled copy.
781 ;; FIXME: A script from the bundled nspr is used.
784 ;; FIXME: With the update to IceCat 60, using system NSS
785 ;; broke certificate validation. See
786 ;; <https://bugs.gnu.org/32833>. For now, we use
787 ;; the bundled NSPR and NSS. TODO: Investigate,
788 ;; and try to unbundle these libraries again.
789 ;; UNBUNDLE-ME! "security/nss"
791 ;; TODO: Use more system media libraries. See:
792 ;; <https://bugzilla.mozilla.org/show_bug.cgi?id=517422>
793 ;; * libtheora: esr60 wants v1.2, not yet released.
794 ;; * soundtouch: avoiding the bundled library would
795 ;; result in some loss of functionality. There's
796 ;; also an issue with exception handling
797 ;; configuration. It seems that this is needed in
799 ;; DEFINES['ST_NO_EXCEPTION_HANDLING'] = 1
806 "ipc/chromium/src/third_party/libevent"
811 ;; "media/libtheora" ; wants theora-1.2, not yet released
815 "js/src/ctypes/libffi"
818 (add-after 'remove-bundled-libraries 'link-libxul-with-libraries
820 ;; libxul.so dynamically opens libraries, so here we explicitly
821 ;; link them into libxul.so instead.
823 ;; TODO: It might be preferable to patch in absolute file names in
824 ;; calls to dlopen or PR_LoadLibrary, but that didn't seem to
825 ;; work. More investigation is needed.
826 (substitute* "toolkit/library/moz.build"
827 (("^# This library needs to be last" all)
828 (string-append "OS_LIBS += [
829 'GL', 'gnome-2', 'canberra', 'Xss', 'cups', 'gssapi_krb5',
830 'avcodec', 'avutil', 'pulse' ]\n\n"
835 (invoke "sh" "-c" "autoconf old-configure.in > old-configure")
836 ;; 'configure' must be newer than 'old-configure.in', or else the
837 ;; build system will raise an alarm and abort.
838 (invoke "touch" "configure")))
839 (add-after 'patch-source-shebangs 'patch-cargo-checksums
841 (use-modules (guix build cargo-utils))
842 (let ((null-hash "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"))
843 (substitute* '("Cargo.lock" "servo/Cargo.lock")
844 (("(\"checksum .* = )\".*\"" all name)
845 (string-append name "\"" null-hash "\"")))
848 (delete-file filename)
849 (let ((dir (dirname filename)))
850 (display (string-append
851 "patch-cargo-checksums: generate-checksums for "
853 (generate-checksums dir)))
854 (find-files "third_party/rust" ".cargo-checksum.json")))
856 (add-before 'configure 'augment-CPLUS_INCLUDE_PATH
857 (lambda* (#:key build inputs #:allow-other-keys)
858 ;; Here, we add additional entries to CPLUS_INCLUDE_PATH, to work
859 ;; around a problem that otherwise occurs when attempting to
860 ;; build Stylo, which requires Rust and Clang. Without these
861 ;; additional entries, errors occur during the build indicating
862 ;; that the <cstddef> and "c++config.h" headers cannot be found.
863 ;; Note that the 'build' keyword argument contains the GNU
864 ;; triplet, e.g. "x86_64-unknown-linux-gnu".
865 (let ((gcc (assoc-ref inputs "gcc")))
866 (setenv "CPLUS_INCLUDE_PATH"
867 (string-append gcc "/include/c++" ":"
868 gcc "/include/c++/" build)))
871 ;; configure does not work followed by both "SHELL=..." and
872 ;; "CONFIG_SHELL=..."; set environment variables instead
873 (lambda* (#:key outputs configure-flags #:allow-other-keys)
874 (let* ((out (assoc-ref outputs "out"))
875 (bash (which "bash"))
876 (abs-srcdir (getcwd))
877 (srcdir (string-append "../" (basename abs-srcdir)))
878 (flags `(,(string-append "--prefix=" out)
879 ,(string-append "--with-l10n-base="
882 (setenv "SHELL" bash)
883 (setenv "CONFIG_SHELL" bash)
884 (setenv "AUTOCONF" (which "autoconf")) ; must be autoconf-2.13
885 (setenv "CC" "gcc") ; apparently needed when Stylo is enabled
888 (format #t "build directory: ~s~%" (getcwd))
889 (format #t "configure flags: ~s~%" flags)
891 (string-append srcdir "/configure")
893 (add-before 'configure 'install-desktop-entry
894 (lambda* (#:key outputs #:allow-other-keys)
895 ;; Install the '.desktop' file.
896 (let* ((desktop-file "taskcluster/docker/icecat-snap/icecat.desktop")
897 (out (assoc-ref outputs "out"))
898 (applications (string-append out "/share/applications")))
899 (substitute* desktop-file
900 (("^Exec=icecat") (string-append "Exec=" out "/bin/icecat"))
901 (("IceCat") "GNU IceCat")
902 (("Icon=.*") "Icon=icecat\n")
903 (("NewWindow") "new-window")
904 (("NewPrivateWindow") "new-private-window"))
905 (install-file desktop-file applications)
907 (add-after 'install-desktop-entry 'install-icons
908 (lambda* (#:key outputs #:allow-other-keys)
909 (let ((out (assoc-ref outputs "out")))
910 (with-directory-excursion "browser/branding/official"
913 (let* ((size (string-filter char-numeric? file))
914 (icons (string-append out "/share/icons/hicolor/"
915 size "x" size "/apps")))
917 (copy-file file (string-append icons "/icecat.png"))))
918 '("default16.png" "default22.png" "default24.png"
919 "default32.png" "default48.png" "content/icon64.png"
920 "mozicon128.png" "default256.png"))
922 ;; This fixes the file chooser crash that happens with GTK 3.
923 (add-after 'install 'wrap-program
924 (lambda* (#:key inputs outputs #:allow-other-keys)
925 (let* ((out (assoc-ref outputs "out"))
926 (lib (string-append out "/lib"))
927 (gtk (assoc-ref inputs "gtk+"))
928 (gtk-share (string-append gtk "/share")))
929 (wrap-program (car (find-files lib "^icecat$"))
930 `("XDG_DATA_DIRS" ":" prefix (,gtk-share)))
932 (home-page "https://www.gnu.org/software/gnuzilla/")
933 (synopsis "Entirely free browser derived from Mozilla Firefox")
935 "IceCat is the GNU version of the Firefox browser. It is entirely free
936 software, which does not recommend non-free plugins and addons. It also
937 features built-in privacy-protecting features.")
938 (license license:mpl2.0) ;and others, see toolkit/content/license.html
940 `((ftp-directory . "/gnu/gnuzilla")
941 (cpe-name . "firefox_esr")
942 (cpe-version . ,(first (string-split version #\-)))))))
944 (define-public conkeror
945 ;; The Conkeror web browser relied on XULRunner, which IceCat > 50 no longer
946 ;; provides. See <http://conkeror.org> for the original web page.
947 (deprecated-package "conkeror" icecat))