Notes about NixOS

I started using NixOS on bare metal from like a month or so. In my opinion it is a fascinating system with a lot of interesting ideas which are two sided swords: The things that makes this system are also the one that make it infuriating.

In my opinion it makes worth for a try, but that's the opinion of somebody with mathematical background who likes functional programming languages and esoteric paradigms. I'll try to fill these notes with what exactly makes NixOS, beside opinions. This is the second time I write this gemlog and I found out that I was transforming my notes into a formal introduction to the system. While writing it i was confused by certain aspects and then I realised: I'm not competent enought to explain well how this system works. So I decided that notes will be good enough for now and I can write more about later on.

Installation

You just flash a usb key and start the installation. This operation doesn't feel different from any other linux distribution. I suppose NixOS leave you the option to install a system based on a file, but I can't confirm, I wasn't looking around for that.

Once the installation is finished you should have a system with (or without) a desktop environment. NixOS from the installer provides various DEs like KDE, GNOME, XFCE, lxQt, Enlightenment etc.

Usability

By default the system works like the next distribution. If you are a standard user you don't have much to worry about. Unluckily flatpak is not installed by default, so your plain old linux distribution feel ends here, when you need new software. Soooo

I need more software

The where the rabbit hole starts. To just install software you go into /etc/nixos/configuration.nix and edit the file:

environment.systemPackages = with pkgs; [
  vim
  git
  # et cetera...
]

Just add whatever you want in this list (defined by the square brackets [ ]) and then run

$ sudo nixos-rebuild switch

And you are done. Now the software is installed and usable.

Documentation

Installing and using NixOS is not hard, but you pass over many of the "details". These details can be explored from the official and unofficial documentation. On graphical system it is available the NixOS Manual with configuration basics and guides for various tools and software (like flatpak, postgreSQL, etc.). Then online you can find the nix.dev tutorials and nixos.wiki. This manuals explain many of the concepts of NixOS, but many points require a good knowledge of the nix programming language and the nix package manager architecture (and functions). Like for example "overlays":

Overlays provide a method to extend and change nixpkgs. They replace constructs like packageOverride and overridePackages.

Then it follows making various schemes, explainations and examples. These can be comprehensive but require a lot of attention and patience to be understood. You got in this page because you want to install your version of emacs and now you have to understand how these overlays will help you. They will, if you get in the NixOS mindset: Rather than compile your software one time, you patch the whole nix so when you ask to install emacs normally, it automatically download, compile with your flavours and install it. This makes emacs easy to install or to use in temporary shells

Software

One final point: The software looks pretty good. The Nix package manager should replace all the middleman package managers that takes the roles of APT and DNF (which is good because they usually fill your system with hard to track and uninstall stuff). NixOS replaces these managers with a huge collection of software. Making possible to prime a nix shell just to test some software in other distributions makes manual and tedious work.

The rabbit hole

NixOS goes really really deep with all of its concept. its strong mathematical imprint makes for many concepts with various usages and qualities. Hitting your head on things like "Derivations", "Shells", "Profiles", "Generations", "Overlays", "Flakes" you wonder why you need to use Nix. It looks like NixOS makes everything more complex, it is like your university calcolus course in your sysadmin life.

I think NixOS requires patience. Like in mathematics, many concepts seems abstract but are made to fulfill specific needs and to solve problems. It is good to start simple, maybe on a virtual machine, and to experiment in doing what sysadmin do on their regular linux boxes.

I think I will learn about Derivations and Overlays next. I'll keep you updated on that.

CYA