NixOS: 6 months later

23 Jan 2023

NixOS is not just another Linux distribution. NixOS allows you to specify the desired state of your system via a configuration file (written in the nix language). This can include programs to install, services to enable, to specify program configuration, install drivers, etc.

This is huge. I no longer need to keep instructions and bookmarks to reproduce my custom sway setup on an nvidia laptop. I can reproduce my system on a new machine as fast as I can type:

git clone
cd dotfiles
sudo nixos-rebuild switch --flake .

I no longer need to remember commands needed to set up trivial things like NVIDIA drivers, or how to create a systemd service, configure audio, setup video acceleration, etc.

You do not modify a declarative system through commands. You write a config from which that system gets built:

If you accidentally removed your video drivers, or messed up a crucial config, don’t worry. NixOS keeps old versions of your system and lets you select which to use on boot. I have never felt scared of messing up on NixOS because of that. And this is not something I could say when working on Arch or even Fedora before.

My system never feels bloated. All installed programs are declared in the single file. Besides, NixOS encourages using the nix shell and nix develop to specify project-specific programs needed. That means that even as I primarily use go for programming, I don’t even have it installed on my system.

$ go version
go: command not found
$ cd p/hello-world
$ nix develop
$ go version
go version go1.19.3 linux/amd64

What’s cool is that nix develop automatically gets enabled as I cd into the directory via direnv! Nix develop is just creating and entering a new shell with programs in path, thanks to nix shell.

You don’t even have to switch to NixOS to benefit from the Nix Shell. Packages work independently, meaning that you can share your project-specific flake.nix with non-NixOS users and they can have the exact same reproducible shell as you.

Nix has A LOT of packages. In my personal experience, it is on par with Arch. Sometimes you might want to try an obscure package with build instructions you don’t want to bother adapting to Nix. In cases like this, don’t be discouraged from using NixOS. Just use distrobox1: a wrapper around podman that makes it really easy to spawn containers that run a distro of your choice.

Nix versioning is as reliable as it gets. Nix generates a flake.lock file that stores exact versions of each package, allowing you to upgrade and downgrade reliably without having to rely on the distribution update cycle.

The cost of Nix? There is a steep learning curve. The nix language might not be everyone’s cup of tea. Some build instructions require extra setup (for example with dynamically-linked libraries).

Is it worth it? I am daily driving it on my laptop as well as the server hosting my personal website. The source code for the latter is private, but feel free to check out my dotfiles2.