Jump to content

Firefox: Difference between revisions

From NixOS Wiki
imported>Wackbyte
formatting
Qweered (talk | contribs)
m Modern alias
 
(35 intermediate revisions by 17 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:3-->


=== NixOS ===
==== Shell ==== <!--T:4-->
</translate>
{{code|lang=bash|line=no|1=$ nix-shell -p firefox}}
<translate>
<!--T:5-->
The command above makes <code>firefox</code> available in your current shell without modifying any configuration files.


<syntaxhighlight lang="nix">
==== System setup ==== <!--T:6-->
environment.systemPackages = with pkgs; [ firefox ];
</translate>
</syntaxhighlight>
{{code|lang=nix|line=no|1=# Example for /etc/nixos/configuration.nix
environment.systemPackages = [
  pkgs.firefox
];


It's also possible to install Firefox via [[Home Manager]]:
# User-specific installation (in ~/.config/nixpkgs/home.nix)
home.packages = [
  pkgs.firefox
];}}
<translate>
<!--T:7-->
After rebuilding with <code>nixos-rebuild switch</code>, Firefox will be installed system-wide.


<syntaxhighlight lang="nix">
== Configuration == <!--T:8-->
# If you want to configure Firefox (consult Home Manager's docs for options):
programs.firefox.enable = true;


# If you don't want to configure Firefox:
==== Basic ==== <!--T:9-->
home.packages = with pkgs; [ firefox ];
</translate>
</syntaxhighlight>
{{code|lang=nix|line=no|1=
programs.firefox = {
  enable = true;


See: [https://rycee.gitlab.io/home-manager/options.html#opt-programs.firefox.enable Home Manager's manual].
  languagePacks = [ "en-US" "de" "fr" ];


=== Non-NixOS ===
  preferences = {
    "browser.startup.homepage"      = "https://example.com";
    "privacy.resistFingerprinting"  = true;
  };


<syntaxHighlight lang="console">
  policies = {
$ nix-env -iA nixos.firefox
    DisableTelemetry = true;
</syntaxHighlight>
  };
 
};
== Tips ==
}}
 
<translate>
== Other Firefox Editions ==
<!--T:10-->
 
The snippet above enables Firefox for all users (or the current Home Manager profile, if placed in <code>home.nix</code>).
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.
 
=== 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 <code>firefox</code> package with <code>firefox-wayland</code> instead.
 
==== Screen Sharing ====
 
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">
# 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
==== Advanced ==== <!--T:11-->
</translate>
<translate>
<!--T:11a-->
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;
    extraPolicies = {
      ExtensionSettings = {};
    };
  };
};
</syntaxhighlight>
* Enable [https://pipewire.org/ PipeWire]:<syntaxhighlight lang="nix">
services.pipewire.enable = true;
</syntaxhighlight>
* Enable [https://github.com/flatpak/xdg-desktop-portal/blob/master/README.md xdg desktop integration]:<syntaxhighlight lang="nix">
xdg = {
  portal = {
    enable = true;
    extraPortals = with pkgs; [
      xdg-desktop-portal-wlr
      xdg-desktop-portal-gtk
    ];
    gtkUsePortal = true;
  };
};
</syntaxhighlight>
* Set environment variables to hint Firefox to use Wayland features. E.g.:<syntaxhighlight lang="nix">
# Classical NixOS setup
environment.sessionVariables = {
  MOZ_ENABLE_WAYLAND = "1";
  XDG_CURRENT_DESKTOP = "sway";
};
# Home Manager setup
home.sessionVariables = {
  MOZ_ENABLE_WAYLAND = 1;
  XDG_CURRENT_DESKTOP = "sway";
};
</syntaxhighlight>
* If you are not using Sway you can remove the 'XDG_CURRENT_DESKTOP = "sway";' line
* Ensure that the environment variables are correctly set for the user systemd units. E.g.:<syntaxhighlight lang="bash">
# 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
</syntaxhighlight>


  languagePacks = [ "en-US" ];


===Firefox ESR===
  policies = {
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.
    # Updates & Background Services
    AppAutoUpdate                = false;
    BackgroundAppUpdate          = false;


===Mozilla Distributed Binaries===
    # Feature Disabling
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.
    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;


===Firefox nightly===
    # Access Restrictions
Nightly builds are daily builds of Firefox from the Mozilla-central repository
    BlockAboutConfig              = false;
    BlockAboutProfiles            = true;
    BlockAboutSupport            = true;


To use them
    # UI and Behavior
<syntaxhighlight lang="nix">
    DisplayMenuBar                = "never";
nixpkgs.overlays =
    DontCheckDefaultBrowser      = true;
  let
     HardwareAcceleration          = false;
     # Change this to a rev sha to pin
     OfferToSaveLogins            = false;
    moz-rev = "master";
     DefaultDownloadDirectory      = "${home}/Downloads";
     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 ==
    # Extensions
    ExtensionSettings = let
      moz = short: "https://addons.mozilla.org/firefox/downloads/latest/${short}/latest.xpi";
    in {
      "*".installation_mode = "blocked";


=== How to run Firefox without pulseaudio and still get audio output? ===
      "uBlock0@raymondhill.net" = {
        install_url      = moz "ublock-origin";
        installation_mode = "force_installed";
        updates_disabled  = true;
      };


Replace libpulseaudio by libpressureaudio, which uses apulse to emulate PulseAudio but uses ALSA directly. So, you don't need to install/enable pulse audio.
      "{f3b4b962-34b4-4935-9eee-45b0bce58279}" = {
        install_url      = moz "animated-purple-moon-lake";
        installation_mode = "force_installed";
        updates_disabled  = true;
      };


<syntaxhighlight lang="nix">
      "{73a6fe31-595d-460b-a920-fcc0f8843232}" = {
{ pkgs ? import <nixpkgs> {} }:
        install_url      = moz "noscript";
(pkgs.wrapFirefox.override {libpulseaudio = pkgs.libpressureaudio;}) pkgs.firefox-unwrapped {}
        installation_mode = "force_installed";
</syntaxhighlight>
        updates_disabled  = true;
      };


and installing it with <code>nix-env -f firefox.nix -i</code>.
      "3rdparty".Extensions = {
        "uBlock0@raymondhill.net".adminSettings = {
          userSettings = rec {
            uiTheme            = "dark";
            uiAccentCustom    = true;
            uiAccentCustom0    = "#8300ff";
            cloudStorageEnabled = mkForce false;


When using [[Home Manager]], add the following to your configuration:
            importedLists = [
<syntaxhighlight lang="nix">
              "https:#filters.adtidy.org/extension/ublock/filters/3.txt"
programs.firefox.package = (pkgs.wrapFirefox.override { libpulseaudio = pkgs.libpressureaudio; }) pkgs.firefox-unwrapped { };
              "https:#github.com/DandelionSprout/adfilt/raw/master/LegitimateURLShortener.txt"
</syntaxhighlight>
            ];


=== I want Firefox, what is Nightly? ===
            externalLists = lib.concatStringsSep "\n" importedLists;
          };


[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.
          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"
          ];
        };
      };
    };
  };


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>.
  profiles.default.search = {
    force          = true;
    default        = "DuckDuckGo";
    privateDefault  = "DuckDuckGo";


=== Firefox ESR and Oracle JDK ===
    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" ];
      };


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.
      "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" ];
      };


