3 min read

NixOS Linux review, is it really the alternative to Debian and Archlinux ?

NixOS 23.05 is a really impressive Linux distro, it is stable as Debian stable and updated as Archlinux.

NixOS Linux killer features

  • Declarative: in normal Linux distro you configure the operating system with a sequence of commands, in NixOS you describe the configuration state in a configuration.nix file. It means that you can recreate and kept update the same OS configuration easly in VMs or bare metal servers. No more exotic bugs because you forget a step.
  • Rollback without BTRFS: NixOS keep old libraries and software in the OS via symlinks so if something bad happens you can rollback to a previous working configuration. No more inconsistent updates, just atomic updates! NB: it isn't a full backup alternative, if the updates execute a database migration you have to use a backup of the previous version to do the rollback
  • Rolling release or point release? NixOS has a huge list of packages supported and you can choose as base the stable channel like nixos-23.05 or nixos-unstable.

Nix flake is magic

There is a lot of documentation in the official website or NixOS Wiki, but all the hype is towards Nix Flakes, the new way to install and update the system, it is available by default but it is marked as experimental so it's quite confusing the first set up, but it is the way to go.

Basically you need to move once /etc/nixos/configuration.nix, which was generated by the graphical installer, in a new directory. flake.nix is the entrypoint, while flake.lock keep track the exact commit of your system packages and dependencies.

It's like in NodeJS with packages.json and packages.lock, you can have multiple projects/machine under git with the exact dependencies.

Real world usage

Let's start updating the packages index, the equivalent of apt update is nix flake update which updates the flake.lock to the latest version available as package base.

$ nix flake update
warning: updating lock file '/home/user/mysystem/flake.lock':
• Updated input 'nixpkgs':
    'github:nixos/nixpkgs/d8bb6c681cf86265fdcf3cc3119f757bbb085835' (2023-07-07)
  → 'github:nixos/nixpkgs/8df7a67abaf8aefc8a2839e0b48f92fdcf69a38b' (2023-07-09)

Then you can update configure.nix if you want add or remove some software. Here is my Nix flake I'm using.

When you are satisfied with the changes you can preview and or apply the changes with nix-rebuild. Check the video for more details.

Using sudo is important for nix-rebuild, because you can have both system and user packages on Nix.

$ sudo nixos-rebuild dry-run --flake .#myNixos
building the system configuration...
these 40 derivations will be built:
these 70 paths will be fetched (217.38 MiB download, 659.00 MiB unpacked):

OK, these are the changes will be applied you can proceed with nixos-rebuild switch

$ sudo nixos-rebuild switch --flake .#myNixos
building the system configuration...
stopping the following units: accounts-daemon.service, systemd-udevd-control.socket, systemd-udevd-kernel.socket, systemd-udevd.service
NOT restarting the following changed units: display-manager.service, systemd-fsck@dev-disk-by\x2duuid-C3C0\x2dB94C.service
activating the configuration...
setting up /etc...
reloading user units for user...
setting up tmpfiles
reloading the following units: dbus.service
restarting the following units: polkit.service
starting the following units: accounts-daemon.service, systemd-udevd-control.socket, systemd-udevd-kernel.socket

Conclusion, will NixOS replace Debian/Ubuntu/RedHat/OpenSuse and other "standard" Linux distros ?

Server: "Atomic updates", "immutability" are the new buzzwords also for the Linux mainstream distros, Fedora has Silverblue, Debian has Endless/Vanilla, OpenSuse has MicroSomething, but honestly it's another paradigm, new stuff to learn, and if Debian stable + Docker Compose works for you (or another mature approch like Ansible,..) maybe you don't see an urgency, but it's worth to try NixOS for new projects.

Desktop: Archlinux AUR is fantastic, but unreliable, sometimes the software compiles, sometimes not. PPA repositories work on Debian but sometimes not. NixOS has a great balance between new software and stability but a desktop user do expect to write lines in a text file to make the Bluetooth audio work.

NixOS is a very different Linux distro, it has already benefits over classical Linux distros, stability, packages and atomic updates, but currently it's for "pro users", maybe nix flake once stable will speed up the adoption in the server space and for the desktop more GUIs are needed to enable NixOS powers also to non techie users.

You can leave a comment about this post on Hacker News