NixOSFor more than 15 years (shit am I old) I am a loyal Debian user.
Who ever had to rebuild his system and I have in the 15 years but the one or other time to do, who knows how annoying it can be to bring his system back to the state as before.
Filebackups is one thing, but the system itself is another leaf.
Since out of curiosity often times what new must be tried thus NixOS came into play.
Originally Arch Linux stood to the selection but by a small tip I changed then directly to NixOS.
The installation effort is basically similar to Arch Linux, so pure manual work including manual formatting and partitioning of the hard drive, and installing the system from scratch.
The installation instructions are available at https://NixOS.org and are really very simple and clear.
Why then want to have NixOS?
Meanwhile I want to have a system that comes along as minimalist as possible.
Sure Debian can be taken as a pure "minimalist" installation, but still has packages that are excessively large and eat unnecessary space.
The packages have of course under Debian their raison d'être but whether you want to have them is another matter.
NixOS occupies about 1.5GB.
This is neatly slim and also interesting for older hardware.
As WM comes here of course again XMonad on it. Also saves space and my fingers have already gotten used to it.
Beside the advantage of the size however still another point is crucial for my decision.
NixOS itself cites three main advantages: reproducible, declarative and reliable.
Reproducible: the nix packages are isolated from each other, this ensures that they are reproducible and have no undeclared dependencies. If a package works on one machine, it will work on another.
Declarative: With NixOS you can share development environments regardless of what language or tools.
Reliable: installing one package does not corrupt others. One can rollback to previous versions and ensure that no package is in an inconsistent state during an upgrade.
At the absolute minimum, NixOS is completely reproducible from a single config-file.
The magic "configuration.nix".
In this file on the one hand the whole system is configured and all necessary packages, like sound, Wifi, WM etc. are stored but also programs like Vim, Git, Python, GoAccess and everything you need.
That means in reverse, if one installs a NixOS on another computer and the "configuration.nix" externally gebackuped has, one copies itself these on the new system starts a Rebuild and has its past system again restored.
Easier it does not go. No more installing by hand.
If you want to run NixOS on the same system as the previous one, there is also the possibility to store all hardware specifications in the "hardware-configuration.nix".
If, for example, my T470 would give up the ghost here and I would get myself a T470 again (not such a far-fetched thought), I would only need the "configuration.nix" and the "hardware-configuration.nix" files and would have my system immediately ready for use again within a few minutes.
The only thing which must be packed then still manually on it are the dotfiles of the individual programs.
There I am but on it and that gives then nen separate Blogpost.
InstallationHow to install NixOS:
The very first thing to do is to get the latest NixOS ISO file here: https://nixos.org/download
You put the iso on a USB stick or any bootable media. (I had HIER once explained. Whether SD card or USB stick does not matter).
Then you boot from the stick.
If everything worked, then you are greeted by a shell.
Default login is User:nixos with empty password.
As the very first thing it is recommended to set the keyboard layout:
loadkeys de de
That would change the layout to German.
Next is the partitioning of the hard disk.
This goes once with UEFI and once with MBR.
In the example here the disk is mounted as /sda.
parted /dev/sda -- mklabel gpt parted /dev/sda -- mkpart primary 512MiB -8GiB parted /dev/sda -- mkpart primary linux-swap -8GiB 100% parted /dev/sda -- mkpart ESP fat32 1MiB 512MiB parted /dev/sda -- set 3 esp on
Here root and swap partition are created.
parted /dev/sda -- mklabel msdos parted /dev/sda -- mkpart primary 1MiB -8GiB parted /dev/sda -- mkpart primary linux-swap -8GiB 100%
Continue with the file system.
NixOS offers several file systems.
mkfs.ext4 -L nixos /dev/sda1
mkswap -L swap /dev/sda2
mkfs.fat -F 32 -n boot /dev/sda3
Last step - the final installation.
First, the drive is mounted:
mount /dev/disk/by-label/nixos /mnt
Under UEFI systems, this works a little differently:
mkdir -p /mnt/boot mount /dev/disk/by-label/boot /mnt/boot
When all this is done, the configuration.nix file mentioned earlier is created.
This is done conveniently by command.
nixos-generate-config --root /mnt
Now you can either use your existing configfile here or leave the new configfile if you want to reboot.
In any case it is worth to look at the "configuration.nix" before the next step, otherwise it can be that NixOS does not boot.
The next step is the installation.
Now NixOS rattles through until everything necessary is installed. In between, a root password is assigned and if everything has worked, you can reboot and have a wonderful OS on the computer.
So far the basic system would be ready and largely usable.
SoftwareBut now you want to have 'nen WM, Python, Vim and and and.
There are two ways to install programs or packages.
First, packages can be installed locally, in the sense only for the current system:
nix-env -iA nixos.vim
The command would install Vim for the current user.
However, this is more recommended for testing the package, since in this case Vim is not in the "configuration.nix" and will not be installed when the system is reproduced.
To have Vim in the transfer of the system, Vim must be in the "configuration.nix".
environment.systemPackages = with pkgs; [ vim ];
This entry must be in the "configuration.nix", so that Vim is installed with the rebuild.
After Vim is entered in the configfile, a rebuild must be executed.
Then you have the, in the configuration.nix file deposited config.
These are the basics to get NixOS running, at least as a basic system.
About the configuration.nix file or other NixOS topics I will in the future still one or other post raushauen.
NixOS is certainly not an OS for everyone but if you have it once you do not want to miss it.
Try it out is worth it all.