Perhaps you haven't heard of Nix yet. Quite possible, why would you? Package management is a solved problem, we have systems like RPM/DEB with many happy users. Actually, I used to be one of them, about 10 years ago.
Even though at the time I was a happy Debian user, some things bugged me.
- Upgrades would break existing software
- Crashes during upgrades cost me many nights of sleep, needing to re-install
- Configuring my system was a list of actions that I had to do over and over again. Scripting didn't help much.
- Writing my own .deb packages was extremely tedious
So let me tell you a bit about Nix, and what it helps me with. The website mentions:
Nix is a purely functional package manager.
What does this mean? Well, it means that it treats packages like values in purely functional programming languages — they are built by functions that don’t have side-effects, and they never change after they have been built. In stead of putting everything in a global /usr, Nix stores all of its packages in a separate location on the filesystem. How this is all implemented is explained in detail on the Nix website, I can't do that better than what is explained there. For this post I am more interested in what Nix brings to the table for me:
- Multiple versions: I can install multiple version of any program with the guarantee that I don't break existing
- Complete dependencies: Nix makes sure that I specify all dependencies, and manage the dependencies for me, mostly automatically
- Multi-user support: Installing software as a non-root user was always tedious, Nix allows users to install software in a safe way
- Atomic upgrades and rollbacks: Nix allows me to cancel and resume an installation/upgrade at any time without the dangers of breaking existing packages/configurations
To summarize the main reasons why I use Nix.
Nix protects me against me
I break stuff, a lot, I am sure you do too. Experimenting with newer kernel, new libraries, we all do it. But only when I started using Nix (and NixOS) I haven't wasted any more time re-installing my system. Rollbacks are awesome!
Nix let's me do things multiple times consistently, even on different machines
So much time wasted trying to figure out what are the differences between two machines. Works for me! Not for him! This happens in both builds as well as deployments. Even though we often prefer to ignore it, any dependency can actually break your system, even the low level dependencies such as kernels. Managing and tracking these dependencies will give us better reproducability, as well as traceability, allowing us to see the complete and exact changes that might have caused a system to fail.
Nix exposes the things I forget
When creating software you deal with software dependencies. It is easy to add a dependency on an external package or program, and forgetting about it. It often happens that such dependencies are introduced without anyone realizing, usually, because it is a piece of software that is commonly available, and thus works on most machines. Obviously, you will pay the price at some point. However, Nix forces me to specify all dependencies and my builds will fail when I fail to do so. Don't get me wrong, this can be extremely annoying at first, but once everything is working, at least for me, it gives me comfort in knowing all my dependencies and that I don't need to worry about them anymore.
Nix, the one language to rule them all
One thing I especially like about the Nix eco-system, is that I can use the same language for everything. I use it to set up my build environment for packages I am working on, defining my continuous integration builds in Hydra, managing my system configuration (NixOS), as well as my multi machine deployments in the cloud (NixOps).
In my opinion, having one language has made it easy to contribute to all of the Nix ecosystem.