nongnu: firefox-wayland: Rewrite to avoid extra build.

* nongnu/packages/mozilla.scm (firefox) [arguments]: use the default value of
`--enable-default-toolkit='. The Wayland backend of Firefox is no longer
considered experimental and support for it is included in the official binaries.
* nongnu/packages/mozilla.scm (firefox-wayland): Re-write the package
definition, based upon `ungoogled-chromium-wayland' to avoid re-compiling
Firefox in cases when there is a substitute for `firefox'.

Signed-off-by: Jonathan Brielmaier <jonathan.brielmaier@web.de>
This commit is contained in:
pineapples 2021-04-29 15:55:31 +02:00 committed by Jonathan Brielmaier
parent df3f4242bf
commit c2bc68ce35
No known key found for this signature in database
GPG key ID: ECFC83988B4E4B9F

View file

@ -17,6 +17,7 @@
;;; Copyright (C) 2019, 2020 Adrian Malacoda <malacoda@monarch-pass.net> ;;; Copyright (C) 2019, 2020 Adrian Malacoda <malacoda@monarch-pass.net>
;;; Copyright © 2020 Jonathan Brielmaier <jonathan.brielmaier@web.de> ;;; Copyright © 2020 Jonathan Brielmaier <jonathan.brielmaier@web.de>
;;; Copyright © 2020 Zhu Zihao <all_but_last@163.com> ;;; Copyright © 2020 Zhu Zihao <all_but_last@163.com>
;;; Copyright © 2021 pineapples <guixuser6392@protonmail.com>
;;; ;;;
;;; This file is not part of GNU Guix. ;;; This file is not part of GNU Guix.
;;; ;;;
@ -36,6 +37,7 @@
(define-module (nongnu packages mozilla) (define-module (nongnu packages mozilla)
#:use-module (guix build-system gnu) #:use-module (guix build-system gnu)
#:use-module (guix build-system cargo) #:use-module (guix build-system cargo)
#:use-module (guix build-system trivial)
#:use-module (guix download) #:use-module (guix download)
#:use-module ((guix licenses) #:prefix license:) #:use-module ((guix licenses) #:prefix license:)
#:use-module (guix packages) #:use-module (guix packages)
@ -45,6 +47,7 @@
#:use-module (gnu packages assembly) #:use-module (gnu packages assembly)
#:use-module (gnu packages autotools) #:use-module (gnu packages autotools)
#:use-module (gnu packages base) #:use-module (gnu packages base)
#:use-module (gnu packages bash)
#:use-module (gnu packages compression) #:use-module (gnu packages compression)
#:use-module (gnu packages crates-io) #:use-module (gnu packages crates-io)
#:use-module (gnu packages cups) #:use-module (gnu packages cups)
@ -104,7 +107,6 @@
"--with-system-icu" "--with-system-icu"
"--enable-system-ffi" "--enable-system-ffi"
"--enable-system-pixman" "--enable-system-pixman"
"--enable-default-toolkit=cairo-gtk3"
"--enable-jemalloc" "--enable-jemalloc"
;; see https://bugs.gnu.org/32833 ;; see https://bugs.gnu.org/32833
@ -394,32 +396,37 @@ the official icon and the name \"firefox\".")
(license license:mpl2.0))) (license license:mpl2.0)))
(define-public firefox/wayland (define-public firefox/wayland
(package/inherit firefox (package
(inherit firefox)
(name "firefox-wayland") (name "firefox-wayland")
(native-inputs '())
(inputs
`(("bash" ,bash-minimal)
("firefox" ,firefox)))
(build-system trivial-build-system)
(arguments (arguments
(substitute-keyword-arguments (package-arguments firefox) '(#:modules ((guix build utils))
((#:configure-flags flags) #:builder
`(append (list "--enable-default-toolkit=cairo-gtk3-wayland") (begin
(delete "--enable-default-toolkit=cairo-gtk3" ,flags))) (use-modules (guix build utils))
;; We need to set the MOZ_ENABLE_WAYLAND env variable. (let* ((bash (assoc-ref %build-inputs "bash"))
((#:phases phases) (firefox (assoc-ref %build-inputs "firefox"))
`(modify-phases ,phases (out (assoc-ref %outputs "out"))
(replace 'wrap-program (exe (string-append out "/bin/firefox")))
(lambda* (#:key inputs outputs #:allow-other-keys) (mkdir-p (dirname exe))
(let* ((out (assoc-ref outputs "out"))
(lib (string-append out "/lib")) (call-with-output-file exe
(ld-libs (map (lambda (x) (lambda (port)
(string-append (assoc-ref inputs x) (format port "#!~a
"/lib")) MOZ_ENABLE_WAYLAND=1 exec ~a $@"
'("pulseaudio" "mesa" (string-append bash "/bin/bash")
;; For the integration of native notifications (string-append firefox "/bin/firefox"))))
"libnotify"))) (chmod exe #o555)
(gtk-share (string-append (assoc-ref inputs "gtk+")
"/share"))) ;; Provide the manual and .desktop file.
(wrap-program (car (find-files lib "^firefox$")) (copy-recursively (string-append firefox "/share")
`("LD_LIBRARY_PATH" prefix ,ld-libs) (string-append out "/share"))
`("XDG_DATA_DIRS" prefix (,gtk-share)) (substitute* (string-append
`("MOZ_ENABLE_WAYLAND" = ("1")) out "/share/applications/firefox.desktop")
`("MOZ_LEGACY_PROFILES" = ("1")) ((firefox) out))
`("MOZ_ALLOW_DOWNGRADE" = ("1"))) #t))))))
#t)))))))))