Firefox: Difference between revisions
No edit summary |
|||
| Line 1: | Line 1: | ||
<translate> | |||
[https://www.mozilla.org/firefox Firefox] is a graphical web browser developed by Mozilla. It can be used with a [[Firefox Sync Server]]. | [https://www.mozilla.org/firefox Firefox] is a graphical web browser developed by Mozilla. It can be used with a [[Firefox Sync Server]]. | ||
</translate> | |||
<translate> | |||
== Installation == | == Installation == | ||
</translate> | |||
<translate> | |||
Set <code>programs.firefox.enable</code> to true in your system or [[Home Manager]] configuration. | Set <code>programs.firefox.enable</code> 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. | Keep in mind that the NixOS and Home Manager modules have different options, so choose accordingly. | ||
</translate> | |||
<translate> | |||
== Firefox Variants == | == Firefox Variants == | ||
</translate> | |||
<translate> | |||
There are several Firefox variants that you can choose to install. To choose a variant, set <code>programs.firefox.package</code> accordingly. | There are several Firefox variants that you can choose to install. To choose a variant, set <code>programs.firefox.package</code> accordingly. | ||
</translate> | |||
<translate> | |||
'''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. | '''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. | ||
</translate> | |||
<translate> | |||
=== Variant: Official Binaries === | === Variant: Official Binaries === | ||
</translate> | |||
<translate> | |||
Mozilla provides official pre-built Firefox binaries. This is the <code>firefox-bin</code> package and will be downloaded directly from the Mozilla servers. | Mozilla provides official pre-built Firefox binaries. This is the <code>firefox-bin</code> package and will be downloaded directly from the Mozilla servers. | ||
</translate> | |||
<translate> | |||
=== Variant: ESR === | === Variant: ESR === | ||
</translate> | |||
<translate> | |||
<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. | <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. | ||
</translate> | |||
<translate> | |||
=== Variant: Nightly === | === Variant: Nightly === | ||
</translate> | |||
<translate> | |||
Nightly builds are daily builds of Firefox from the central Mozilla repository. | Nightly builds are daily builds of Firefox from the central Mozilla repository. | ||
</translate> | |||
<translate> | |||
==== Reproducible ==== | ==== Reproducible ==== | ||
</translate> | |||
<translate> | |||
This method uses flakes to pull in nightly versions of Firefox in a reproducible way, and is recommended for use. If you don't want to use flakes, check out the next section. | This method uses flakes to pull in nightly versions of Firefox in a reproducible way, and is recommended for use. If you don't want to use flakes, check out the next section. | ||
First, add the following inputs to your flake: | First, add the following inputs to your flake: | ||
</translate> | |||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
inputs = { | inputs = { | ||
| Line 32: | Line 50: | ||
}; | }; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<translate> | |||
Then, using the [[Flakes#Using_nix_flakes_with_NixOS|specialArgs]] attribute to pass flake inputs to external configuration files, add the nightly package to your system: | Then, using the [[Flakes#Using_nix_flakes_with_NixOS|specialArgs]] attribute to pass flake inputs to external configuration files, add the nightly package to your system: | ||
</translate> | |||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
{ pkgs, inputs, config, ... }: | { pkgs, inputs, config, ... }: | ||
| Line 43: | Line 61: | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<translate> | |||
The downside of using this method is that you'll have to update the flake input before you can get a new nightly version, which also means that you might miss new builds since the flake lags behind the nightly release. | The downside of using this method is that you'll have to update the flake input before you can get a new nightly version, which also means that you might miss new builds since the flake lags behind the nightly release. | ||
</translate> | |||
<translate> | |||
==== Non-reproducible (Impure) ==== | ==== Non-reproducible (Impure) ==== | ||
Using this method is bad for reproducibility since it fetches resources from non-pinned URLs, but it also means you always get the latest nightly version when you build your system. | Using this method is bad for reproducibility since it fetches resources from non-pinned URLs, but it also means you always get the latest nightly version when you build your system. | ||
</translate> | |||
<translate> | |||
{{tip|1=If you don't want to use flakes but you still want to reproducibly install Firefox nightly, you might want to use this method with [https://github.com/nmattia/niv niv].}} | {{tip|1=If you don't want to use flakes but you still want to reproducibly install Firefox nightly, you might want to use this method with [https://github.com/nmattia/niv niv].}} | ||
</translate> | |||
<translate> | |||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
nixpkgs.overlays = | nixpkgs.overlays = | ||
| Line 63: | Line 84: | ||
programs.firefox.package = pkgs.latest.firefox-nightly-bin; | programs.firefox.package = pkgs.latest.firefox-nightly-bin; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</translate> | |||
<translate> | |||
Once you've added the overlay, you'll need to pass the <code>--impure</code> option to nix commands. For example, in order to build and activate your configuration, you'll have to run: | Once you've added the overlay, you'll need to pass the <code>--impure</code> option to nix commands. For example, in order to build and activate your configuration, you'll have to run: | ||
</translate> | |||
<syntaxHighlight lang="console"> | <syntaxHighlight lang="console"> | ||
$ nixos-rebuild switch --impure | $ nixos-rebuild switch --impure | ||
</syntaxHighlight> | </syntaxHighlight> | ||
<translate> | |||
== Customizing with [[Home Manager]] == | == Customizing with [[Home Manager]] == | ||
</translate> | |||
<translate> | |||
Home manager allows more customization for firefox. Such as extensions, search engines, bookmarks, [https://www.userchrome.org/ userChrome] and [https://kb.mozillazine.org/User.js_file user.js]. The example below shows a basic config defining Nix packages & options as a search engine. | Home manager allows more customization for firefox. Such as extensions, search engines, bookmarks, [https://www.userchrome.org/ userChrome] and [https://kb.mozillazine.org/User.js_file user.js]. The example below shows a basic config defining Nix packages & options as a search engine. | ||
</translate> | |||
[https://nix-community.github.io/home-manager/options.xhtml More options are available on Home Manager's site]<syntaxhighlight lang="nix"> | <translate> | ||
[https://nix-community.github.io/home-manager/options.xhtml More options are available on Home Manager's site] | |||
</translate> | |||
<syntaxhighlight lang="nix"> | |||
home-manager.users.username = { | home-manager.users.username = { | ||
programs.firefox = { | programs.firefox = { | ||
| Line 107: | Line 133: | ||
}; | }; | ||
}; | }; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<translate> | |||
== FAQ == | == FAQ == | ||
</translate> | |||
<translate> | |||
=== How do I use ALSA with Firefox instead of PulseAudio? === | === How do I use ALSA with Firefox instead of PulseAudio? === | ||
</translate> | |||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
programs.firefox.package = (pkgs.wrapFirefox.override { libpulseaudio = pkgs.libpressureaudio; }) pkgs.firefox-unwrapped { }; | programs.firefox.package = (pkgs.wrapFirefox.override { libpulseaudio = pkgs.libpressureaudio; }) pkgs.firefox-unwrapped { }; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<translate> | |||
== Tips == | == Tips == | ||
</translate> | |||
=== Enabling [https://community.kde.org/Plasma/Browser_Integration#How_to_install Plasma Browser Integration] | <translate> | ||
=== Enabling | |||
[https://community.kde.org/Plasma/Browser_Integration#How_to_install Plasma Browser Integration] === | |||
</translate> | |||
<translate> | |||
1. Add the following line to your <code>configuration.nix</code> (note that [[KDE#Installation|enabling Plasma]] automatically does this): | 1. Add the following line to your <code>configuration.nix</code> (note that [[KDE#Installation|enabling Plasma]] automatically does this): | ||
</translate> | |||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
programs.firefox.nativeMessagingHosts.packages = [ pkgs.plasma5Packages.plasma-browser-integration ]; | programs.firefox.nativeMessagingHosts.packages = [ pkgs.plasma5Packages.plasma-browser-integration ]; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<translate> | |||
2. Install [https://addons.mozilla.org/en-US/firefox/addon/plasma-integration/ KDE's Firefox extension]. | 2. Install [https://addons.mozilla.org/en-US/firefox/addon/plasma-integration/ KDE's Firefox extension]. | ||
</translate> | |||
<translate> | |||
=== Use KDE file picker === | === Use KDE file picker === | ||
</translate> | |||
<translate> | |||
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> | 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> | ||
</translate> | |||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
# Make Firefox use the KDE file picker. | # Make Firefox use the KDE file picker. | ||
| Line 144: | Line 176: | ||
}; | }; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<translate> | |||
=== Use xinput2 === | === Use xinput2 === | ||
</translate> | |||
<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: | 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> | |||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
environment.sessionVariables = { | environment.sessionVariables = { | ||
| Line 154: | Line 187: | ||
}; | }; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<translate> | |||
== Troubleshooting== | == Troubleshooting== | ||
</translate> | |||
<translate> | |||
=== If you can't start the browser because of a configuration error === | === If you can't start the browser because of a configuration error === | ||
For example: | For example: | ||
</translate> | |||
<syntaxhighlight lang="text"> | <syntaxhighlight lang="text"> | ||
firefox | firefox | ||
| Line 168: | Line 202: | ||
JavaScript error: resource:///modules/aboutpages/AboutPrivateBrowsingHandler.jsm, line 28: TypeError: this.pageListener is undefined | JavaScript error: resource:///modules/aboutpages/AboutPrivateBrowsingHandler.jsm, line 28: TypeError: this.pageListener is undefined | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<translate> | |||
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. | 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> | |||
<translate> | |||
=== <code>nativeMessagingHosts</code> doesn't work === | === <code>nativeMessagingHosts</code> doesn't work === | ||
</translate> | |||
<translate> | |||
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> | 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> | ||
| Line 179: | Line 215: | ||
<hr /> | <hr /> | ||
<references /> | <references /> | ||
</translate> | |||
<translate> | |||
=== Screen Sharing under Wayland === | === Screen Sharing under Wayland === | ||
</translate> | |||
<translate> | |||
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> | |||
* add Pipewire support to Firefox:<syntaxhighlight lang="nix"> | <translate> | ||
* add Pipewire support to Firefox: | |||
</translate> | |||
<translate> | |||
<syntaxhighlight lang="nix"> | |||
environment.systemPackages = [ | environment.systemPackages = [ | ||
# Replace this | # Replace this | ||
| Line 192: | Line 234: | ||
]; | ]; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
* Enable [https://pipewire.org/ PipeWire] | </translate> | ||
<translate> | |||
* Enable [https://pipewire.org/ PipeWire] | |||
</translate> | |||
<syntaxhighlight lang="nix"> | |||
services.pipewire.enable = true; | services.pipewire.enable = true; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
* Enable [https://github.com/flatpak/xdg-desktop-portal/blob/master/README.md xdg desktop integration]:<syntaxhighlight lang="nix"> | <translate> | ||
* Enable [https://github.com/flatpak/xdg-desktop-portal/blob/master/README.md xdg desktop integration]: | |||
</translate> | |||
<syntaxhighlight lang="nix"> | |||
xdg = { | xdg = { | ||
portal = { | portal = { | ||
| Line 206: | Line 255: | ||
}; | }; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
* Set environment variables to hint Firefox to use Wayland features. E.g.:<syntaxhighlight lang="nix"> | <translate> | ||
* Set environment variables to hint Firefox to use Wayland features. E.g.: | |||
</translate> | |||
<translate> | |||
<syntaxhighlight lang="nix"> | |||
# Classical NixOS setup | # Classical NixOS setup | ||
environment.sessionVariables = { | environment.sessionVariables = { | ||
| Line 219: | Line 272: | ||
}; | }; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
* Ensure that the environment variables are correctly set for the user systemd units, e.g. | </translate> | ||
<translate> | |||
* Ensure that the environment variables are correctly set for the user systemd units, e.g. | |||
</translate> | |||
<translate> | |||
<syntaxhighlight lang="bash"> | |||
# Sway users might achieve this by adding the following to their Sway config file | # 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 | # This ensures all user units started after the command (not those already running) set the variables | ||
exec systemctl --user import-environment | exec systemctl --user import-environment | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</translate> | |||
[[Category:Cookbook]] | [[Category:Cookbook]] | ||
[[Category:Applications]] | [[Category:Applications]] | ||