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
@ -393,33 +395,38 @@
the official icon and the name \"firefox\".") 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
(name "firefox-wayland") (inherit firefox)
(arguments (name "firefox-wayland")
(substitute-keyword-arguments (package-arguments firefox) (native-inputs '())
((#:configure-flags flags) (inputs
`(append (list "--enable-default-toolkit=cairo-gtk3-wayland") `(("bash" ,bash-minimal)
(delete "--enable-default-toolkit=cairo-gtk3" ,flags))) ("firefox" ,firefox)))
;; We need to set the MOZ_ENABLE_WAYLAND env variable. (build-system trivial-build-system)
((#:phases phases) (arguments
`(modify-phases ,phases '(#:modules ((guix build utils))
(replace 'wrap-program #:builder
(lambda* (#:key inputs outputs #:allow-other-keys) (begin
(let* ((out (assoc-ref outputs "out")) (use-modules (guix build utils))
(lib (string-append out "/lib")) (let* ((bash (assoc-ref %build-inputs "bash"))
(ld-libs (map (lambda (x) (firefox (assoc-ref %build-inputs "firefox"))
(string-append (assoc-ref inputs x) (out (assoc-ref %outputs "out"))
"/lib")) (exe (string-append out "/bin/firefox")))
'("pulseaudio" "mesa" (mkdir-p (dirname exe))
;; For the integration of native notifications
"libnotify"))) (call-with-output-file exe
(gtk-share (string-append (assoc-ref inputs "gtk+") (lambda (port)
"/share"))) (format port "#!~a
(wrap-program (car (find-files lib "^firefox$")) MOZ_ENABLE_WAYLAND=1 exec ~a $@"
`("LD_LIBRARY_PATH" prefix ,ld-libs) (string-append bash "/bin/bash")
`("XDG_DATA_DIRS" prefix (,gtk-share)) (string-append firefox "/bin/firefox"))))
`("MOZ_ENABLE_WAYLAND" = ("1")) (chmod exe #o555)
`("MOZ_LEGACY_PROFILES" = ("1"))
`("MOZ_ALLOW_DOWNGRADE" = ("1"))) ;; Provide the manual and .desktop file.
#t))))))))) (copy-recursively (string-append firefox "/share")
(string-append out "/share"))
(substitute* (string-append
out "/share/applications/firefox.desktop")
((firefox) out))
#t))))))