When categorizing Linux distributions, it is often useful to specify which package management system the distribution uses. There are many different package management systems in use, but the two most popular are probably the .deb and .rpm formats. The first comes from Debian and is used by Ubuntu, while the second was developed by RedHat.
NixOS is a Linux distribution with its own unique package manager. The entire operating system, including the kernel, applications, system packages and configuration files, are built by the Nix package manager. The Nix Package Manager uses a declarative system configuration model. This means system configuration items are described in a configuration file, and the OS does everything necessary to make the configuration happen.
If a system admin wants to install a SSH server, then all they need to do is add a line to the configuration to enable that service. NixOS will then download and install OpenSHH, plus generate the relevant configuration files.
Another interesting feature of NixOS is that it stores all its packages in isolation from each other; as a result there are no /bin, /sbin, /lib or /usr directories. All packages are kept in /nix/store instead. This, together with the declarative configuration model, makes upgrading NixOS systems reliable and allows the OS to implement a transactional approach to system management including the ability to roll back upgrades.
The declarative configuration model also makes it easy to reproduce a system configuration on another machine. The admin just copies the configuration file to the new NixOS machine and with one command, the machine will be transformed to use the same kernel, applications, system services, and so on.
To try out NixOS, download the .ISO file from the project's download page, burn it onto a CD and boot your PC from it. Once booted, you will be presented with a text login prompt. Enter "root" as the username and press ENTER. The NixOS installer doesn't do any partitioning or formatting, so you need to create and format the partitions manually.
Note: The following commands will erase EVERYTHING on the disk; please proceed with caution.
Where "/dev/sda" is the name of the disk you want to use, in this case the first hard disk in the PC.
In fdisk, type "o" to create an empty partition table. Type "n, p, 1, ENTER, +2G, t, 82" to create a new primary partition of 2Gb to be used as swap space. Now type "n, p, 2, ENTER, ENTER" to create a new primary partition for the NixOS installation. Exit out of fdisk using "w". If you want to use the free space on the disk without erasing the existing data, then don't create an empty partition table and modify your partitioning scheme accordingly.
Once the installation has completed, reboot your system. You will need to remove the CD or pick the "Boot from hard disk" option if you booted from the optical drive.
The system should boot into the display manager; however, you can't yet log in as there are no users defined, and root logins aren't allowed on the desktop. Press CTRL+ALT+F1 to switch to a console.
You should also change the root password using "passwd".
Press CTRL+ALT+F7 to get back to the graphical login prompt and log in with the username and password you created above.
The way we added the user and the way we installed Firefox is called imperative management. You execute a command and it happens. However the power of NixOS is in its declarative management. With declarative management, the system administrator tells NixOS what needs to be achieved, and NixOS will ensure that it happens without breaking the system.
This command does everything necessary to make the configuration happen, including downloading Thunderbird and creating the new user etc.
The power of NixOS is formidable. If you want to go deeper then you should look at the NixOS manual, and if you need help you should try the NixOS community page.
Can the disk partitioning done ahead of time with GParted, or does it have to be done with fdisk as part of the install?
You can do it with any partitioning program, there just needs to be valid partitions for the install to proceed.
Thanks! I've been really interested in NixOS but haven't had a chance to play around. Great article, this is exactly the stuff I most enjoy from MTE.