Firefox: Difference between revisions

imported>Aktaboot
m remove deprecated gtkUsePortal
imported>Hypnosis2839
m remove mentions of nix-env, java, and simplify explanations; remove repetitive text
Line 3: Line 3:
== Installation ==
== Installation ==


=== NixOS ===
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.
<syntaxhighlight lang="nix">
environment.systemPackages = with pkgs; [ firefox ];
</syntaxhighlight>
 
It's also possible to install Firefox via [[Home Manager]]:
 
<syntaxhighlight lang="nix">
# 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:
home.packages = with pkgs; [ firefox ];
</syntaxhighlight>
 
See: [https://rycee.gitlab.io/home-manager/options.html#opt-programs.firefox.enable Home Manager's manual].
 
=== Non-NixOS ===
 
<syntaxHighlight lang="console">
$ nix-env -iA nixos.firefox
</syntaxHighlight>


== Tips ==
== Tips ==
Line 31: Line 10:
== Other Firefox Editions ==
== Other Firefox Editions ==


Nixpkgs also offers other variants of Firefox aside from the ones stated above - these may suit your needs more comfortably than vanilla Firefox.  
Nixpkgs also offers other variants of Firefox aside from the ones stated above; these may suit your needs more than vanilla Firefox.
To choose a variant, set <code>programs.firefox.package</code> accordingly.


'''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.
'''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.
Line 37: Line 17:
=== Wayland ===
=== 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.  This can help with a number of issues such as phantom scrolling.
Users running a Wayland compositor (such as [[Sway]]) may want to use a Wayland-compatible build of Firefox (<code>firefox-wayland</code>).  This can help with a number of issues such as phantom scrolling.


==== Screen Sharing ====
==== Screen Sharing ====
Line 43: Line 23:
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).


* Use <code>firefox-wayland</code>, e.g.:<syntaxhighlight lang="nix">
* Use <code>firefox-wayland</code>
# 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
programs.firefox = {
  enable = true;
  package = pkgs.wrapFirefox pkgs.firefox-unwrapped {
    extraPolicies = {
      ExtensionSettings = {};
    };
  };
};
</syntaxhighlight>
* Enable [https://pipewire.org/ PipeWire]:<syntaxhighlight lang="nix">
* Enable [https://pipewire.org/ PipeWire]:<syntaxhighlight lang="nix">
services.pipewire.enable = true;
services.pipewire.enable = true;
Line 77: Line 41:
# Classical NixOS setup
# Classical NixOS setup
environment.sessionVariables = {
environment.sessionVariables = {
  MOZ_ENABLE_WAYLAND = "1";
  MOZ_ENABLE_WAYLAND = 1;
  XDG_CURRENT_DESKTOP = "sway";  
  # only needed for Sway
  XDG_CURRENT_DESKTOP = "sway";  
};
};


Line 84: Line 49:
home.sessionVariables = {
home.sessionVariables = {
   MOZ_ENABLE_WAYLAND = 1;
   MOZ_ENABLE_WAYLAND = 1;
  # only needed for Sway
   XDG_CURRENT_DESKTOP = "sway";  
   XDG_CURRENT_DESKTOP = "sway";  
};
};
</syntaxhighlight>
</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.:
* Ensure that the environment variables are correctly set for the user systemd units. E.g.:<syntaxhighlight lang="bash">
<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>


===Firefox ESR===
===Firefox ESR===
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.
<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.


===Mozilla Distributed Binaries===
===Mozilla Distributed Binaries===
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.
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 (such as <code>firefox-bin</code>). This will download the binary from Mozilla's servers.


===Firefox nightly===
===Firefox nightly===
Nightly builds are daily builds of Firefox from the Mozilla-central repository
Nightly builds are daily builds of Firefox from the Mozilla-central repository.


To use them
To use them
Line 115: Line 80:
     nightlyOverlay
     nightlyOverlay
   ];
   ];
environment.systemPackages = with pkgs; [ latest.firefox-nightly-bin ];
programs.firefox.package = pkgs.latest.firefox-nightly-bin;
</syntaxhighlight>
</syntaxhighlight>


== FAQ ==
== FAQ ==


=== How to run Firefox without pulseaudio and still get audio output? ===
=== How do I use ALSA with Firefox instead of PulseAudio? ===
 
Replace libpulseaudio by libpressureaudio, which uses apulse to emulate PulseAudio but uses ALSA directly. So, you don't need to install/enable pulse audio.
 
<syntaxhighlight lang="nix">
{ 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>.


When using [[Home Manager]], add the following to your configuration:
<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 { };
Line 141: Line 96:


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>.
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>.
=== Firefox ESR and Oracle JDK ===
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.
Firefox stops support of Java plugin. To use Java plugin you have to use special Firefox ESR, Extended Support Release.
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.


== Tips ==
== Tips ==