Firefox
Firefox is a graphical web browser developed by Mozilla.
Installation
NixOS
environment.systemPackages = with pkgs; [ firefox ]
Home Manager
Home Manager provides options to manage Firefox. You can find them below the the Configuration Option programs.firefox.enable entry in the Home Manager Manual.
programs.firefox.enable = true;
or
home.packages = with pkgs; [ firefox ]
if you do not need the home-manager options
Non-NixOS
Other Editions
Nixpkgs also offers other variants of Firefox aside from the ones stated above. These may suit your needs more comfortably than vanilla Firefox.
Note: The packages for the variants listed below are installed instead of the normal firefox
package and each other, which means that you'll have to choose one among these options.
Wayland
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 firefox
package with firefox-wayland
instead.
Screen Sharing
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).
- Use
firefox-wayland
, e.g.:# 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 = {}; }; }; };
- Enable PipeWire:
services.pipewire.enable = true;
- Enable xdg desktop integration:
xdg = { portal = { enable = true; extraPortals = with pkgs; [ xdg-desktop-portal-wlr xdg-desktop-portal-gtk ]; gtkUsePortal = true; }; };
- Set environment variables to hint Firefox to use Wayland features. E.g.:
# Classical NixOS setup environment.sessionVariables = { MOZ_ENABLE_WAYLAND = "1"; XDG_CURRENT_DESKTOP = "sway"; # TODO: Do we need this in non-sway setups? XDG_SESSION_TYPE = "wayland"; }; # Home Manager setup home.sessionVariables = { MOZ_ENABLE_WAYLAND = 1; XDG_CURRENT_DESKTOP = "sway"; # TODO: Do we need this in non-sway setups? XDG_SESSION_TYPE = "wayland"; };
- Ensure that the environment variables are correctly set for the user systemd units. E.g.:
# 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 exec systemctl --user import-environment
- Apply the patch from pull-request #106815 to fix a screen sharing related regression
Firefox ESR
This is the Extended Support Release 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 firefox-esr
package.
Mozilla Distributed Binaries
Mozilla themselves provide official pre-built Firefox binaries. It is possible to install these packages through Nix by using the -bin
suffix with the package. So you'd use firefox-bin
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
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 ];
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.
{ pkgs ? import <nixpkgs> {} }:
(pkgs.wrapFirefox.override {libpulseaudio = pkgs.libpressureaudio;}) pkgs.firefox-unwrapped {}
and installing it with nix-env -f firefox.nix -i
.
When using Home Manager, add the following to your configuration:
programs.firefox.package = (pkgs.wrapFirefox.override { libpulseaudio = pkgs.libpressureaudio; }) pkgs.firefox-unwrapped { };
I want Firefox, what is Nightly?
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 enabling unfree and installing firefox-bin
.
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 Plasma Browser Integration
1. Add following line to your configuration.nix:
nixpkgs.config.firefox.enablePlasmaBrowserIntegration = true;
If you're wondering where this part is coming from see NixOS Manual:Customising Packages
2. Install KDE's Firefox extension: Link
Troubleshooting
If you can't start the browser because of a configuration error.
For example:
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
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 don'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