NixOS 20.03NixOS is a Linux distribution with a special approach to package and configuration management. NixOS is built on top of the Nix package manager which is declarative and makes upgrading systems reliable by way of atomic updates and package snapshots. Nix also provides the ability to roll forwards and backwards through package snapshots, which it calls generations, allowing the administrator to rollback changes or move forward through available versions. Since package transactions are atomic this means upgrades and installations will not break the operating system if a crash or power failure occurs. The administrator can simply revert back to the original snapshot of the installed packages.
Nix can use declarative configuration, meaning we can use the same system configuration file on multiple machines to have them all set up the same way without needing to use disk cloning.
There are over 60,000 packages in the Nix repository. Since Nix can be installed on most Linux distributions, this provides a great repository of software to any distribution where we care to install the Nix package manager.
Back in 2017 I talked about running Nix on Debian. Back then the Nix repository had just 12,860 packages. The repository has grown but the tips on installing and running Nix have remained the same.
There are two editions of NixOS. The first is the Graphical edition which is a 64-bit (x86_64) build and features the KDE Plasma desktop. The Graphical edition is a 1.2GB download. The other edition provides a minimal, command line interface. The smaller edition is available in 32-bit and 64-bit builds and its ISO is approximately 550MB in size.
The latest version of NixOS includes mostly package updates, bringing KDE Plasma and GNOME up to date with their stable upstream versions. ZFS now performs automatic trimming on appropriate storage devices. Meanwhile the Nix package manager recognizes a wider range of services and programs we can enable.
I decided to try the Graphical edition of NixOS. Booting from the media brings up a menu where we are invited to start the live Plasma desktop with one of three options: normal boot, failsafe mode, or running the distribution from RAM. Selecting any of these options loads the KDE Plasma desktop. A panel holding the application menu, task switcher, and system tray sits at the bottom of the screen. Icons on the desktop launch GParted, open the Konsole virtual terminal, and open the NixOS manual. The manual is a locally stored web page that opens in Firefox. The manual is especially helpful and covers tips on using and installing the operating system. Since NixOS does not have a system installer in the usual sense, I recommend reading the manual to learn how to get started with the operating system.
NixOS 20.03 -- Reading the NixOS manual in Firefox (full image size: 215kB, resolution: 1366x768 pixels)
When it comes to installing NixOS the manual points out a few things we need to do up front. For example, we need to have a working Internet connection. We also need to set aside at least one disk partition and format it. These steps are not handled for us, but NixOS includes networking tools and the GParted partition editor to help us.
Once we have the necessary partition, we need to mount it under the /mnt directory and edit the Nix configuration file. This file explains to Nix how to set up the operating system, it's like a recipe. Luckily for us, the file is mostly filled in with good default values. There are also a lot of optional features listed in the file in comments. This allows us to simply edit the existing lines to enable some common services and set up a user account.
Once we have edited the Nix file we run an install script which sets up the operating system, based on the rules outlined in the file. We are also asked to make up a password for the root account. At this point the system is all ready to go and we can reboot to give our local copy of NixOS a try.
Launching my fresh copy of NixOS brought up a graphical login screen. By default the login screen assumes we want to sign in as the first non-root user. However, at this point I hadn't had a chance to set a password on the account and could not sign in as my regular user. We can switch to a console or click a button at the bottom of the screen to login as root and set the user's password.
NixOS 20.03 -- The Plasma desktop and application menu (full image size: 492kB, resolution: 1366x768 pixels)
Once I signed in as my regular user a KDE Plasma session started. The interface features a light theme with a panel at the bottom of the screen, as it was in the live session. The desktop icons for GParted, Konsole, and the manual are gone. The manual is still installed, we just need to browse the application menu to find it. Also missing is the Firefox web browser. Firefox is present in the live session, but is not included in the installed version of NixOS meaning we cannot open the manual to read it in a browser. We can add a web browser later using the Nix package manager and I will talk about Nix later.
I began testing NixOS in VirtualBox and found the system generally worked well. Desktop performance was good and the system was stable. Loading programs and launching the Plasma desktop was slower than average, but the desktop was otherwise responsive. While running in VirtualBox, the Plasma desktop would not resize automatically when I changed the dimensions of its window. However, I could change the desktop's resolution from the System Settings panel. (To be more precise, I could not resize the Plasma desktop at all using VirtualBox's default video settings. I had to switch from VMSVGA to the VBoxVGA controller in my host's settings to be able to resize the desktop.)
When I tried running NixOS on my laptop, the distribution performed well. Programs loaded quickly, my full screen resolution was used, and wireless networking was recognized.
NixOS 20.03 -- Exploring the settings panel with a dark theme (full image size: 424kB, resolution: 1366x768 pixels)
A fresh install of NixOS is relatively light, using about 370MB of memory when signed into the Plasma desktop. A new install consumed about 4.1GB of disk space. Most of the time, NixOS did not use much CPU though some package management actions used more CPU and disk I/O and could slow down the desktop.
A fresh install of NixOS with a default configuration includes very few desktop applications. Apart from the Konsole virtual terminal, the KDE Help documentation, and the System Settings desktop configuration panel, there isn't much to be found.
There is no compiler, no web browser, no office suite. In the background we find the usual collection of GNU command line utilities and manual pages. The systemd software is installed and provides the distribution's init program. A fresh install runs on version 5.4 of the Linux kernel.
While running NixOS I noticed that typing the name of a command into the terminal that has not yet been installed causes a message to appear telling us what Nix command we need to run in order to install the missing program. This happens quickly and did not cause much disruption to my workflow.
Early on I found that any time I tried to connect to a new wireless network the system would prompt me for a wallet password. This is an annoying feature and it meant I sometimes had to try to connect multiple times to a new network before the system would accept my wi-fi password without corresponding wallet password.
While it is possible to use NixOS as a day-to-day operating system, it largely exists as a platform to show off the powerful Nix package manager. For the most part, using Nix feels like using most other command line package managers. We can run "nix-env -i <package name>" to install new software, "nix-env -e <package name>" to remove an item. The "nix-env -u" command updates software and "nix-env -qa <pattern>" searches for software. While the commands we run look familiar and produce similar results to the equivalent APT and pacman actions, Nix does several things differently.
NixOS 20.03 -- Installing new software and browsing package generations (full image size: 216kB, resolution: 1366x768 pixels)
For instance, Nix installs are atomic, meaning that if the power cuts out partway through an upgrade, nothing bad happens to your packages or the package database. We can just restart the computer and begin the process anew. Another intriguing feature is Nix creates snapshots of its packages. These snapshots are called generations and each time we install, remove, or upgrade software, Nix effectively takes a snapshot of the software we have installed. We can then move almost instantly between package snapshots. In practice, this means we can rollback any change that breaks the system or introduces a bug by running "nix-env --rollback".
We can also move forward into newer snapshots. This is especially handy if we want to test two versions of the same software. We can run the application, rollback to a previous version, then instantly move ahead to a newer snapshot to test the new version again. We can see a list of available snapshots by running "nix-env --list-generations".
One concern some people have about Nix is that these generations will use up extra disk space. However, the extra space is pretty minimal, at least in the short term. The extra space is not even noticeable after a few weeks of installing updates. For those concerned about disk space though we can discard old generations to free up space.
Another nice feature of Nix is that it handles the configuration of the operating system, not just packages. This, combined with Nix's reproducible builds, means we can take the configuration (recipe) file from one computer and use it to install NixOS on another computer. We should end up with identical operating systems on each machine.
In short, Nix is an amazing package manager. These features, along with the ability to run along side other package managers on other distributions, make it a very attractive tool. It does have a few problems though. I found Nix was sometime slow compared to other mainstream package managers and it does not show much progress information. This sometimes makes it look like the nix-env command has stopped working. In fact, it took me a while once to realize the desktop had locked up and stopped responding once when Nix was installing software updates. However, these small issues aside, Nix is quite powerful and useful, especially for people who need extra reliability or who want to be able to quickly rollback software changes.
The NixOS distribution, on its own, does not particularly stand out. Apart from the fact it has a very minimal, and very memory-friendly KDE Plasma session, the distribution (from a practical point of view) does not do much to attract users. NixOS mostly functions as a platform to show off Nix and demonstrate how a distribution can be shaped, managed, and even replicated through its package manager.
The Nix repository has grown by leaps, adding tens of thousands of new packages in the past three years. These packages are reproducible, are installed and upgraded atomically, and can be rolled back (or forward) almost instantly. The Nix approach to keeping software transactions safe while making it easy for us to switch between installed versions of programs makes it very attractive.
In recent years some filesystems, like Btrfs and ZFS, have also added snapshots at the filesystem level, rather than the package manager level. This, to my mind, takes a bite out of one of Nix's main selling features. However, Nix can work with any Linux filesystem, avoiding the overhead of advanced filesystems, and works independently of the distribution (and any other installed package manager). This makes Nix a very attractive way to gain access to more software and provides a way to experiment with new packages with minimal risk. Whether you try NixOS or not, I highly recommend installing and trying Nix, especially if you keep up to date with cutting edge packages and want to protect your system from regressions due to upgrades.
* * * * *
Hardware used in this review
My physical test equipment for this review was a de-branded HP laptop with the followingspecifications:
Processor: Intel i3 2.5GHz CPU
Display: Intel integrated video
Storage: Western Digital 700GB hard drive
Memory: 6GB of RAM
Wired network device: Realtek RTL8101E/RTL8102E PCI Express Fast