NixOs 21.05
A complete working distro created from a single configuration file sounds different, and Neil Bothwick discovers that it is.
A complete working distro created from a single configuration file. It sounds different, and Neil Bothwick discovers that it is.
Installing Linux is usually a matter of: boot from install media, run installer, make choices, drink a hot beverage, reboot computer and start configuring everything to your needs. NixOS turns this completely on its head.
The starting point for NixOS is a configuration file called configuration.nix. This is where you specify everything about how you want your system set up, from which partitions to install to and the filesystems to use, to the list of packages to install and the users to create. You have to create the partitioning yourself – Gentoo users will feel at home here – then run nixos-generate-config to scan your hardware and create a basic configuration, which you then edit.
Once you have done this, run nixos-install and sit back. After it has done its stuff, you should have a ready to use system. This is a lot more work than a traditional install, especially the first time, but it has the advantage of being reproducible, and this is where NixOS really finds its place.
If you want to set up a number of information kiosks or office desktops, all with the same configuration, you only need to create the configuration file once then copy it to each of the computers and run the installer. Of course, you won’t get it right first time, and even if your needs change, you can edit the configuration and run nixosrebuild to apply your changes.
NixOS actually stores all files under /nix, so everything in the usual Linux hierarchy is a symlink to files in /nix. When you run nixos-rebuild, it create new files in /nix and updates the symlinks. The old files are still there and you can select previous incarnations from the boot menu, so you are safeguarded against an upgrade breaking something important.
This all sounds very clever, so what is the catch? It is that much of what you know about administering a Linux system does not apply. Want to export a filesystem by adding it to /etc/exports? You can’t – that file is readonly, as is most of /etc. Instead, you add the relevant entries to configuration.nix and rebuild.
The problem is that, at least at first, everything takes three times as long to do because you have to search the documents and forums for the way to do it, because of the alien nature of NixOS. This is different from, say, Gentoo, where you have to edit files by hand, but it is all standard stuff. Thankfully, there is detailed documentation, with examples, of all the configuration options, as well as a comprehensive package list, in a searchable format on the website.
When it comes to installing packages, the configuration file is not the only route. That installs packages globally, just like other package managers, but there is also the nix-env command that can be used to install software and make changes at the individual user level.
As a general-purpose desktop distro, it is hard to recommend NixOS to anyone but an enthusiast. However, as a means to create custom environments, repeatable across multiple machines, NixOS has a lot going for it.
Yes, you could do the same with Debian and a configuration manager like Ansible or Puppet, but there is a certain elegance to the NixOS way of doing things.
It is not so much a distro as a way of creating and installing your own custom distro.
Is this a good distro? That’s a really complicated question. For most users the answer has to be no, but if you need to create multiple instances of the same, or a similar, system, and maintain them easily, it may be just what you are looking for. Just be prepared to put it some time getting it all set up first.