forked from jsoo1/guix-channel
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfirefox.scm
438 lines (422 loc) · 20.1 KB
/
firefox.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
(define-module (firefox)
#:use-module ((srfi srfi-1) #:hide (zip))
#:use-module (srfi srfi-26)
#:use-module (ice-9 match)
#:use-module (gnu packages)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix packages)
#:use-module (guix download)
#:use-module (guix hg-download)
#:use-module (guix gexp)
#:use-module (guix store)
#:use-module (guix monads)
#:use-module (guix utils)
#:use-module (guix build-system gnu)
#:use-module (guix build-system cargo)
#:use-module (gnu packages admin)
#:use-module (gnu packages audio)
#:use-module (gnu packages autotools)
#:use-module (gnu packages base)
#:use-module (gnu packages bash)
#:use-module ((gnu packages commencement) #:select (gcc-toolchain-8))
#:use-module (gnu packages crates-io)
#:use-module (gnu packages databases)
#:use-module (gnu packages glib)
#:use-module (gnu packages gtk)
#:use-module (gnu packages gnome)
#:use-module (gnu packages libcanberra)
#:use-module (gnu packages cups)
#:use-module (gnu packages kerberos)
#:use-module (gnu packages linux)
#:use-module (gnu packages node)
#:use-module (gnu packages perl)
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages compression)
#:use-module (gnu packages fontutils)
#:use-module (gnu packages libevent)
#:use-module ((gnu packages libreoffice) #:select (hunspell))
#:use-module (gnu packages image)
#:use-module (gnu packages libffi)
#:use-module (gnu packages pulseaudio)
#:use-module (gnu packages python)
#:use-module (gnu packages python-xyz)
#:use-module (gnu packages xorg)
#:use-module (gnu packages gl)
#:use-module (gnu packages assembly)
#:use-module (gnu packages rust)
#:use-module (gnu packages llvm)
#:use-module (gnu packages nss)
#:use-module (gnu packages icu4c)
#:use-module (gnu packages video)
#:use-module (gnu packages xiph)
#:use-module (gnu packages xdisorg)
#:use-module (gnu packages readline)
#:use-module (gnu packages sqlite)
#:use-module (gnu packages rust-apps)
#:use-module (rust-xyz)
#:use-module (rustfmt))
;; Like IceCat but using bundled media libraries
(define-public firefox
(package
(name "firefox")
(version "60.9.0esr")
(source
(origin
(method url-fetch)
(uri
(string-append
"https://ftp.mozilla.org/pub/firefox/releases/"
version "/source/"
"firefox-" version ".source.tar.xz"))
(sha256
(base32
"0gy5x2rnnbkqmjd9sq93s3q5na9nkba68xwpizild7k6qn63qicz"))))
(build-system gnu-build-system)
(inputs
`(("alsa-lib" ,alsa-lib)
("bzip2" ,bzip2)
("cups" ,cups)
("dbus-glib" ,dbus-glib)
("gdk-pixbuf" ,gdk-pixbuf)
("glib" ,glib)
("gtk+" ,gtk+)
("gtk+-2" ,gtk+-2)
("graphite2" ,graphite2)
("pango" ,pango)
("freetype" ,freetype)
("harfbuzz" ,harfbuzz)
("hunspell" ,hunspell)
("libcanberra" ,libcanberra)
("libgnome" ,libgnome)
("libjpeg-turbo" ,libjpeg-turbo)
("libogg" ,libogg)
;; ("libtheora" ,libtheora) ; wants theora-1.2, not yet released
;; vorbis unused??
("libvorbis" ,libvorbis)
("libxft" ,libxft)
("libevent" ,libevent)
("libxinerama" ,libxinerama)
("libxscrnsaver" ,libxscrnsaver)
("libxcomposite" ,libxcomposite)
("libxt" ,libxt)
("libffi" ,libffi)
("ffmpeg" ,ffmpeg)
("libvpx" ,libvpx-1.7)
("icu4c" ,icu4c)
("pixman" ,pixman)
("pulseaudio" ,pulseaudio)
("mesa" ,mesa)
("mit-krb5" ,mit-krb5)
;; See <https://bugs.gnu.org/32833>
;; and related comments in the 'remove-bundled-libraries' phase.
;; UNBUNDLE-ME! ("nspr" ,nspr)
;; UNBUNDLE-ME! ("nss" ,nss)
("node" ,node)
("sqlite" ,sqlite)
("startup-notification" ,startup-notification)
("unzip" ,unzip)
("zip" ,zip)
("zlib" ,zlib)))
(native-inputs
;; The following patches are specific to the Guix packaging of Firefox,
;; and therefore we prefer to leave them out of 'source', which should be
;; a tarball suitable for compilation on any system that Firefox supports.
;; (Bug fixes and security fixes, however, should go in 'source').
;; They are commented out because they fail
`(("firefox-avoid-bundled-libraries.patch"
"./icecat-avoid-bundled-libraries.patch")
("firefox-use-system-graphite2+harfbuzz.patch"
"./icecat-use-system-graphite2+harfbuzz.patch")
("firef0x-use-system-media-libs.patch"
"./icecat-use-system-media-libs.patch")
("patch" ,(canonical-package patch))
("autoconf" ,autoconf-2.13)
("rust" ,rust-1.35)
("rust-cbindgen" ,rust-cbindgen)
("rustfmt" ,rustfmt)
("cargo" ,rust-1.35 "cargo")
("llvm" ,llvm-3.9.1)
("clang" ,clang)
("gcc-toolchain" ,gcc-toolchain-8)
("perl" ,perl)
("python3" ,python-3)
("python" ,python-2) ; Python 3 not supported
("python2-pysqlite" ,python2-pysqlite)
("nasm" ,nasm)
("yasm" ,yasm)
("pkg-config" ,pkg-config)
("which" ,which)))
(arguments
`(#:tests? #f ; no check target
#:out-of-source? #t ; must be built outside of the source directory
;; XXX: There are RUNPATH issues such as
;; $prefix/lib/firefox-89.0/plugin-container NEEDing libmozalloc.so,
;; which is not in its RUNPATH, but they appear to be harmless in
;; practice somehow. See <http://hydra.gnu.org/build/378133>.
#:validate-runpath? #f
#:configure-flags `("--enable-default-toolkit=cairo-gtk3"
"--with-distribution-id=org.gnu"
"--enable-startup-notification"
"--enable-pulseaudio"
"--disable-tests"
"--disable-updater"
"--disable-crashreporter"
"--disable-maintenance-service"
"--disable-eme"
"--disable-gconf"
;; Building with debugging symbols takes ~5GiB, so
;; disable it.
"--disable-debug"
"--disable-debug-symbols"
;; Clang is needed to build Stylo, Mozilla's new
;; CSS engine. We must specify the clang paths
;; manually, because otherwise the Mozilla build
;; system looks in the directories returned by
;; llvm-config --bindir and llvm-config --libdir,
;; which return paths in the llvm package where
;; clang is not found.
,(string-append "--with-clang-path="
(assoc-ref %build-inputs "clang")
"/bin/clang")
,(string-append "--with-libclang-path="
(assoc-ref %build-inputs "clang")
"/lib")
;; Hack to work around missing
;; "unofficial" branding in icecat.
"--enable-official-branding"
;; Avoid bundled libraries.
"--with-system-zlib"
"--with-system-bz2"
"--with-system-jpeg" ; must be libjpeg-turbo
"--with-system-libevent"
"--with-system-ogg"
"--with-system-vorbis"
;; "--with-system-theora" ; wants theora-1.2, not yet released
"--with-system-libvpx"
"--with-system-icu"
;; See <https://bugs.gnu.org/32833>
;; and related comments in the
;; 'remove-bundled-libraries' phase below.
;; UNBUNDLE-ME! "--with-system-nspr"
;; UNBUNDLE-ME! "--with-system-nss"
"--with-system-harfbuzz"
"--with-system-graphite2"
"--enable-system-pixman"
"--enable-system-ffi"
"--enable-system-hunspell"
"--enable-system-sqlite"
;; Fails with "--with-system-png won't work because
;; the system's libpng doesn't have APNG support".
;; According to
;; http://sourceforge.net/projects/libpng-apng/ ,
;; "the Animated Portable Network Graphics (APNG)
;; is an unofficial extension of the Portable
;; Network Graphics (PNG) format";
;; we probably do not wish to support it.
;; "--with-system-png"
)
#:imported-modules ,%cargo-utils-modules ;for `generate-checksums'
#:modules ((ice-9 ftw)
(ice-9 rdelim)
(ice-9 match)
,@%gnu-build-system-modules)
#:phases
(modify-phases %standard-phases
(add-after 'unpack 'apply-guix-specific-patches
(lambda* (#:key inputs native-inputs #:allow-other-keys)
(let ((patch (string-append (assoc-ref (or native-inputs inputs)
"patch")
"/bin/patch")))
(for-each (match-lambda
((label . file)
(when (and (string-prefix? "firefox-" label)
(string-suffix? ".patch" label))
(format #t "applying '~a'...~%" file)
(invoke patch "--force" "--no-backup-if-mismatch"
"-p1" "--input" file))))
(or native-inputs inputs)))
#t))
(add-after 'apply-guix-specific-patches 'remove-bundled-libraries
(lambda _
;; Remove bundled libraries that we don't use, since they may
;; contain unpatched security flaws, they waste disk space and
;; memory, and may cause confusion.
(for-each (lambda (file)
(format #t "deleting '~a'...~%" file)
(delete-file-recursively file))
'(;; FIXME: Removing the bundled icu breaks configure.
;; * The bundled icu headers are used in some places.
;; * The version number is taken from the bundled copy.
;;"intl/icu"
;;
;; FIXME: A script from the bundled nspr is used.
;;"nsprpub"
;;
;; FIXME: With the update to IceCat 60, using system NSS
;; broke certificate validation. See
;; <https://bugs.gnu.org/32833>. For now, we use
;; the bundled NSPR and NSS. TODO: Investigate,
;; and try to unbundle these libraries again.
;; UNBUNDLE-ME! "security/nss"
;;
;; TODO: Use more system media libraries. See:
;; <https://bugzilla.mozilla.org/show_bug.cgi?id=517422>
;; * libtheora: esr60 wants v1.2, not yet released.
;; * soundtouch: avoiding the bundled library would
;; result in some loss of functionality. There's
;; also an issue with exception handling
;; configuration. It seems that this is needed in
;; some moz.build:
;; DEFINES['ST_NO_EXCEPTION_HANDLING'] = 1
;; * libopus
;; * speex
;;
"modules/freetype2"
"modules/zlib"
"modules/libbz2"
"ipc/chromium/src/third_party/libevent"
"media/libjpeg"
"media/libvpx"
"media/libogg"
"media/libvorbis"
;; "media/libtheora" ; wants theora-1.2, not yet released
"media/libtremor"
"gfx/harfbuzz"
"gfx/graphite2"
"js/src/ctypes/libffi"
"db/sqlite3"))
#t))
(add-after 'remove-bundled-libraries 'link-libxul-with-libraries
(lambda _
;; libxul.so dynamically opens libraries, so here we explicitly
;; link them into libxul.so instead.
;;
;; TODO: It might be preferable to patch in absolute file names in
;; calls to dlopen or PR_LoadLibrary, but that didn't seem to
;; work. More investigation is needed.
(substitute* "toolkit/library/moz.build"
(("^# This library needs to be last" all)
(string-append "OS_LIBS += [
'GL', 'gnome-2', 'canberra', 'Xss', 'cups', 'gssapi_krb5',
'avcodec', 'avutil', 'pulse' ]\n\n"
all)))
#t))
(replace 'bootstrap
(lambda _
(invoke "sh" "-c" "autoconf old-configure.in > old-configure")
;; 'configure' must be newer than 'old-configure.in', or else the
;; build system will raise an alarm and abort.
(invoke "touch" "configure")))
(add-after 'patch-source-shebangs 'patch-cargo-checksums
(lambda _
(use-modules (guix build cargo-utils))
(let ((null-hash "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")
;; I think this is copied from cargo-build-system.
;; It is awaiting a move to (guix build cargo-utils)
(generate-all-checksums
(lambda* (d #:optional f)
(for-each
(lambda (filename)
(delete-file filename)
(let ((dir (dirname filename)))
(display (string-append
"patch-cargo-checksums: generate-checksums for "
dir "\n"))
(generate-checksums dir)))
(find-files d f)))))
;; Remove pinned third party crates
(substitute* '("Cargo.lock" "servo/Cargo.lock")
(("(\"checksum .* = )\".*\"" all name)
(string-append name "\"" null-hash "\"")))
;; Generate checksums to refer to guix packages
(generate-all-checksums "third_party/rust" ".cargo-checksum.json"))
#t))
(add-before 'configure 'augment-CPLUS_INCLUDE_PATH
(lambda* (#:key build inputs #:allow-other-keys)
;; Here, we add additional entries to CPLUS_INCLUDE_PATH, to work
;; around a problem that otherwise occurs when attempting to
;; build Stylo, which requires Rust and Clang. Without these
;; additional entries, errors occur during the build indicating
;; that the <cstddef> and "c++config.h" headers cannot be found.
;; Note that the 'build' keyword argument contains the GNU
;; triplet, e.g. "x86_64-unknown-linux-gnu".
(let ((gcc (assoc-ref inputs "gcc-toolchain")))
(setenv "CPLUS_INCLUDE_PATH"
(string-append gcc "/include/c++" ":"
gcc "/include/c++/" build ":"
(getenv "CPLUS_INCLUDE_PATH"))))
#t))
(replace 'configure
;; configure does not work followed by both "SHELL=..." and
;; "CONFIG_SHELL=..."; set environment variables instead
(lambda* (#:key outputs configure-flags #:allow-other-keys)
(let* ((out (assoc-ref outputs "out"))
(bash (which "bash"))
(abs-srcdir (getcwd))
(srcdir (string-append "../" (basename abs-srcdir)))
(flags `(,(string-append "--prefix=" out)
;; Doesn't exist anymore
;; ,(string-append "--with-l10n-base="
;; abs-srcdir "/l10n")
,@configure-flags)))
(setenv "SHELL" bash)
(setenv "CONFIG_SHELL" bash)
(setenv "AUTOCONF" (which "autoconf")) ; must be autoconf-2.13
(setenv "CC" "gcc") ; apparently needed when Stylo is enabled
(mkdir "../build")
(chdir "../build")
;; ??? Not sure why/how to fix the rust build steps
(setenv "CARGO_HOME" (string-append (getcwd) "/.cargo"))
(mkdir-p ".cargo")
(format #t "build directory: ~s~%" (getcwd))
(format #t "configure flags: ~s~%" flags)
(apply invoke bash
(string-append srcdir "/configure")
flags))))
(add-before 'configure 'install-desktop-entry
(lambda* (#:key outputs #:allow-other-keys)
;; Install the '.desktop' file.
(let* ((desktop-file "taskcluster/docker/firefox-snap/firefox.desktop")
(out (assoc-ref outputs "out"))
(applications (string-append out "/share/applications")))
(substitute* desktop-file
(("^Exec=firefox") (string-append "Exec=" out "/bin/firefox"))
(("NewWindow") "new-window")
(("NewPrivateWindow") "new-private-window"))
(install-file desktop-file applications)
#t)))
(add-after 'configure 'install-icons
(lambda* (#:key outputs #:allow-other-keys)
(let ((out (assoc-ref outputs "out")))
(with-directory-excursion "browser/branding/official"
(for-each
(lambda (file)
(let* ((size (string-filter char-numeric? file))
(icons (string-append out "/share/icons/hicolor/"
size "x" size "/apps")))
(mkdir-p icons)
(copy-file file (string-append icons "/firefox.png"))))
'("default16.png" "default22.png" "default24.png"
"default32.png" "default48.png" "content/icon64.png"
"mozicon128.png" "default256.png"))
#t))))
;; This fixes the file chooser crash that happens with GTK 3.
(add-after 'install 'wrap-program
(lambda* (#:key inputs outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out"))
(lib (string-append out "/lib"))
(gtk (assoc-ref inputs "gtk+"))
(gtk-share (string-append gtk "/share")))
(wrap-program (car (find-files lib "^firefox$"))
`("XDG_DATA_DIRS" ":" prefix (,gtk-share)))
#t))))))
(home-page "https://mozilla.org/firefox")
(synopsis "Firefox")
(description
"Firefox")
(license license:mpl2.0) ;and others, see toolkit/content/license.html
(properties
`(;; not sure this is needed
;; (ftp-directory . "/gnu/gnuzilla")
(cpe-name . "firefox")
(cpe-version . ,(first (string-split version #\-)))))))