How to install Firefox Nightly on NixOS
Like some other Linux distributions, NixOS supports the use of overlays.
I am actually not very familiar with how overlays work on NixOS. So, for the sake of simplicity, we will just think of them as being similar to PPAs on Ubuntu. Except, instead of being a custom repository of downloadable packages, NixOS overlays are more like scripts that instruct the package manager on how to download and build additional packages (or just about anything, really).
You might be wondering why you cannot just download the official Firefox Nightly release straight from Mozilla, extract it, and use that.
Indeed, that is how I have always installed Firefox Nightly on other Linux distributions (it even automatically updates itself!), but I was unable to get it working on NixOS, hence the overlay. (You might have better luck though.)
Thankfully for us, the overlay we are going to use is actually maintained by Mozilla:
Located in this repository is a firefox-overlay.nix
file, which is what we will use to fetch our Firefox Nightly binary. Go ahead and clone this repository onto your computer.
Once you have cloned the repository, you will need to make a couple of edits to your configuration.nix
file in /etc/nixos/
.
First, you will need to add the line nixpkgs.config.allowUnfree = true;
if you want to use the binary Firefox packages and avoid having to compile them yourself (which I do not recommend doing, unless you have beefy hardware and a lot of free time).
(The binary packages are considered "unfree" because of the Firefox trademark.)
Second, you will need to add another line to your configuration.nix
file that declares the firefox-overlay.nix
file, from the repository you cloned, as an overlay. That can be accomplished with this line:
nixpkgs.overlays = [ (import /path/to/firefox-overlay.nix) ];
Finally, assuming you have done everything correctly, the last thing you will need to do is add a line declaring a Firefox package to install. Since this blog post is about installing Firefox Nightly, we will add this line to our systemPackages
list, alongside the rest of our system packages:
latest.firefox-nightly-bin
In the end, your configuration.nix
file should end up with three new lines:
nixpkgs.overlays = [ (import /etc/nixos/firefox-overlay.nix) ]; nixpkgs.config.allowUnfree = true; environment.systemPackages = with pkgs; [ latest.firefox-nightly-bin ];
(I symlink my firefox-overlay.nix
file to /etc/nixos/
, but you can put it just about wherever you want. )
And that should be it! Just run a nixos-rebuild
command to bring your system in-sync with your configuration.nix
file and Firefox Nightly should then be installed and usable.
Shout out to the anonymous, deleted GitHub user who posted a comment on one of the overlay repository's issues. This was a very simple, very elegant solution. Unfortunately, it took me a long time to find this solution and I ran into quite a few people who were doing the same thing, but with vastly more complex configurations.