Linux Format

NixOs 21.05

A complete working distro created from a single configurat­ion file sounds different, and Neil Bothwick discovers that it is.

-

A complete working distro created from a single configurat­ion 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 configurin­g everything to your needs. NixOS turns this completely on its head.

The starting point for NixOS is a configurat­ion file called configurat­ion.nix. This is where you specify everything about how you want your system set up, from which partitions to install to and the filesystem­s to use, to the list of packages to install and the users to create. You have to create the partitioni­ng yourself – Gentoo users will feel at home here – then run nixos-generate-config to scan your hardware and create a basic configurat­ion, 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 traditiona­l install, especially the first time, but it has the advantage of being reproducib­le, and this is where NixOS really finds its place.

If you want to set up a number of informatio­n kiosks or office desktops, all with the same configurat­ion, you only need to create the configurat­ion 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 configurat­ion and run nixosrebui­ld 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 incarnatio­ns from the boot menu, so you are safeguarde­d 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 administer­ing 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 configurat­ion.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 documentat­ion, with examples, of all the configurat­ion options, as well as a comprehens­ive package list, in a searchable format on the website.

When it comes to installing packages, the configurat­ion 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 environmen­ts, repeatable across multiple machines, NixOS has a lot going for it.

Yes, you could do the same with Debian and a configurat­ion 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 complicate­d 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.

 ??  ?? NixOS is well documented, and it needs to be. Just look at the number of configurat­ion options!
NixOS is well documented, and it needs to be. Just look at the number of configurat­ion options!

Newspapers in English

Newspapers from Australia