Firefox stops support of Java plugin. To use Java plugin you have to use special Firefox ESR, Extended Support Release.
      "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" ];
      };
    };
  };
};
}}
<translate>
<!--T:11b-->
[https://nix-community.github.io/home-manager/options.xhtml#opt-programs.firefox.enable More options are available on Home Manager's site.]
</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.
<translate>


== Tips ==
== Firefox Variants == <!--T:12-->
</translate>
<translate>
<!--T:13-->
There are several Firefox variants available. To choose one, set the <code>programs.firefox.package</code> option accordingly.
</translate>
{{Note|The packages for the variants listed below are installed ''instead'' of the normal <code>firefox</code> package.}}
<translate>
=== Variant: Official Binaries === <!--T:14-->
</translate>
<translate>
<!--T:15-->
Mozilla provides official pre-built Firefox binaries via the <code>firefox-bin</code> package, which are downloaded directly from Mozilla's servers.
</translate>
<translate>
=== Variant: Extended Support Release (ESR) === <!--T:16-->
</translate>
<translate>
<!--T:17-->
<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.
</translate>
<translate>
=== Variant: Nightly === <!--T:18-->
</translate>
<translate>
<!--T:19-->
Nightly builds are daily builds from the central Mozilla repository.
</translate>
<translate>
==== Method 1: Using nix-community/flake-firefox-nightly ==== <!--T:20-->
</translate>
<translate>
<!--T:21-->
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";
};
}}
<translate>
<!--T:22-->
Then, add the package to your system:
</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:23-->
</translate>
<translate>
<!--T:24-->
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:25-->
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}}


