Firefox: Difference between revisions

imported>Nix
m add Software/Applications subcategory
Ardenet (talk | contribs)
Marked this version for translation
 
(43 intermediate revisions by 24 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-->


=== NixOS ===
==== Shell ==== <!--T:56-->
</translate>


<syntaxhighlight lang="nix">
{{code|lang=bash|line=no|1=$ nix-shell -p firefox}}
environment.systemPackages = with pkgs; [ firefox ]
</syntaxhighlight>


[[Home Manager]] provides options to manage {{PAGENAME}}. You can find them below [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>
<!--T:57-->
The command above makes <code>firefox</code> available in your current shell without modifying any configuration files.


<syntaxhighlight lang="nix">
==== System setup ==== <!--T:58-->
# Home Manager when not using any additional Firefox options
</translate>
home.packages = with pkgs; [ firefox ]


# Home Manager programs.firefox style
{{code|lang=nix|line=no|1=# Example for /etc/nixos/configuration.nix
programs.firefox.enable = true;
environment.systemPackages = [
</syntaxhighlight>
  pkgs.firefox
];


=== Non-NixOS ===
# User-specific installation (in ~/.config/nixpkgs/home.nix)
Firefox can be installed by specifying the packages declaratively as stated in the [https://nixos.org/manual/nixpkgs/stable/#sec-declarative-package-management manual].
home.packages = [
  pkgs.firefox
];}}
<translate>
<!--T:59-->
After rebuilding with <code>nixos-rebuild switch</code>, Firefox will be installed system-wide.


==Other Editions==
== Configuration == <!--T:60-->
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 <code>firefox</code> package and each other, which means that you'll have to choose one among these options.
==== Basic ==== <!--T:61-->
</translate>


===Wayland===
{{code|lang=nix|line=no|1=
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.
programs.firefox = {
  enable = true;


====Screen Sharing====
  languagePacks = [ "en-US" "de" "fr" ];
When using Firefox with Wayland, screen sharing options might be limited and require additional configuration (exact capabilities vary with different compositors).


* Use <code>firefox-wayland</code>, e.g.:<syntaxhighlight lang="nix">
  preferences = {
# NixOS system wide Firefox install
    "browser.startup.homepage"      = "https://example.com";
environment.systemPackages = with pkgs; [ firefox-wayland ]
    "privacy.resistFingerprinting"  = true;
  };


# Home Manager when not using any additional Firefox options
  policies = {
home.packages = with pkgs; [ firefox-wayland ]
    DisableTelemetry = true;
  };
};
}}


# Home Manager programs.firefox style
<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 = {
programs.firefox = {
   enable = true;
   enable = true;
   package = pkgs.wrapFirefox pkgs.firefox-unwrapped {
 
    forceWayland = true;
  languagePacks = [ "en-US" ];
     extraPolicies = {
 
       ExtensionSettings = {};
   policies = {
    # Updates & Background Services
    AppAutoUpdate                = false;
    BackgroundAppUpdate          = false;
 
    # Feature Disabling
    DisableBuiltinPDFViewer      = true;
    DisableFirefoxStudies        = true;
    DisableFirefoxAccounts        = true;
    DisableFirefoxScreenshots    = true;
    DisableForgetButton          = true;
    DisableMasterPasswordCreation = true;
    DisableProfileImport          = true;
    DisableProfileRefresh        = true;
    DisableSetDesktopBackground  = true;
    DisablePocket                = true;
    DisableTelemetry              = true;
    DisableFormHistory            = true;
    DisablePasswordReveal        = true;
 
    # Access Restrictions
    BlockAboutConfig              = false;
    BlockAboutProfiles            = true;
    BlockAboutSupport            = true;
 
    # UI and Behavior
    DisplayMenuBar                = "never";
    DontCheckDefaultBrowser      = true;
    HardwareAcceleration          = false;
    OfferToSaveLogins            = false;
    DefaultDownloadDirectory      = "${home}/Downloads";
 
    # Extensions
    ExtensionSettings = let
      moz = short: "https://addons.mozilla.org/firefox/downloads/latest/${short}/latest.xpi";
    in {
      "*".installation_mode = "blocked";
 
      "uBlock0@raymondhill.net" = {
        install_url      = moz "ublock-origin";
        installation_mode = "force_installed";
        updates_disabled  = true;
      };
 
      "{f3b4b962-34b4-4935-9eee-45b0bce58279}" = {
        install_url      = moz "animated-purple-moon-lake";
        installation_mode = "force_installed";
        updates_disabled  = true;
      };
 
      "{73a6fe31-595d-460b-a920-fcc0f8843232}" = {
        install_url      = moz "noscript";
        installation_mode = "force_installed";
        updates_disabled  = true;
      };
     };
 
    # Extension configuration
    "3rdparty".Extensions = {
       "uBlock0@raymondhill.net".adminSettings = {
        userSettings = rec {
          uiTheme            = "dark";
          uiAccentCustom    = true;
          uiAccentCustom0    = "#8300ff";
          cloudStorageEnabled = mkForce false;
 
          importedLists = [
            "https:#filters.adtidy.org/extension/ublock/filters/3.txt"
            "https:#github.com/DandelionSprout/adfilt/raw/master/LegitimateURLShortener.txt"
          ];
 
          externalLists = lib.concatStringsSep "\n" importedLists;
        };
 
        selectedFilterLists = [
          "CZE-0"
          "adguard-generic"
          "adguard-annoyance"
          "adguard-social"
          "adguard-spyware-url"
          "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>
  profiles.default.search = {
* Enable [https://pipewire.org/ PipeWire]:<syntaxhighlight lang="nix">
    force          = true;
services.pipewire.enable = true;
    default        = "DuckDuckGo";
</syntaxhighlight>
    privateDefault  = "DuckDuckGo";
* Enable [https://github.com/flatpak/xdg-desktop-portal/blob/master/README.md xdg desktop integration]:<syntaxhighlight lang="nix">
 
xdg = {
    engines = {
  portal = {
      "Nix Packages" = {
    enable = true;
        urls = [
    extraPortals = with pkgs; [
          {
      xdg-desktop-portal-wlr
            template = "https://search.nixos.org/packages";
      xdg-desktop-portal-gtk
            params = [
    ];
              { name = "channel"; value = "unstable"; }
     gtkUsePortal = true;
              { name = "query";  value = "{searchTerms}"; }
            ];
          }
        ];
        icon          = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
        definedAliases = [ "@np" ];
      };
 
      "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" ];
      };
 
      "NixOS Wiki" = {
        urls = [
          {
            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>
}}
* Set environment variables to hint Firefox to use Wayland features. E.g.:<syntaxhighlight lang="nix">
 
# Classical NixOS setup
<translate>
environment.sessionVariables = {
<!--T:25-->
  MOZ_ENABLE_WAYLAND = "1";
[https://nix-community.github.io/home-manager/options.xhtml#opt-programs.firefox.enable More options are available on Home Manager's site.]
  XDG_CURRENT_DESKTOP = "sway";  
 
== Firefox Variants == <!--T:4-->
 
<!--T:5-->
There are several Firefox variants available. To choose one, set the <code>programs.firefox.package</code> option accordingly.
</translate>
 
{{Note|<translate><!--T:6--> The packages for the variants listed below are installed ''instead'' of the normal <code>firefox</code> package.</translate>}}
 
<translate>
=== Variant: Official Binaries === <!--T:7-->
 
<!--T:8-->
Mozilla provides official pre-built Firefox binaries via the <code>firefox-bin</code> package, which are downloaded directly from Mozilla's servers.
 
=== Variant: Extended Support Release (ESR) === <!--T:9-->
 
<!--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.
 
=== Variant: Nightly === <!--T:11-->
 
<!--T:12-->
Nightly builds are daily builds from the central Mozilla repository.
 
==== Method 1: Using nix-community/flake-firefox-nightly ==== <!--T:13-->
 
<!--T:14-->
This method is reproducible but may lag behind the upstream version. First, add the input to your flake:
</translate>
 
{{code|lang=nix|line=no|1=
inputs = {
  firefox.url = "github:nix-community/flake-firefox-nightly";
  firefox.inputs.nixpkgs.follows = "nixpkgs";
};
};
}}


# Home Manager setup
<translate>
home.sessionVariables = {
<!--T:16-->
   MOZ_ENABLE_WAYLAND = 1;
Then, add the package to your system:
  XDG_CURRENT_DESKTOP = "sway";  
</translate>
};
 
</syntaxhighlight>
{{code|lang=nix|line=no|1=
* If you are not using Sway you can remove the 'XDG_CURRENT_DESKTOP = "sway";' line
# In configuration.nix, assuming use of specialArgs
* Ensure that the environment variables are correctly set for the user systemd units. E.g.:<syntaxhighlight lang="shell">
environment.systemPackages = [
# Sway users might achieve this by adding the following to their Sway config file
   inputs.firefox.packages.${pkgs.stdenv.hostPlatform.system}.firefox-nightly-bin
# This ensures all user units started after the command (not those already running) set the variables
];
exec systemctl --user import-environment
}}
</syntaxhighlight>
 
<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;
}}


===Firefox ESR===
<translate>
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.
<!--T:22-->
Using this method requires the <code>--impure</code> flag for Nix commands, for example:
</translate>


===Mozilla Distributed Binaries===
{{code|lang=bash|line=no|1=$ nixos-rebuild switch --impure}}
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===
<translate>
Nightly builds are daily builds of Firefox from the Mozilla-central repository
== Tips and Tricks == <!--T:28-->


To use them
==== Force XWayland (X11) instead of Wayland ==== <!--T:62-->
<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 ==
<!--T:63-->
Firefox defaults to native Wayland when running under a Wayland compositor. To force it to use XWayland (X11) instead:
</translate>


=== How to run Firefox without pulseaudio and still get audio output? ===
{{code|lang=nix|line=no|1=environment.sessionVariables.MOZ_ENABLE_WAYLAND = "0";}}


Replace libpulseaudio by libpressureaudio, which uses apulse to emulate PulseAudio but uses ALSA directly. So, you don't need to install/enable pulse audio.
<translate>
<!--T:30a-->
This is useful when troubleshooting Wayland-specific issues or when certain features work better under X11.


<syntaxhighlight lang="nix">
==== Touchpad Gestures and Smooth Scrolling ==== <!--T:34-->
{ 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>.
<!--T:35-->
Enable <code>xinput2</code> to improve touchscreen support and enable additional touchpad gestures and smooth scrolling.
</translate>


When using [[Home Manager]], add the following to your configuration:
{{code|lang=nix|line=no|1=
<syntaxhighlight lang="nix">
environment.sessionVariables.MOZ_USE_XINPUT2 = "1";
programs.firefox.package = (pkgs.wrapFirefox.override { libpulseaudio = pkgs.libpressureaudio; }) pkgs.firefox-unwrapped { };
}}
</syntaxhighlight>


=== I want Firefox, what is Nightly? ===
<translate>
==== KDE Plasma Integration ==== <!--T:29-->


[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.
<!--T:30-->
1. Add the native messaging host package to your configuration:
</translate>


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>.
{{code|lang=nix|line=no|1=programs.firefox.nativeMessagingHosts.packages = [ pkgs.kdePackages.plasma-browser-integration ];}}


=== Firefox ESR and Oracle JDK ===
<translate>
<!--T:31-->
2. Install the corresponding [https://addons.mozilla.org/en-US/firefox/addon/plasma-integration/ browser add-on].


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.
==== Use KDE file picker ==== <!--T:32-->


Firefox stops support of Java plugin. To use Java plugin you have to use special Firefox ESR, Extended Support Release.
<!--T:33-->
To use the KDE file picker instead of the GTK one, set the following preference:
</translate>


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.
{{code|lang=nix|line=no|1=
programs.firefox.preferences = {
  "widget.use-xdg-desktop-portal.file-picker" = 1;
};
}}


== Repo extensions ==
<translate>
== Troubleshooting == <!--T:36-->


=== Enabling [https://community.kde.org/Plasma/Browser_Integration#How_to_install Plasma Browser Integration]  ===
==== Native Messaging Hosts Fail to Load ==== <!--T:40-->
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]
<!--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.


2. Install KDE's Firefox extension: [https://addons.mozilla.org/en-US/firefox/addon/plasma-integration/ Link]
==== ALSA audio instead of PulseAudio ==== <!--T:27-->


== Troubleshooting==
<!--T:64-->
To force Firefox to use ALSA, you can override it with a wrapper:
</translate>


===If you can't start the browser because of a configuration error.===
{{code|lang=nix|line=no|1=programs.firefox.package = pkgs.wrapFirefox pkgs.firefox-unwrapped { libpulseaudio = pkgs.libalsa; };}}


For example:  
<translate>
==== Screen Sharing under Wayland ==== <!--T:43-->


<syntaxhighlight>
<!--T:44-->
firefox
Screen sharing on Wayland requires enabling PipeWire and the appropriate XDG Desktop Portals.
1554035168269 Marionette FATAL Error de análisis XML: entidad indefinida
</translate>
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.  
{{code|lang=nix|line=no|1=
services.pipewire.enable = true;
xdg.portal = {
  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
  ];
};
}}


=== nativeMessagingHosts don't work ===
<translate>
such as enablePlasmaBrowserIntegration, enableGnomeExtensions, and enableBrowserpass
== See also == <!--T:65-->


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
<!--T:66-->
* [[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]


<hr />
== References == <!--T:67-->
<references />
</translate>


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