From d7731c3142516cd6cc568d8deed316ff9c1bacbd Mon Sep 17 00:00:00 2001 From: Andreas Rammhold Date: Sun, 3 Feb 2019 11:34:39 +0100 Subject: [PATCH 1/2] firefoxPackages: enable support for wayland This adds support for building firefox with the gtk wayland backend. It should work on all the flavors that use >=gtk3. Using the wayland still allows using the X11 backend. --- pkgs/applications/networking/browsers/firefox/common.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/applications/networking/browsers/firefox/common.nix b/pkgs/applications/networking/browsers/firefox/common.nix index 2ef05a8f8d4b..1219f3bb895e 100644 --- a/pkgs/applications/networking/browsers/firefox/common.nix +++ b/pkgs/applications/networking/browsers/firefox/common.nix @@ -22,6 +22,7 @@ , pulseaudioSupport ? stdenv.isLinux, libpulseaudio , ffmpegSupport ? true , gtk3Support ? true, gtk2, gtk3, wrapGAppsHook +, waylandSupport ? true, libxkbcommon , gssSupport ? true, kerberos ## privacy-related options @@ -74,7 +75,7 @@ let flag = tf: x: [(if tf then "--enable-${x}" else "--disable-${x}")]; default-toolkit = if stdenv.isDarwin then "cairo-cocoa" - else "cairo-gtk${if gtk3Support then "3" else "2"}"; + else "cairo-gtk${if gtk3Support then "3${lib.optionalString waylandSupport "-wayland"}" else "2"}"; binaryName = if isIceCatLike then "icecat" else "firefox"; binaryNameCapitalized = lib.toUpper (lib.substring 0 1 binaryName) + lib.substring 1 (-1) binaryName; @@ -124,6 +125,7 @@ stdenv.mkDerivation rec { ++ lib.optional pulseaudioSupport libpulseaudio # only headers are needed ++ lib.optional gtk3Support gtk3 ++ lib.optional gssSupport kerberos + ++ lib.optional waylandSupport libxkbcommon ++ lib.optionals stdenv.isDarwin [ CoreMedia ExceptionHandling Kerberos AVFoundation MediaToolbox CoreLocation Foundation libobjc AddressBook cups ]; From 7eaef48e5a2eaf9be0d6ce961fdb45e81b150dac Mon Sep 17 00:00:00 2001 From: Andreas Rammhold Date: Sun, 3 Feb 2019 12:06:11 +0100 Subject: [PATCH 2/2] wrapFirefox: support GDK_BACKEND=wayland The firefox wrapper now supports setting the GDK_BACKEND to wayland which is useful in cases where firefox would be started from within an X-Application inside of wayland. GTK/GDK would otherwise default to the X11 backend in those situations. The intention is that people that are using wayland primarily pull in the new `firefox-wayland` top-level attribute into their environments instead of just `firefox`. Firefox will then always be started with the correct rendering backend. --- .../applications/networking/browsers/firefox/wrapper.nix | 9 +++++++-- pkgs/top-level/all-packages.nix | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pkgs/applications/networking/browsers/firefox/wrapper.nix b/pkgs/applications/networking/browsers/firefox/wrapper.nix index 1c214230e4ed..bc3a1ed844a4 100644 --- a/pkgs/applications/networking/browsers/firefox/wrapper.nix +++ b/pkgs/applications/networking/browsers/firefox/wrapper.nix @@ -26,8 +26,11 @@ let , icon ? browserName , extraPlugins ? [] , extraNativeMessagingHosts ? [] + , gdkWayland ? false }: + assert gdkWayland -> (browser ? gtk3); # Can only use the wayland backend if gtk3 is being used + let cfg = config.${browserName} or {}; enableAdobeFlash = cfg.enableAdobeFlash or false; @@ -86,7 +89,7 @@ let exec = "${browserName}${nameSuffix} %U"; inherit icon; comment = ""; - desktopName = "${desktopName}${nameSuffix}"; + desktopName = "${desktopName}${nameSuffix}${lib.optionalString gdkWayland " (Wayland)"}"; genericName = "Web Browser"; categories = "Application;Network;WebBrowser;"; mimeType = stdenv.lib.concatStringsSep ";" [ @@ -124,7 +127,9 @@ let --suffix PATH ':' "$out${browser.execdir or "/bin"}" \ --set MOZ_APP_LAUNCHER "${browserName}${nameSuffix}" \ --set MOZ_SYSTEM_DIR "$out/lib/mozilla" \ - ${lib.optionalString (browser ? gtk3) + ${lib.optionalString gdkWayland '' + --set GDK_BACKEND "wayland" \ + ''}${lib.optionalString (browser ? gtk3) ''--prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH" \ --suffix XDG_DATA_DIRS : '${gnome3.defaultIconTheme}/share' '' diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index adf7e603b231..57b82fc1cb47 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -17164,6 +17164,7 @@ with pkgs; icecat-unwrapped = firefoxPackages.icecat; firefox = wrapFirefox firefox-unwrapped { }; + firefox-wayland = wrapFirefox firefox-unwrapped { gdkWayland = true; }; firefox-esr-52 = wrapFirefox firefox-esr-52-unwrapped { }; firefox-esr-60 = wrapFirefox firefox-esr-60-unwrapped { }; firefox-esr = firefox-esr-60;