Nix series: Why nix?

 

I started using Nix, predominantly because of a (rather) insistent good friend. We’re both interested in reproducible science, and I see nix as an (often complementary) alternative to Docker. As the title suggests, this isn’t a post on How, but Why; I’ll include some snippets of my config, but the rest will be left up to other posts. Here are some of the purposes nix fulfills in my workflow:

 

Nix is GNU stow+

 

The evolution of my individual development environment configuration began with a .txt file, stopped off at a series of shell scripts, and ended with nix. I’m not going to lie, I have not saved time with this. In fact, it’s been a complete time waster. Don’t repeat my mistakes and overoptimize your work flow, it usually means your daily work is boring enough that you find time to procrastinate on things to “enhance productivity”.

 

That being said, nix is the best way to manage and keep personal configuration files and useful CLI applications up to date. Ryan Mulligan has done phenomenal work on nix PR automation, so most application are updated very quickly. Similarly, Graham Christensen has been developing ofborg which automatically builds and tests most PRs before merged. Consequently nixpkgs is both up-to-date and tested.

For packages that aren’t in the nixpkgs repository (nightly builds of neovim for example) overlays versioned with NIV allow me to compile and build certain packages locally as part of my updated cycle. Together, my nix config gives me the latest and greatest text editors, language servers, and CLI tools all kept in synchronization across macOS and Linux (workstation and cluster). These tools live in parallel to brew, dnf, pacman, etc. installed packages.

 

Furthermore, home-manager allows me to store “versions” of my user profile, so worst-case scenario, if one of my packages has a bug, I can easily roll back to a prior version (disclaimer, this feature is nice, but in reality I’ve never had to use it since nixpkgs is very stable for the applications I use).

 

Nix is a more space efficient Docker with explicit package versioning

 

Why not nix?