=== Enabling [https://community.kde.org/Plasma/Browser_Integration#How_to_install Plasma Browser Integration===
<translate>
1. Add the following line to your configuration.nix:
== Tips and Tricks == <!--T:26-->
</translate>
<translate>
==== Enhancing Privacy ==== <!--T:27-->
</translate>
{{Note|Hardening Firefox often involves a trade-off between privacy and convenience. Some websites may not function correctly with aggressive settings.}}
<translate>
<!--T:28-->
Beyond the declarative settings above, you can further enhance privacy:
* '''Container Tabs''': Use an extension like [https://addons.mozilla.org/en-US/firefox/addon/multi-account-containers/ Multi-Account Containers] to isolate websites from each other, preventing cross-site tracking.
* '''DNS over HTTPS (DoH)''': Encrypt your DNS queries by enabling DoH in Firefox's network settings to prevent ISP snooping.
</translate>
<translate>
==== Wayland support ==== <!--T:29-->
</translate>
{{code|lang=nix|line=no|1=environment.sessionVariables.MOZ_ENABLE_WAYLAND = "1";}}
<translate>
<!--T:30-->
Setting the variable above makes Firefox use Wayland when available.
</translate>
<translate>
==== Touchpad Gestures and Smooth Scrolling ==== <!--T:31-->
</translate>
<translate>
<!--T:32-->
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:33-->
</translate>
<translate>
<!--T:34-->
1. Add the native messaging host package to your configuration:
</translate>
{{code|lang=nix|line=no|1=programs.firefox.nativeMessagingHosts.packages = [ pkgs.plasma-browser-integration ];}}
<translate>
<!--T:35-->
2. Install the corresponding [https://addons.mozilla.org/en-US/firefox/addon/plasma-integration/ browser add-on].
</translate>
<translate>
==== Use KDE file picker ==== <!--T:36-->
</translate>
<translate>
<!--T:37-->
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;
};
}}


<syntaxhighlight lang="nix">
<translate>
nixpkgs.config.firefox.enablePlasmaBrowserIntegration = true;
== Troubleshooting == <!--T:38-->
</syntaxhighlight>
</translate>
 
<translate>
If you're wondering where this part is coming from see [https://nixos.org/nixos/manual/#sec-customising-packages NixOS Manual:Customising Packages]
==== Native Messaging Hosts Fail to Load ==== <!--T:39-->
 
</translate>
2. Install [https://addons.mozilla.org/en-US/firefox/addon/plasma-integration/ KDE's Firefox extension].
<translate>
 
<!--T:40-->
=== Use xinput2 ===
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.
 
</translate>
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>
 
==== ALSA audio instead of PulseAudio ==== <!--T:41-->
<syntaxhighlight lang="nix">
</translate>
environment.sessionVariables = {
<translate>
   MOZ_USE_XINPUT2 = "1";
<!--T:42-->
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-->
</translate>
<translate>
<!--T:44-->
Screen sharing on Wayland requires enabling PipeWire and the appropriate XDG Desktop Portals.
</translate>
{{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
  ];
};
};
</syntaxhighlight>
}}
 
== Troubleshooting==
 
=== If you can't start the browser because of a configuration error ===
 
For example:
 
<syntaxhighlight lang="text">
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 <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.
 
=== <code>nativeMessagingHosts</code> don't work ===
 
such as <code>enablePlasmaBrowserIntegration</code>, <code>enableGnomeExtensions</code>, and <code>enableBrowserpass</code>.
 
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>


