Firefox: Difference between revisions

imported>Hypnosis2839
Screen Sharing under Wayland: firefox-wayland is just an alias for firefox
Ardenet (talk | contribs)
Marked this version for translation
 
(30 intermediate revisions by 15 users not shown)
Line 1: Line 1:
[https://www.mozilla.org/firefox Firefox] is a graphical web browser developed by Mozilla.
<languages/>
{{infobox application
  |name=Mozilla Firefox
  |image=Firefox logo, 2019.svg
  |type=Web Browser
  |developer=Mozilla Foundation & Community
  |firstRelease=November 9, 2004
  |latestRelease=Firefox 140.0 (June 24, 2025)
  |status=Active
  |license=[https://www.mozilla.org/MPL/2.0/ Mozilla Public License 2.0]
  |os=Cross-platform (Linux, macOS, Windows, *BSD)
  |website=[https://www.mozilla.org/firefox mozilla.org/firefox]
  |github=mozilla/firefox
  |bugTracker=[https://bugzilla.mozilla.org/ Bugzilla]
  |documentation=[https://support.mozilla.org/ Official Support]
}}
<translate>
<!--T:1-->
<strong>Firefox</strong><ref>Mozilla Foundation, "Firefox", Official Website, Accessed June 2025. https://www.mozilla.org/firefox</ref> is a free and open-source web browser developed by the Mozilla Foundation. It is known for its focus on privacy, security, and user freedom, offering a customizable experience through a rich ecosystem of add-ons and themes.


== Installation ==
== Installation == <!--T:2-->


Set <code>programs.firefox.enable</code> to true in your system or [[Home Manager]] configuration.
==== Shell ==== <!--T:56-->
Keep in mind that the NixOS and Home Manager modules have different options, so choose accordingly.
</translate>


== Firefox Variants ==
{{code|lang=bash|line=no|1=$ nix-shell -p firefox}}


There are several Firefox variants that you can choose to install. To choose a variant, set <code>programs.firefox.package</code> accordingly.
<translate>
<!--T:57-->
The command above makes <code>firefox</code> available in your current shell without modifying any configuration files.


'''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.
==== System setup ==== <!--T:58-->
</translate>


=== Variant: Official Binaries ===
{{code|lang=nix|line=no|1=# Example for /etc/nixos/configuration.nix
Mozilla provides official pre-built Firefox binaries. This is the <code>firefox-bin</code> package and will be downloaded directly from the Mozilla servers.
environment.systemPackages = [
  pkgs.firefox
];


=== Variant: ESR ===
# User-specific installation (in ~/.config/nixpkgs/home.nix)
<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.
home.packages = [
  pkgs.firefox
];}}
<translate>
<!--T:59-->
After rebuilding with <code>nixos-rebuild switch</code>, Firefox will be installed system-wide.


=== Variant: Nightly ===
== Configuration == <!--T:60-->
Nightly builds are daily builds of Firefox from the central Mozilla repository.


To use them
==== Basic ==== <!--T:61-->
<syntaxhighlight lang="nix">
</translate>
nixpkgs.overlays =
 
   let
{{code|lang=nix|line=no|1=
    # Change this to a rev sha to pin
programs.firefox = {
    moz-rev = "master";
   enable = true;
     moz-url = builtins.fetchTarball { url = "https://github.com/mozilla/nixpkgs-mozilla/archive/${moz-rev}.tar.gz";};
 
     nightlyOverlay = (import "${moz-url}/firefox-overlay.nix");
  languagePacks = [ "en-US" "de" "fr" ];
   in [
 
     nightlyOverlay
  preferences = {
   ];
     "browser.startup.homepage"      = "https://example.com";
programs.firefox.package = pkgs.latest.firefox-nightly-bin;
     "privacy.resistFingerprinting" = true;
</syntaxhighlight>
  };
 
   policies = {
     DisableTelemetry = true;
   };
};
}}
 
<translate>
<!--T:3-->
The snippet above enables Firefox for all users (or the current Home Manager profile, if placed in <code>home.nix</code>).
 
==== Advanced ==== <!--T:23-->
 
<!--T:24-->
Home Manager allows for deep customization of Firefox, including extensions, search engines, bookmarks, and themes. The example below shows a configuration for adding custom search engines with aliases.
</translate>
 
{{code|lang=nix|line=no|1=
programs.firefox = {
  enable = true;


== FAQ ==
  languagePacks = [ "en-US" ];


=== How do I use ALSA with Firefox instead of PulseAudio? ===
  policies = {
    # Updates & Background Services
    AppAutoUpdate                = false;
    BackgroundAppUpdate          = false;


<syntaxhighlight lang="nix">
    # Feature Disabling
programs.firefox.package = (pkgs.wrapFirefox.override { libpulseaudio = pkgs.libpressureaudio; }) pkgs.firefox-unwrapped { };
    DisableBuiltinPDFViewer      = true;
</syntaxhighlight>
    DisableFirefoxStudies        = true;
    DisableFirefoxAccounts        = true;
    DisableFirefoxScreenshots    = true;
    DisableForgetButton          = true;
    DisableMasterPasswordCreation = true;
    DisableProfileImport          = true;
    DisableProfileRefresh        = true;
    DisableSetDesktopBackground  = true;
    DisablePocket                = true;
    DisableTelemetry              = true;
    DisableFormHistory            = true;
    DisablePasswordReveal        = true;


=== I want Firefox, what is Nightly? ===
    # Access Restrictions
    BlockAboutConfig              = false;
    BlockAboutProfiles            = true;
    BlockAboutSupport            = true;


[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.
    # UI and Behavior
    DisplayMenuBar                = "never";
    DontCheckDefaultBrowser      = true;
    HardwareAcceleration          = false;
    OfferToSaveLogins            = false;
    DefaultDownloadDirectory      = "${home}/Downloads";


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>.
    # Extensions
    ExtensionSettings = let
      moz = short: "https://addons.mozilla.org/firefox/downloads/latest/${short}/latest.xpi";
    in {
      "*".installation_mode = "blocked";


== Tips ==
      "uBlock0@raymondhill.net" = {
        install_url      = moz "ublock-origin";
        installation_mode = "force_installed";
        updates_disabled  = true;
      };


=== Enabling [https://community.kde.org/Plasma/Browser_Integration#How_to_install Plasma Browser Integration]  ===
      "{f3b4b962-34b4-4935-9eee-45b0bce58279}" = {
1. Add the following line to your <code>configuration.nix</code> (note that [[KDE#Installation|enabling Plasma]] automatically does this):
        install_url      = moz "animated-purple-moon-lake";
        installation_mode = "force_installed";
        updates_disabled  = true;
      };


<syntaxhighlight lang="nix">
      "{73a6fe31-595d-460b-a920-fcc0f8843232}" = {
programs.firefox.nativeMessagingHosts.packages = [ pkgs.plasma5Packages.plasma-browser-integration ];
        install_url      = moz "noscript";
</syntaxhighlight>
        installation_mode = "force_installed";
        updates_disabled  = true;
      };
    };


2. Install [https://addons.mozilla.org/en-US/firefox/addon/plasma-integration/ KDE's Firefox extension].
    # Extension configuration
    "3rdparty".Extensions = {
      "uBlock0@raymondhill.net".adminSettings = {
        userSettings = rec {
          uiTheme            = "dark";
          uiAccentCustom    = true;
          uiAccentCustom0    = "#8300ff";
          cloudStorageEnabled = mkForce false;


=== Use KDE file picker ===
          importedLists = [
            "https:#filters.adtidy.org/extension/ublock/filters/3.txt"
            "https:#github.com/DandelionSprout/adfilt/raw/master/LegitimateURLShortener.txt"
          ];


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>
          externalLists = lib.concatStringsSep "\n" importedLists;
        };


<syntaxhighlight lang="nix">
        selectedFilterLists = [
  # Make Firefox use the KDE file picker.
          "CZE-0"
  # Preferences source: https://wiki.archlinux.org/title/firefox#KDE_integration
          "adguard-generic"
  programs.firefox = {
          "adguard-annoyance"
    enable = true;
          "adguard-social"
    preferences = {
          "adguard-spyware-url"
      "widget.use-xdg-desktop-portal.file-picker" = 1;
          "easylist"
          "easyprivacy"
          "https:#github.com/DandelionSprout/adfilt/raw/master/LegitimateURLShortener.txt"
          "plowe-0"
          "ublock-abuse"
          "ublock-badware"
          "ublock-filters"
          "ublock-privacy"
          "ublock-quick-fixes"
          "ublock-unbreak"
          "urlhaus-1"
        ];
      };
     };
     };
   };
   };
</syntaxhighlight>


=== Use xinput2 ===
  profiles.default.search = {
    force          = true;
    default        = "DuckDuckGo";
    privateDefault  = "DuckDuckGo";
 
    engines = {
      "Nix Packages" = {
        urls = [
          {
            template = "https://search.nixos.org/packages";
            params = [
              { name = "channel"; value = "unstable"; }
              { name = "query";  value = "{searchTerms}"; }
            ];
          }
        ];
        icon          = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
        definedAliases = [ "@np" ];
      };


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:
      "Nix Options" = {
        urls = [
          {
            template = "https://search.nixos.org/options";
            params = [
              { name = "channel"; value = "unstable"; }
              { name = "query";  value = "{searchTerms}"; }
            ];
          }
        ];
        icon          = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
        definedAliases = [ "@no" ];
      };


<syntaxhighlight lang="nix">
      "NixOS Wiki" = {
environment.sessionVariables = {
        urls = [
  MOZ_USE_XINPUT2 = "1";
          {
            template = "https://wiki.nixos.org/w/index.php";
            params = [
              { name = "search"; value = "{searchTerms}"; }
            ];
          }
        ];
        icon          = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
        definedAliases = [ "@nw" ];
      };
    };
  };
};
};
</syntaxhighlight>
}}


== Troubleshooting==
<translate>
<!--T:25-->
[https://nix-community.github.io/home-manager/options.xhtml#opt-programs.firefox.enable More options are available on Home Manager's site.]


=== If you can't start the browser because of a configuration error ===  
== Firefox Variants == <!--T:4-->


For example:  
<!--T:5-->
There are several Firefox variants available. To choose one, set the <code>programs.firefox.package</code> option accordingly.
</translate>


<syntaxhighlight lang="text">
{{Note|<translate><!--T:6--> The packages for the variants listed below are installed ''instead'' of the normal <code>firefox</code> package.</translate>}}
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>


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>
=== Variant: Official Binaries === <!--T:7-->


=== <code>nativeMessagingHosts</code> doesn't work ===
<!--T:8-->
Mozilla provides official pre-built Firefox binaries via the <code>firefox-bin</code> package, which are downloaded directly from Mozilla's servers.


such as <code>enablePlasmaBrowserIntegration</code>, <code>enableGnomeExtensions</code>, and <code>enableBrowserpass</code>.
=== Variant: Extended Support Release (ESR) === <!--T:9-->


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>
<!--T:10-->
<code>firefox-esr</code> is a variant that receives security updates for a longer period with a slower feature implementation cadence. It also allows for more extensive policy-based configuration.


<hr />
=== Variant: Nightly === <!--T:11-->
<references />


=== Screen Sharing under Wayland ===
<!--T:12-->
Nightly builds are daily builds from the central Mozilla repository.


When using Firefox with Wayland, screen sharing options might be limited and require additional configuration (exact capabilities vary with different compositors).
==== Method 1: Using nix-community/flake-firefox-nightly ==== <!--T:13-->


* Enable [https://pipewire.org/ PipeWire]:<syntaxhighlight lang="nix">
<!--T:14-->
services.pipewire.enable = true;
This method is reproducible but may lag behind the upstream version. First, add the input to your flake:
</syntaxhighlight>
</translate>
* Enable [https://github.com/flatpak/xdg-desktop-portal/blob/master/README.md xdg desktop integration]:<syntaxhighlight lang="nix">
 
xdg = {
{{code|lang=nix|line=no|1=
   portal = {
inputs = {
    enable = true;
   firefox.url = "github:nix-community/flake-firefox-nightly";
    extraPortals = with pkgs; [
   firefox.inputs.nixpkgs.follows = "nixpkgs";
      xdg-desktop-portal-wlr
      xdg-desktop-portal-gtk
    ];
   };
};
};
</syntaxhighlight>
}}
* Set environment variables to hint Firefox to use Wayland features. E.g.:<syntaxhighlight lang="nix">
 
# Classical NixOS setup
<translate>
environment.sessionVariables = {
<!--T:16-->
  # only needed for Sway
Then, add the package to your system:
   XDG_CURRENT_DESKTOP = "sway";  
</translate>
 
{{code|lang=nix|line=no|1=
# In configuration.nix, assuming use of specialArgs
environment.systemPackages = [
  inputs.firefox.packages.${pkgs.stdenv.hostPlatform.system}.firefox-nightly-bin
];
}}
 
<translate>
==== Method 2: Using mozilla/nixpkgs-mozilla ==== <!--T:18-->
 
<!--T:19-->
This method is not necessarily reproducible without a flake-like system but will always be the latest version.
</translate>
 
{{code|lang=nix|line=no|1=
nixpkgs.overlays = [
  (import (builtins.fetchTarball "https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz"))
];
programs.firefox.package = pkgs.latest.firefox-nightly-bin;
}}
 
<translate>
<!--T:22-->
Using this method requires the <code>--impure</code> flag for Nix commands, for example:
</translate>
 
{{code|lang=bash|line=no|1=$ nixos-rebuild switch --impure}}
 
<translate>
== Tips and Tricks == <!--T:28-->
 
==== Force XWayland (X11) instead of Wayland ==== <!--T:62-->
 
<!--T:63-->
Firefox defaults to native Wayland when running under a Wayland compositor. To force it to use XWayland (X11) instead:
</translate>
 
{{code|lang=nix|line=no|1=environment.sessionVariables.MOZ_ENABLE_WAYLAND = "0";}}
 
<translate>
<!--T:30a-->
This is useful when troubleshooting Wayland-specific issues or when certain features work better under X11.
 
==== Touchpad Gestures and Smooth Scrolling ==== <!--T:34-->
 
<!--T:35-->
Enable <code>xinput2</code> to improve touchscreen support and enable additional touchpad gestures and smooth scrolling.
</translate>
 
{{code|lang=nix|line=no|1=
environment.sessionVariables.MOZ_USE_XINPUT2 = "1";
}}
 
<translate>
==== KDE Plasma Integration ==== <!--T:29-->
 
<!--T:30-->
1. Add the native messaging host package to your configuration:
</translate>
 
{{code|lang=nix|line=no|1=programs.firefox.nativeMessagingHosts.packages = [ pkgs.kdePackages.plasma-browser-integration ];}}
 
<translate>
<!--T:31-->
2. Install the corresponding [https://addons.mozilla.org/en-US/firefox/addon/plasma-integration/ browser add-on].
 
==== Use KDE file picker ==== <!--T:32-->
 
<!--T:33-->
To use the KDE file picker instead of the GTK one, set the following preference:
</translate>
 
{{code|lang=nix|line=no|1=
programs.firefox.preferences = {
   "widget.use-xdg-desktop-portal.file-picker" = 1;
};
};
}}
<translate>
== Troubleshooting == <!--T:36-->
==== Native Messaging Hosts Fail to Load ==== <!--T:40-->
<!--T:42-->
Native messaging hosts (used for extensions like Plasma Integration) do not work with the <code>-bin</code> variants of Firefox or with Firefox installed imperatively via <code>nix-env</code>. You must use a variant built from source via your NixOS or Home Manager configuration.
==== ALSA audio instead of PulseAudio ==== <!--T:27-->
<!--T:64-->
To force Firefox to use ALSA, you can override it with a wrapper:
</translate>
{{code|lang=nix|line=no|1=programs.firefox.package = pkgs.wrapFirefox pkgs.firefox-unwrapped { libpulseaudio = pkgs.libalsa; };}}
<translate>
==== Screen Sharing under Wayland ==== <!--T:43-->
<!--T:44-->
Screen sharing on Wayland requires enabling PipeWire and the appropriate XDG Desktop Portals.
</translate>


# Home Manager setup
{{code|lang=nix|line=no|1=
home.sessionVariables = {
services.pipewire.enable = true;
   # only needed for Sway
xdg.portal = {
   XDG_CURRENT_DESKTOP = "sway";  
  enable = true;
   # Add the portal for your compositor, e.g.:
  extraPortals = with pkgs; [
    xdg-desktop-portal-wlr # For Sway/wlroots
    # xdg-desktop-portal-gtk # For GNOME
    # xdg-desktop-portal-kde # For KDE
   ];
};
};
</syntaxhighlight>
}}
* Ensure that the environment variables are correctly set for the user systemd units, e.g.:
 
<syntaxhighlight lang="bash">
<translate>
# Sway users might achieve this by adding the following to their Sway config file
== See also == <!--T:65-->
# This ensures all user units started after the command (not those already running) set the variables
 
exec systemctl --user import-environment
<!--T:66-->
</syntaxhighlight>
* [[Home Manager]] – Declarative per-user configuration
* [https://search.nixos.org/options?channel=unstable&query=programs.firefox NixOS options for Firefox]
* [https://discourse.nixos.org/tag/firefox Firefox topics on NixOS Discourse]
 
== References == <!--T:67-->
</translate>


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