Install Nix
Nix is a tool that allows us to create a shared, reproducible development environment. This makes sure we have the same versions of the same tools available to us, no matter what computer we are using.
Nix manages our tools like sops for handling secrets or terraform for managing infrastructure. We also use nix to define custom commands in the developer shell that make development more approachable.
Nix also builds our NixOS configurations, the operating system running on our servers. There are multiple implementations of Nix, we prefer Lix because of its user-friendliness. Installing Nix and other tools will take up some disk space, make sure you have at least 15GB free.
Nix on NixOS
If your computer runs NixOS, Nix is already installed. You can switch to Lix, but other Nix implementations should work as well.
Nix on other Linux distributions
If your computer runs any other Linux distribution, you can most likely install Lix
curl -sSf -L https://install.lix.systems/lix | sh -s -- install
Any other Nix implementation should work as well.
Nix on MacOS
If your computer runs MacOS, you can most likely install Lix
curl -sSf -L https://install.lix.systems/lix | sh -s -- install
Note: older MacOS versions may not be supported. Make sure you’re on the latest major version of MacOS.
To build NixOS images, you’ll need a Linux builder. The easiest way to set one up is to use nix-darwin. Determinate Nix also includes a Linux builder but requires account registration and a request to enable the feature. A more thorough MacOS guide coming soon.
Nix on Windows
Nix on Windows requires WSL. You can run NixOS on WSL, or install Nix on any other Linux distro inside WSL, such as Ubuntu.
Nix on Ubuntu in WSL
wsl --install -d Ubuntu-26.04in Powershell- Start Ubuntu terminal in Windows Start Menu.
curl -sSf -L https://install.lix.systems/lix | sh -s -- install
NixOS on WSL
wsl --install --no-distributionin Powershell- Reboot the machine for settings to take effect.
- Download nixos.wsl from here
- Double click the downloaded file (should be about 500MB in size)
- Start NixOS terminal in Windows Start Menu.
Verify Your Setup
To verify your Nix setup, run
nix-shell -p hello --run "hello"
This is enough to build the website and docs using the Nix environments defined in those projects.
Building NixOS images is required for deploying and updating servers. To verify that you can build NixOS images, run
nix-build '<nixpkgs/nixos>' -A config.system.build.toplevel --arg configuration '{ fileSystems."/".device = "/dev/sda1"; fileSystems."/".fsType = "ext4"; boot.loader.grub.devices = [ "/dev/sda" ]; }'