From c2bc68ce353fec2efb3d00a881937ab6ac9347e1 Mon Sep 17 00:00:00 2001 From: pineapples Date: Thu, 29 Apr 2021 15:55:31 +0200 Subject: 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 --- nongnu/packages/mozilla.scm | 69 +++++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 31 deletions(-) diff --git a/nongnu/packages/mozilla.scm b/nongnu/packages/mozilla.scm index 1474173..d0f5ea6 100644 --- a/nongnu/packages/mozilla.scm +++ b/nongnu/packages/mozilla.scm @@ -17,6 +17,7 @@ ;;; Copyright (C) 2019, 2020 Adrian Malacoda ;;; Copyright © 2020 Jonathan Brielmaier ;;; Copyright © 2020 Zhu Zihao +;;; Copyright © 2021 pineapples ;;; ;;; This file is not part of GNU Guix. ;;; @@ -36,6 +37,7 @@ (define-module (nongnu packages mozilla) #:use-module (guix build-system gnu) #:use-module (guix build-system cargo) + #:use-module (guix build-system trivial) #:use-module (guix download) #:use-module ((guix licenses) #:prefix license:) #:use-module (guix packages) @@ -45,6 +47,7 @@ #:use-module (gnu packages assembly) #:use-module (gnu packages autotools) #:use-module (gnu packages base) + #:use-module (gnu packages bash) #:use-module (gnu packages compression) #:use-module (gnu packages crates-io) #:use-module (gnu packages cups) @@ -104,7 +107,6 @@ "--with-system-icu" "--enable-system-ffi" "--enable-system-pixman" - "--enable-default-toolkit=cairo-gtk3" "--enable-jemalloc" ;; see https://bugs.gnu.org/32833 @@ -393,33 +395,38 @@ the official icon and the name \"firefox\".") (license license:mpl2.0))) -(define-public firefox/wayland - (package/inherit firefox - (name "firefox-wayland") - (arguments - (substitute-keyword-arguments (package-arguments firefox) - ((#:configure-flags flags) - `(append (list "--enable-default-toolkit=cairo-gtk3-wayland") - (delete "--enable-default-toolkit=cairo-gtk3" ,flags))) - ;; We need to set the MOZ_ENABLE_WAYLAND env variable. - ((#:phases phases) - `(modify-phases ,phases - (replace 'wrap-program - (lambda* (#:key inputs outputs #:allow-other-keys) - (let* ((out (assoc-ref outputs "out")) - (lib (string-append out "/lib")) - (ld-libs (map (lambda (x) - (string-append (assoc-ref inputs x) - "/lib")) - '("pulseaudio" "mesa" - ;; For the integration of native notifications - "libnotify"))) - (gtk-share (string-append (assoc-ref inputs "gtk+") - "/share"))) - (wrap-program (car (find-files lib "^firefox$")) - `("LD_LIBRARY_PATH" prefix ,ld-libs) - `("XDG_DATA_DIRS" prefix (,gtk-share)) - `("MOZ_ENABLE_WAYLAND" = ("1")) - `("MOZ_LEGACY_PROFILES" = ("1")) - `("MOZ_ALLOW_DOWNGRADE" = ("1"))) - #t))))))))) + (define-public firefox/wayland + (package + (inherit firefox) + (name "firefox-wayland") + (native-inputs '()) + (inputs + `(("bash" ,bash-minimal) + ("firefox" ,firefox))) + (build-system trivial-build-system) + (arguments + '(#:modules ((guix build utils)) + #:builder + (begin + (use-modules (guix build utils)) + (let* ((bash (assoc-ref %build-inputs "bash")) + (firefox (assoc-ref %build-inputs "firefox")) + (out (assoc-ref %outputs "out")) + (exe (string-append out "/bin/firefox"))) + (mkdir-p (dirname exe)) + + (call-with-output-file exe + (lambda (port) + (format port "#!~a + MOZ_ENABLE_WAYLAND=1 exec ~a $@" + (string-append bash "/bin/bash") + (string-append firefox "/bin/firefox")))) + (chmod exe #o555) + + ;; Provide the manual and .desktop file. + (copy-recursively (string-append firefox "/share") + (string-append out "/share")) + (substitute* (string-append + out "/share/applications/firefox.desktop") + ((firefox) out)) + #t)))))) -- cgit v1.2.3