Firefox: Difference between revisions

From NixOS Wiki
imported>Fadenb
→‎Wayland: Document what is needed to make Firefox screen sharing work with Wayland
Klinger (talk | contribs)
 
(36 intermediate revisions by 21 users not shown)
Line 1: Line 1:
[https://www.mozilla.org/firefox Firefox] is a graphical web browser developed by Mozilla.
<translate>
<!--T:1-->
[https://www.mozilla.org/firefox Firefox] is a graphical web browser developed by Mozilla. It can be used with a [[Firefox Sync Server]].
</translate>
<translate>
== Installation == <!--T:2-->
</translate>
<translate>
<!--T:3-->
Set <code>programs.firefox.enable</code> to true in your system or [[Home Manager]] configuration.
Keep in mind that the NixOS and Home Manager modules have different options, so choose accordingly.
</translate>
<translate>
== Firefox Variants == <!--T:4-->
</translate>
<translate>
<!--T:5-->
There are several Firefox variants that you can choose to install. To choose a variant, set <code>programs.firefox.package</code> accordingly.
</translate>
<translate>
<!--T:6-->
'''Note:''' The packages for the variants listed below are installed ''instead'' of the normal <code>firefox</code> package. Thus, you'll have to choose one among these options.
</translate>
<translate>
=== Variant: Official Binaries === <!--T:7-->
</translate>
<translate>
<!--T:8-->
Mozilla provides official pre-built Firefox binaries. This is the <code>firefox-bin</code> package and will be downloaded directly from the Mozilla servers.
</translate>
<translate>
=== Variant: ESR === <!--T:9-->
</translate>
<translate>
<!--T:10-->
<code>firefox-esr</code> is the '''E'''xtended '''S'''upport '''R'''elease of Firefox provided by Mozilla, which receives only security updates and a more relaxed cadence of feature implementation.
</translate>
<translate>
=== Variant: Nightly === <!--T:11-->
</translate>
<translate>
<!--T:12-->
Nightly builds are daily builds of Firefox from the central Mozilla repository.
</translate>
<translate>
==== Reproducible ==== <!--T:13-->
</translate>
<translate>
<!--T:14-->
This method uses flakes to pull in nightly versions of Firefox in a reproducible way, and is recommended for use. If you don't want to use flakes, check out the next section.


== Installation ==
<!--T:15-->
First, add the following inputs to your flake:
</translate>
<syntaxhighlight lang="nix">
inputs = {
  firefox.url = "github:nix-community/flake-firefox-nightly";
  firefox.inputs.nixpkgs.follows = "nixpkgs";
};
</syntaxhighlight>
<translate>
<!--T:16-->
Then, using the [[Flakes#Using_nix_flakes_with_NixOS|specialArgs]] attribute to pass flake inputs to external configuration files, add the nightly package to your system:
</translate>
<syntaxhighlight lang="nix">
{ pkgs, inputs, config, ... }:
{
  environment.systemPackages = [
    inputs.firefox.packages.${pkgs.system}.firefox-nightly-bin
  ];
}
</syntaxhighlight>
<translate>
<!--T:17-->
The downside of using this method is that you'll have to update the flake input before you can get a new nightly version, which also means that you might miss new builds since the flake lags behind the nightly release.
</translate>
<translate>
==== Non-reproducible (Impure) ==== <!--T:18-->
</translate>
<translate>
<!--T:19-->
Using this method is bad for reproducibility since it fetches resources from non-pinned URLs, but it also means you always get the latest nightly version when you build your system.
</translate>
<translate>
<!--T:20-->
{{tip|1=If you don't want to use flakes but you still want to reproducibly install Firefox nightly, you might want to use this method with [https://github.com/nmattia/niv niv].}}
</translate>
<translate>
<!--T:21-->
<syntaxhighlight lang="nix">
nixpkgs.overlays =
  let
    # Change this to a rev sha to pin
    moz-rev = "master";
    moz-url = builtins.fetchTarball { url = "https://github.com/mozilla/nixpkgs-mozilla/archive/${moz-rev}.tar.gz";};
    nightlyOverlay = (import "${moz-url}/firefox-overlay.nix");
  in [
    nightlyOverlay
  ];
programs.firefox.package = pkgs.latest.firefox-nightly-bin;
</syntaxhighlight>
</translate>
<translate>
<!--T:22-->
Once you've added the overlay, you'll need to pass the <code>--impure</code> option to nix commands. For example, in order to build and activate your configuration, you'll have to run:
</translate>
<syntaxHighlight lang="console">
$ nixos-rebuild switch --impure
</syntaxHighlight>
<translate>
== Customizing with [[Home Manager]] == <!--T:23-->
</translate>
<translate>
<!--T:24-->
Home manager allows more customization for firefox. Such as  extensions, search engines, bookmarks, [https://www.userchrome.org/ userChrome] and [https://kb.mozillazine.org/User.js_file user.js]. The example below shows a basic config defining Nix packages & options as a search engine.
</translate>
<translate>
<!--T:25-->
[https://nix-community.github.io/home-manager/options.xhtml More options are available on Home Manager's site]
</translate>
<syntaxhighlight lang="nix">
home-manager.users.username = {
  programs.firefox = {
    enable = true;
    profiles = {
      "user" = {
        id = 0;
        isDefault = true;


=== NixOS ===
        search.engines = {
          "Nix Packages" = {
            urls = [{
              template = "https://search.nixos.org/packages";
              params = [
                { name = "query"; value = "{searchTerms}"; }
              ];
            }];
            icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
            definedAliases = [ "@np" ];
          };
          "Nix Options" = {
            definedAliases = [ "@no" ];
            urls = [{
              template = "https://search.nixos.org/options";
              params = [
                { name = "query"; value = "{searchTerms}"; }
              ];
            }];
          };
        };
      };
    };
  };
</syntaxhighlight>
<translate>
== FAQ == <!--T:26-->
</translate>
<translate>
=== How do I use ALSA with Firefox instead of PulseAudio? === <!--T:27-->
</translate>
<syntaxhighlight lang="nix">
programs.firefox.package = (pkgs.wrapFirefox.override { libpulseaudio = pkgs.libpressureaudio; }) pkgs.firefox-unwrapped { };
</syntaxhighlight>
<translate>
== Tips == <!--T:28-->
</translate>
<translate>
<!--T:29-->
=== Enabling
[https://community.kde.org/Plasma/Browser_Integration#How_to_install Plasma Browser Integration] ===
</translate>
<translate>
<!--T:30-->
1. Add the following line to your <code>configuration.nix</code> (note that [[KDE#Installation|enabling Plasma]] automatically does this):
</translate>


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
environment.systemPackages = with pkgs; [ firefox ]
programs.firefox.nativeMessagingHosts.packages = [ pkgs.plasma5Packages.plasma-browser-integration ];
</syntaxhighlight>
</syntaxhighlight>
 
<translate>
=== Home Manager ===
<!--T:31-->
 
2. Install [https://addons.mozilla.org/en-US/firefox/addon/plasma-integration/ KDE's Firefox extension].
[[Home Manager]] provides options to manage {{PAGENAME}}. You can find them below the [https://rycee.gitlab.io/home-manager/options.html#opt-programs.firefox.enable the Configuration Option ''programs.firefox.enable'' entry in the Home Manager Manual].
</translate>
 
<translate>
=== Use KDE file picker === <!--T:32-->
</translate>
<translate>
<!--T:33-->
You must instruct Firefox to use the file picker offered by the XDG Desktop Portal framework. This setting can be found in Firefox's ''about:config'' as ''widget.use-xdg-desktop-portal.file-picker''. The value 1 means "always". To set it using NixOS, add to '<code>configuration.nix'</code>
</translate>
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
programs.firefox.enable = true;
  # Make Firefox use the KDE file picker.
  # Preferences source: https://wiki.archlinux.org/title/firefox#KDE_integration
  programs.firefox = {
    enable = true;
    preferences = {
      "widget.use-xdg-desktop-portal.file-picker" = 1;
    };
  };
</syntaxhighlight>
</syntaxhighlight>
 
<translate>
or
=== Use xinput2 === <!--T:34-->
 
</translate>
<translate>
<!--T:35-->
You can make Firefox use xinput2 by setting the <code>MOZ_USE_XINPUT2</code> environment variable. This improves touchscreen support and enables additional touchpad gestures. It also enables smooth scrolling as opposed to the stepped scrolling that Firefox has by default. To do this, put the following in your config:
</translate>
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
home.packages = with pkgs; [ firefox ]
environment.sessionVariables = {
  MOZ_USE_XINPUT2 = "1";
};
</syntaxhighlight>
</syntaxhighlight>
<translate>
== Troubleshooting== <!--T:36-->
</translate>
<translate>
=== If you can't start the browser because of a configuration error === <!--T:37-->


if you do not need the home-manager options
<!--T:38-->
For example:
</translate>
<syntaxhighlight lang="text">
firefox
1554035168269 Marionette FATAL XML parsing error: undefined entity
Location: chrome://browser/content/browser.xul
Line 2526, column 13:            <toolbarbutton id="tracking-protection-preferences-button"
JavaScript error: resource:///modules/aboutpages/AboutPrivateBrowsingHandler.jsm, line 28: TypeError: this.pageListener is undefined
</syntaxhighlight>
<translate>
<!--T:39-->
An easy way to get away from this is to start firefox with the <code>firefox -safe-mode</code> command. Then you can troubleshoot your actual problem or you can call your luck by calling the refresh option (a special button will appear when firefox starts in this mode). This will reset your configuration to a sane state and you will be usually able to start the browser again, but you will lose most of your customization.
</translate>
<translate>
=== <code>nativeMessagingHosts</code> doesn't work === <!--T:40-->
</translate>
<translate>
<!--T:41-->
Such as <code>enablePlasmaBrowserIntegration</code>, <code>enableGnomeExtensions</code>, and <code>enableBrowserpass</code>.


=== Non-NixOS ===
<!--T:42-->
[https://nixos.org/manual/nixpkgs/stable/#sec-declarative-package-management declarative package management on non-nixos]
They do not work with the <code>firefox-bin</code> derivation<ref>https://github.com/NixOS/nixpkgs/issues/47340#issuecomment-476368401</ref> or with <code>firefox</code> installed via <code>nix-env</code>
 
</translate>
==Other Editions==
<hr />
Nixpkgs also offers other variants of Firefox aside from the ones stated above. These may suit your needs more comfortably than vanilla Firefox.  
<references />
<translate>
=== Screen Sharing under Wayland === <!--T:43-->
</translate>
<translate>
<!--T:44-->
When using Firefox with Wayland, screen sharing options might be limited and require additional configuration (exact capabilities vary with different compositors).
</translate>
<translate>
<!--T:45-->
* add Pipewire support to Firefox:
</translate>
<translate>
<!--T:46-->
<syntaxhighlight lang="nix">
# when programs.firefox.enable == true
programs.firefox.wrapperConfig = {
  pipewireSupport = true;
};


'''Note:''' The packages for the variants listed below are installed ''instead'' of the normal <code>firefox</code> package and each other, which means that you'll have to choose one among these options.
<!--T:54-->
# or, alternatively


===Wayland===
<!--T:55-->
Users running a Wayland compositor (such as [[Sway]]) may want to use a Wayland-compatible build of Firefox. This can be achieved by replacing the <code>firefox</code> package with <code>firefox-wayland</code> instead.
environment.systemPackages = [
 
  # Replace this
====Screen Sharing====
  pkgs.firefox
When using Firefox with Wayland, screen sharing options are limited and require additional configuration. As of 2020-12-15, it is only possible to share a whole screen (rather than choosing which window to share).
   # With this
 
   (pkgs.wrapFirefox (pkgs.firefox-unwrapped.override { pipewireSupport = true;}) {})
* Use <code>firefox-wayland</code>, e.g.:<syntaxhighlight lang="nix">
];
# NixOS system wide firefox install
environment.systemPackages = with pkgs; [ firefox-wayland ]
 
# Home Manager when not using any additional firefox options
home.packages = with pkgs; [ firefox-wayland ]
 
# Home Manager programs.firefox style
programs.firefox = {
   enable = true;
   package = pkgs.wrapFirefox pkgs.firefox-unwrapped {
    forceWayland = true;
    extraPolicies = {
      ExtensionSettings = {};
    };
  };
};
</syntaxhighlight>
</syntaxhighlight>
* Enable [https://pipewire.org/ PipeWire]:<syntaxhighlight lang="nix">
</translate>
<translate>
<!--T:47-->
* Enable [https://pipewire.org/ PipeWire]
</translate>
<syntaxhighlight lang="nix">
services.pipewire.enable = true;
services.pipewire.enable = true;
</syntaxhighlight>
</syntaxhighlight>
* Enable [https://github.com/flatpak/xdg-desktop-portal/blob/master/README.md xdg desktop integration]:<syntaxhighlight lang="nix">
<translate>
<!--T:48-->
* Enable [https://github.com/flatpak/xdg-desktop-portal/blob/master/README.md xdg desktop integration]:
</translate>
<syntaxhighlight lang="nix">
xdg = {
xdg = {
   portal = {
   portal = {
Line 68: Line 293:
       xdg-desktop-portal-gtk
       xdg-desktop-portal-gtk
     ];
     ];
    gtkUsePortal = true;
   };
   };
};
};
</syntaxhighlight>
</syntaxhighlight>
* Set environment variables to hint Firefox to use Wayland features. E.g.:<syntaxhighlight lang="nix">
<translate>
<!--T:49-->
* Set environment variables to hint Firefox to use Wayland features. E.g.:
</translate>
<translate>
<!--T:50-->
<syntaxhighlight lang="nix">
# Classical NixOS setup
# Classical NixOS setup
environment.sessionVariables = {
environment.sessionVariables = {
  MOZ_ENABLE_WAYLAND = "1";
  # only needed for Sway
  XDG_CURRENT_DESKTOP = "sway"; # TODO: Do we need this in non-sway setups?
  XDG_CURRENT_DESKTOP = "sway";  
  XDG_SESSION_TYPE = "wayland";
};
};
 
</syntaxhighlight>
</translate>
<translate>
<!--T:51-->
<syntaxhighlight lang="nix">
# Home Manager setup
# Home Manager setup
home.sessionVariables = {
home.sessionVariables = {
   MOZ_ENABLE_WAYLAND = 1;
   # only needed for Sway
   XDG_CURRENT_DESKTOP = "sway"; # TODO: Do we need this in non-sway setups?
   XDG_CURRENT_DESKTOP = "sway";  
  XDG_SESSION_TYPE = "wayland";
};
};
</syntaxhighlight>
</syntaxhighlight>
* Ensure that the environment variables are correctly set for the user systemd units. E.g.:<syntaxhighlight lang="shell">
</translate>
<translate>
<!--T:52-->
* Ensure that the environment variables are correctly set for the user systemd units, e.g.
</translate>
<translate>
<!--T:53-->
# Sway users might achieve this by adding the following to their Sway config file
# Sway users might achieve this by adding the following to their Sway config file
# This ensures all user units started after the command (not those already running) set the variables
# This ensures all user units started after the command (not those already running) set the variables
</translate>
<syntaxhighlight lang="bash">
exec systemctl --user import-environment
exec systemctl --user import-environment
</syntaxhighlight>
</syntaxhighlight>
* Apply the patch from pull-request {{pull|106815}} to fix a screen sharing related regression{{Note|Remove this once the PR has been merged/backported to stable.}}
===Firefox ESR===
This is the '''E'''xtended '''S'''upport '''R'''elease of Firefox provided by Mozilla, this release receives only security updates and possesses a more relaxed cadence of feature implementation. You can install it by using the <code>firefox-esr</code> package.
===Mozilla Distributed Binaries===
Mozilla themselves provide official pre-built Firefox binaries. It is possible to install these packages through Nix by using the <code>-bin</code> suffix with the package. So you'd use <code>firefox-bin</code> instead of the normal package. This will download the binary from Mozilla's servers and install it on your system.
===Firefox nightly===
Nightly builds are daily builds of Firefox from the Mozilla-central repository
To use them
<syntaxhighlight lang="nix">
nixpkgs.overlays =
  let
    # Change this to a rev sha to pin
    moz-rev = "master";
    moz-url = builtins.fetchTarball { url = "https://github.com/mozilla/nixpkgs-mozilla/archive/${moz-rev}.tar.gz";};
    nightlyOverlay = (import "${moz-url}/firefox-overlay.nix");
  in [
    nightlyOverlay
  ];
environment.systemPackages = with pkgs; [ latest.firefox-nightly-bin ];
</syntaxhighlight>
== FAQ ==
=== How to run Firefox without pulseaudio and still get audio output? ===
Replace libpulseaudio by libpressureaudio, which uses apulse to emulate PulseAudio but uses ALSA directly. So, you don't need to install/enable pulse audio.
<syntaxhighlight lang="nix">
{ pkgs ? import <nixpkgs> {} }:
(pkgs.wrapFirefox.override {libpulseaudio = pkgs.libpressureaudio;}) pkgs.firefox-unwrapped {}
</syntaxhighlight>
and installing it with <code>nix-env -f firefox.nix -i</code>.
When using [[Home Manager]], add the following to your configuration:
<syntaxhighlight lang="nix">
programs.firefox.package = (pkgs.wrapFirefox.override { libpulseaudio = pkgs.libpressureaudio; }) pkgs.firefox-unwrapped { };
</syntaxhighlight>
=== I want Firefox, what is Nightly? ===
[https://www.mozilla.org/en-US/foundation/trademarks/faq/ Mozilla's trademarks] on Firefox disallows distributing unofficial builds using the Firefox trademark. This is why the Nix-built Firefox is named Nightly.
The official builds are available by [[FAQ#How_can_I_install_a_proprietary_or_unfree_package.3F|enabling unfree]] and installing <code>firefox-bin</code>.
=== Firefox ESR and Oracle JDK ===
Note: It is not clear whether this section is out of date, and whether any Firefox release in Nixpkgs allows to use Java. See https://github.com/NixOS/nixpkgs/issues/84909.
Firefox stops support of Java plugin. To use Java plugin you have to use special Firefox ESR, Extended Support Release.
Also, Oracle doesn't provide a nice way to automate Oracle JDK installation without accepting the license. See https://gist.github.com/danbst/30165b59996fb403068c74a95b108d6f for possible way to combine automated JDK and Firefox ESR download.
== Repo extensions ==
=== Enabling [https://community.kde.org/Plasma/Browser_Integration#How_to_install Plasma Browser Integration]  ===
1. Add following line to your configuration.nix:
<code>nixpkgs.config.firefox.enablePlasmaBrowserIntegration = true;</code>
If you're wondering where this part is coming from see [https://nixos.org/nixos/manual/#sec-customising-packages NixOS Manual:Customising Packages]
2. Install KDE's Firefox extension: [https://addons.mozilla.org/en-US/firefox/addon/plasma-integration/ Link]
== Troubleshooting==
===If you can't start the browser because of a configuration error.===
For example:
<syntaxhighlight>
firefox
1554035168269 Marionette FATAL Error de análisis XML: entidad indefinida
Ubicación: chrome://browser/content/browser.xul
Línea 2526, columna 13:            <toolbarbutton id="tracking-protection-preferences-button"
JavaScript error: resource:///modules/aboutpages/AboutPrivateBrowsingHandler.jsm, line 28: TypeError: this.pageListener is undefined
</syntaxhighlight>
An easy way to get away from this is to start firefox with the <syntaxhighlight>firefox -safe-mode </syntaxhighlight> command. Then you can troubleshoot your actual problem or you can call your luck by calling the refresh option (a special button will appear when firefox starts in this mode). This will reset your configuration to a sane state and you will be usually able to start the browser again, but you will lose most of your customization.
=== nativeMessagingHosts don't work ===
such as enablePlasmaBrowserIntegration, enableGnomeExtensions, and enableBrowserpass
They do not work with the firefox-bin derivation<ref>https://github.com/NixOS/nixpkgs/issues/47340#issuecomment-476368401</ref> or with firefox installed via nix-env
<hr />
<references />


[[Category:Configuration]]
[[Category:Cookbook]]
[[Category:Applications]]
[[Category:Web Browser]]

Latest revision as of 20:43, 26 September 2024

Firefox is a graphical web browser developed by Mozilla. It can be used with a Firefox Sync Server.

Installation

Set programs.firefox.enable to true in your system or Home Manager configuration. Keep in mind that the NixOS and Home Manager modules have different options, so choose accordingly.

Firefox Variants

There are several Firefox variants that you can choose to install. To choose a variant, set programs.firefox.package accordingly. Note: The packages for the variants listed below are installed instead of the normal firefox package. Thus, you'll have to choose one among these options.

Variant: Official Binaries

Mozilla provides official pre-built Firefox binaries. This is the firefox-bin package and will be downloaded directly from the Mozilla servers.

Variant: ESR

firefox-esr is the Extended Support Release of Firefox provided by Mozilla, which receives only security updates and a more relaxed cadence of feature implementation.

Variant: Nightly

Nightly builds are daily builds of Firefox from the central Mozilla repository.

Reproducible

This method uses flakes to pull in nightly versions of Firefox in a reproducible way, and is recommended for use. If you don't want to use flakes, check out the next section.

First, add the following inputs to your flake:

inputs = {
  firefox.url = "github:nix-community/flake-firefox-nightly";
  firefox.inputs.nixpkgs.follows = "nixpkgs";
};

Then, using the specialArgs attribute to pass flake inputs to external configuration files, add the nightly package to your system:

{ pkgs, inputs, config, ... }:
{
  environment.systemPackages = [
    inputs.firefox.packages.${pkgs.system}.firefox-nightly-bin
  ];
}

The downside of using this method is that you'll have to update the flake input before you can get a new nightly version, which also means that you might miss new builds since the flake lags behind the nightly release.

Non-reproducible (Impure)

Using this method is bad for reproducibility since it fetches resources from non-pinned URLs, but it also means you always get the latest nightly version when you build your system.

nixpkgs.overlays =
  let
    # Change this to a rev sha to pin
    moz-rev = "master";
    moz-url = builtins.fetchTarball { url = "https://github.com/mozilla/nixpkgs-mozilla/archive/${moz-rev}.tar.gz";};
    nightlyOverlay = (import "${moz-url}/firefox-overlay.nix");
  in [
    nightlyOverlay
  ];
programs.firefox.package = pkgs.latest.firefox-nightly-bin;

Once you've added the overlay, you'll need to pass the --impure option to nix commands. For example, in order to build and activate your configuration, you'll have to run:

$ nixos-rebuild switch --impure

Customizing with Home Manager

Home manager allows more customization for firefox. Such as extensions, search engines, bookmarks, userChrome and user.js. The example below shows a basic config defining Nix packages & options as a search engine. More options are available on Home Manager's site

home-manager.users.username = {
  programs.firefox = {
    enable = true;
    profiles = {
      "user" = {
        id = 0;
        isDefault = true;

        search.engines = {
          "Nix Packages" = {
            urls = [{
              template = "https://search.nixos.org/packages";
              params = [
                { name = "query"; value = "{searchTerms}"; }
              ];
            }];
            icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
            definedAliases = [ "@np" ];
          };
          "Nix Options" = {
            definedAliases = [ "@no" ];
            urls = [{
              template = "https://search.nixos.org/options";
              params = [
                { name = "query"; value = "{searchTerms}"; }
              ];
            }];
          };
        };
      };
    };
  };

FAQ

How do I use ALSA with Firefox instead of PulseAudio?

programs.firefox.package = (pkgs.wrapFirefox.override { libpulseaudio = pkgs.libpressureaudio; }) pkgs.firefox-unwrapped { };

Tips

=== Enabling Plasma Browser Integration === 1. Add the following line to your configuration.nix (note that enabling Plasma automatically does this):

programs.firefox.nativeMessagingHosts.packages = [ pkgs.plasma5Packages.plasma-browser-integration ];

2. Install KDE's Firefox extension.

Use KDE file picker

You must instruct Firefox to use the file picker offered by the XDG Desktop Portal framework. This setting can be found in Firefox's about:config as widget.use-xdg-desktop-portal.file-picker. The value 1 means "always". To set it using NixOS, add to 'configuration.nix'

  # Make Firefox use the KDE file picker.
  # Preferences source: https://wiki.archlinux.org/title/firefox#KDE_integration
  programs.firefox = {
    enable = true;
    preferences = {
      "widget.use-xdg-desktop-portal.file-picker" = 1;
    };
  };

Use xinput2

You can make Firefox use xinput2 by setting the MOZ_USE_XINPUT2 environment variable. This improves touchscreen support and enables additional touchpad gestures. It also enables smooth scrolling as opposed to the stepped scrolling that Firefox has by default. To do this, put the following in your config:

environment.sessionVariables = {
  MOZ_USE_XINPUT2 = "1";
};

Troubleshooting

If you can't start the browser because of a configuration error

For example:

firefox
1554035168269	Marionette	FATAL	XML parsing error: undefined entity
Location: chrome://browser/content/browser.xul
Line 2526, column 13:            <toolbarbutton id="tracking-protection-preferences-button"
JavaScript error: resource:///modules/aboutpages/AboutPrivateBrowsingHandler.jsm, line 28: TypeError: this.pageListener is undefined

An easy way to get away from this is to start firefox with the firefox -safe-mode command. Then you can troubleshoot your actual problem or you can call your luck by calling the refresh option (a special button will appear when firefox starts in this mode). This will reset your configuration to a sane state and you will be usually able to start the browser again, but you will lose most of your customization.

nativeMessagingHosts doesn't work

Such as enablePlasmaBrowserIntegration, enableGnomeExtensions, and enableBrowserpass.

They do not work with the firefox-bin derivation[1] or with firefox installed via nix-env


Screen Sharing under Wayland

When using Firefox with Wayland, screen sharing options might be limited and require additional configuration (exact capabilities vary with different compositors).

  • add Pipewire support to Firefox:
# when programs.firefox.enable == true
programs.firefox.wrapperConfig = {
  pipewireSupport = true;
};

# or, alternatively

environment.systemPackages = [
  # Replace this
  pkgs.firefox
  # With this
  (pkgs.wrapFirefox (pkgs.firefox-unwrapped.override { pipewireSupport = true;}) {})
];
services.pipewire.enable = true;
xdg = {
  portal = {
    enable = true;
    extraPortals = with pkgs; [
      xdg-desktop-portal-wlr
      xdg-desktop-portal-gtk
    ];
  };
};
  • Set environment variables to hint Firefox to use Wayland features. E.g.:
# Classical NixOS setup
environment.sessionVariables = {
  # only needed for Sway
  XDG_CURRENT_DESKTOP = "sway"; 
};
# Home Manager setup
home.sessionVariables = {
  # only needed for Sway
  XDG_CURRENT_DESKTOP = "sway"; 
};
  • Ensure that the environment variables are correctly set for the user systemd units, e.g.
  1. Sway users might achieve this by adding the following to their Sway config file
  2. This ensures all user units started after the command (not those already running) set the variables
exec systemctl --user import-environment