Firefox: Difference between revisions
m Category:Web Browser added |
capitalize firefox; don't use "you"; tidy up |
||
Line 1: | Line 1: | ||
<translate> | <translate> | ||
<!--T:1--> | <!--T:1--> | ||
[https://www.mozilla.org/firefox Firefox] is a graphical web browser developed by Mozilla | [https://www.mozilla.org/firefox Firefox] is a graphical web browser developed by Mozilla. | ||
</translate> | </translate> | ||
<translate> | <translate> | ||
Line 30: | Line 30: | ||
</translate> | </translate> | ||
<translate> | <translate> | ||
=== Variant: ESR === <!--T:9--> | === Variant: Extended Support Release (ESR) === <!--T:9--> | ||
</translate> | </translate> | ||
<translate> | <translate> | ||
<!--T:10--> | <!--T:10--> | ||
<code>firefox-esr</code> is | <code>firefox-esr</code> is a variant of Firefox provided by Mozilla, which receives security updates for a longer period of time and a more relaxed cadence of feature implementation. It also allows users to change otherwise untouchable behavior with Firefox using policies. | ||
</translate> | </translate> | ||
<translate> | <translate> | ||
Line 44: | Line 44: | ||
</translate> | </translate> | ||
<translate> | <translate> | ||
==== | ==== Method #1: Using nix-community/flake-firefox-nightly ==== <!--T:13--> | ||
</translate> | </translate> | ||
<translate> | <translate> | ||
<!--T:14--> | <!--T:14--> | ||
This method | This method is reproducible but may lag behind the upstream version of Firefox Nightly. It uses flakes. | ||
<!--T:15--> | <!--T:15--> | ||
Line 71: | Line 71: | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==== Method #2: Using mozilla/nixpkgs-mozilla ==== <!--T:18--> | |||
<nowiki></translate></nowiki> | |||
==== | |||
</translate> | |||
<translate> | <translate> | ||
<!--T:19--> | <!--T:19--> | ||
This method is not necessarily reproducible without a [[Flake]]-like system because it fetches resources from non-pinned URLs, but it will always be the latest Nightly version. | |||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
nixpkgs.overlays = | nixpkgs.overlays = | ||
Line 103: | Line 91: | ||
<translate> | <translate> | ||
<!--T:22--> | <!--T:22--> | ||
It is also needed to pass the <code>--impure</code> option to nix commands. For example, | |||
</translate> | </translate> | ||
<syntaxHighlight lang="console"> | <syntaxHighlight lang="console"> | ||
Line 212: | Line 200: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<translate> | <translate> | ||
== Troubleshooting== | == Troubleshooting== | ||
=== <code>nativeMessagingHosts</code> doesn't work === <!--T:40--> | === <code>nativeMessagingHosts</code> doesn't work === <!--T:40--> | ||
</translate> | </translate> | ||
<translate> | <translate> | ||
<!--T:41--> | <!--T:41--> | ||
These options, for example <code>enablePlasmaBrowserIntegration</code>, or<code>enableGnomeExtensions</code>, do not work with the <code>bin</code> variants of the Firefox packages or with Firefox installed via<code>nix-env</code>. | |||
</translate> | </translate> | ||
<hr /> | <hr /> | ||
<translate> | <translate> | ||
=== Screen Sharing under Wayland === <!--T:43--> | === Screen Sharing under Wayland === <!--T:43--> | ||
Line 250: | Line 216: | ||
When using Firefox with Wayland, screen sharing options might be limited and require additional configuration (exact capabilities vary with different compositors). | When using Firefox with Wayland, screen sharing options might be limited and require additional configuration (exact capabilities vary with different compositors). | ||
</translate> | </translate> | ||
<translate> | |||
<!--T:47--> | |||
* Enable [https://pipewire.org/ PipeWire] | |||
</translate> | |||
<syntaxhighlight lang="nix"> | |||
services.pipewire.enable = true; | |||
</syntaxhighlight> | |||
<translate> | <translate> | ||
<!--T:45--> | <!--T:45--> | ||
* | * Add PipeWire support to Firefox: | ||
</translate> | </translate> | ||
<translate> | <translate> | ||
<!--T:46--> | <!--T:46--> | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="nixos"> | ||
programs.firefox.enable = true | |||
programs.firefox.wrapperConfig = { | programs.firefox.wrapperConfig = { | ||
pipewireSupport = true; | pipewireSupport = true; | ||
}; | }; | ||
</syntaxhighlight> | |||
< | Alternatively, it is possible to override the Firefox derivation with [[PipeWire]] support to it:<syntaxhighlight lang="diff"> | ||
< | |||
environment.systemPackages = [ | environment.systemPackages = [ | ||
- pkgs.firefox | |||
+ pkgs.wrapFirefox (pkgs.firefox-unwrapped.override { pipewireSupport = true;}) {}) | |||
]; | ]; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</translate> | </translate> | ||
<translate> | <translate> | ||
<!--T:48--> | <!--T:48--> | ||
Line 303: | Line 267: | ||
<!--T:50--> | <!--T:50--> | ||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
# | # NixOS setup | ||
environment.sessionVariables = { | environment.sessionVariables = { | ||
# only needed for Sway | # only needed for Sway |
Latest revision as of 23:48, 26 October 2024
Firefox is a graphical web browser developed by Mozilla.
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: Extended Support Release (ESR)
firefox-esr
is a variant of Firefox provided by Mozilla, which receives security updates for a longer period of time and a more relaxed cadence of feature implementation. It also allows users to change otherwise untouchable behavior with Firefox using policies.
Variant: Nightly
Nightly builds are daily builds of Firefox from the central Mozilla repository.
Method #1: Using nix-community/flake-firefox-nightly
This method is reproducible but may lag behind the upstream version of Firefox Nightly. It uses flakes.
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
];
}
Method #2: Using mozilla/nixpkgs-mozilla
</translate> This method is not necessarily reproducible without a Flake-like system because it fetches resources from non-pinned URLs, but it will always be the latest Nightly version.
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;
It is also needed to pass the --impure
option to nix commands. For example,
$ 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
nativeMessagingHosts
doesn't work
These options, for example enablePlasmaBrowserIntegration
, orenableGnomeExtensions
, do not work with the bin
variants of the Firefox packages or with Firefox installed vianix-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).
- Enable PipeWire
services.pipewire.enable = true;
- Add PipeWire support to Firefox:
programs.firefox.enable = true
programs.firefox.wrapperConfig = {
pipewireSupport = true;
};
Alternatively, it is possible to override the Firefox derivation with PipeWire support to it:
environment.systemPackages = [
- pkgs.firefox
+ pkgs.wrapFirefox (pkgs.firefox-unwrapped.override { pipewireSupport = true;}) {})
];
- Enable xdg desktop integration:
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.:
# 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.
- 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