The most dreadful part about commissioning new Linux computers is configuring it. A sequence of commands, a random 10-year old tutorial on Stack Overflow, a completely bogus SEO article; we all know how it goes.
- What if there was a better way?
- What if, in the same way you program in Python, for example, you could program your operating system?
One single file (if you want) to set up your browser, your development environment, and all the particularities and little pesky configurations that make your computer “truly yours.”
Meet Nix and NixOS.
NixOS, through a system-wide configuration file, lets you dictate what you want to install in your system, configure your applications, and look good while doing it.
Nix, in unison with the former, is a package manager, equally declarative, that lets you specify how your custom applications and development environments need to be set up. NixOS pulls recipes for its gigantic list of available applications from a repository of Nix recipes maintained by the community on GitHub. But that’s not all! Every Nix package can pin their own versions of dependencies, and they will be each pulled individually to what’s called Nix Store, where all your binaries, libraries, and referenced files will go.
Now you ask me:
That’s nice and dandy. Isn’t this what Ansible is for though?
And you are right, but Ansible offers several disadvantages compared to Nix, although with some important advantages.
Disadvantages
- Ansible relies on the old package managers of yesterday. This means that there is not a saving grace for dependency hell, and all the limitations inherent of the most popular distros still apply.
- The configurator for Ansible can write the configuration files for our applications, but they are still allowed to be edited manually. In my opinion, this is bad! Nix, on the other hand, keeps configuration files read-only, so any changes are forced to go through the declarative configuration file.
Advantages
- The institutional backing of Nix and NixOS pales in comparison to Ansible. The latter is used by many of the big companies and is a common word in job description pages; not so much popularity for Nix.
- NixOS enforces the Nix package manager, while Ansible wraps around many different package managers. There is an argument to be made that Ansible is more flexible because of that.