<hr />
<translate>
<references />
== See also == <!--T:45-->
</translate>
<translate>
* [[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]
</translate>
<translate>
== References == <!--T:46-->
</translate>


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

Latest revision as of 02:49, 30 July 2025

Mozilla Firefox

Web Browser Application

100%
Developer(s)Mozilla Foundation & Community
Latest releaseFirefox 140.0 (June 24, 2025)
StatusActive
Operating SystemCross-platform (Linux, macOS, Windows, *BSD)
LicenseMozilla Public License 2.0
External links
Websitemozilla.org/firefox
GitHubmozilla/firefox
Bug trackerBugzilla
DocumentationOfficial Support

Firefox[1] 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

Shell

$ nix-shell -p firefox

The command above makes firefox available in your current shell without modifying any configuration files.

System setup

# Example for /etc/nixos/configuration.nix
environment.systemPackages = [
  pkgs.firefox
];

# User-specific installation (in ~/.config/nixpkgs/home.nix)
home.packages = [
  pkgs.firefox
];

After rebuilding with nixos-rebuild switch, Firefox will be installed system-wide.

Configuration

Basic

programs.firefox = {
  enable = true;

  languagePacks = [ "en-US" "de" "fr" ];

  preferences = {
    "browser.startup.homepage"      = "https://example.com";
    "privacy.resistFingerprinting"  = true;
  };

  policies = {
    DisableTelemetry = true;
  };
};

The snippet above enables Firefox for all users (or the current Home Manager profile, if placed in home.nix).

Advanced

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.

programs.firefox = {
  enable = true;

  languagePacks = [ "en-US" ];

  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;
      };

      "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"
          ];
        };
      };
    };
  };

  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" ];
      };

      "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" ];
      };
    };
  };
};

More options are available on Home Manager's site.


Firefox Variants

There are several Firefox variants available. To choose one, set the programs.firefox.package option accordingly.

Note: The packages for the variants listed below are installed instead of the normal firefox package.

Variant: Official Binaries

Mozilla provides official pre-built Firefox binaries via the firefox-bin package, which are downloaded directly from Mozilla's servers.

Variant: Extended Support Release (ESR)

firefox-esr 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

Nightly builds are daily builds from the central Mozilla repository.

Method 1: Using nix-community/flake-firefox-nightly

This method is reproducible but may lag behind the upstream version. First, add the input to your flake:

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

Then, add the package to your system:

# In configuration.nix, assuming use of specialArgs
environment.systemPackages = [
  inputs.firefox.packages.${pkgs.stdenv.hostPlatform.system}.firefox-nightly-bin
];

Method 2: Using mozilla/nixpkgs-mozilla

This method is not necessarily reproducible without a flake-like system but will always be the latest version.

nixpkgs.overlays = [
  (import (builtins.fetchTarball "https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz"))
];
programs.firefox.package = pkgs.latest.firefox-nightly-bin;

Using this method requires the --impure flag for Nix commands, for example:

$ nixos-rebuild switch --impure

Tips and Tricks

Enhancing Privacy

Note: Hardening Firefox often involves a trade-off between privacy and convenience. Some websites may not function correctly with aggressive settings.

Beyond the declarative settings above, you can further enhance privacy:

  • Container Tabs: Use an extension like Multi-Account Containers to isolate websites from each other, preventing cross-site tracking.
  • DNS over HTTPS (DoH): Encrypt your DNS queries by enabling DoH in Firefox's network settings to prevent ISP snooping.

Wayland support

environment.sessionVariables.MOZ_ENABLE_WAYLAND = "1";

Setting the variable above makes Firefox use Wayland when available.

Touchpad Gestures and Smooth Scrolling

Enable xinput2 to improve touchscreen support and enable additional touchpad gestures and smooth scrolling.

environment.sessionVariables.MOZ_USE_XINPUT2 = "1";

KDE Plasma Integration

1. Add the native messaging host package to your configuration:

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

2. Install the corresponding browser add-on.

Use KDE file picker

To use the KDE file picker instead of the GTK one, set the following preference:

programs.firefox.preferences = {
  "widget.use-xdg-desktop-portal.file-picker" = 1;
};

Troubleshooting

Native Messaging Hosts Fail to Load

Native messaging hosts (used for extensions like Plasma Integration) do not work with the -bin variants of Firefox or with Firefox installed imperatively via nix-env. You must use a variant built from source via your NixOS or Home Manager configuration.

ALSA audio instead of PulseAudio

To force Firefox to use ALSA, you can override it with a wrapper:

programs.firefox.package = pkgs.wrapFirefox pkgs.firefox-unwrapped { libpulseaudio = pkgs.libalsa; };

Screen Sharing under Wayland

Screen sharing on Wayland requires enabling PipeWire and the appropriate XDG Desktop Portals.

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
  ];
};

See also

References

  1. Mozilla Foundation, "Firefox", Official Website, Accessed June 2025. https://www.mozilla.org/firefox