I have been a loyal Debian user for over 15 years now (shit, I'm old).
Anyone who has ever had to reinstall their system, and I've had to do that a few times in the last 15 years, knows how annoying it can be to get your system back to the same state as before.
File backups are one thing, but the system itself is a different story.
Since curiosity often makes you want to try something new, NixOS came into play.
Originally Arch Linux was an option, but a little tip made me switch directly to NixOS.
The installation effort is basically similar to that of 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.
So why would you want NixOS?
I now want a system that is as minimalistic as possible.
Sure, Debian can be used as a pure "minimalist" installation, but it still has packages that are excessively large and take up unnecessary space.
The packages obviously have their right to exist under Debian, but whether you want them is another matter.
NixOS takes up around 1.5GB.
That's pretty slim and also interesting for older hardware.
XMonad is also used as the WM. It also saves space and my fingers have already gotten used to it.
In addition to the advantage of size, there is another factor that is crucial for my decision.
NixOS itself lists three main advantages: reproducible, declarative and reliable.
Reproducible: The nix packages are isolated from each other, which ensures that they are reproducible and have no undeclared dependencies. If a package works on one computer, it will also work on another.
Declarative: With NixOS you can share development environments regardless of the language or tools.
Reliable: Installing one package does not damage any others. You can roll back 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 magical "configuration.nix".
This file configures the entire system and stores all the necessary packages, such as sound, WiFi, WM, etc., but also programs such as Vim, Git, Python, GoAccess and everything you need.
This means, conversely, that if you install NixOS on another computer and have backed up the "configuration.nix" externally, you copy it to the new system, start a rebuild and have restored your previous system.
It couldn't be easier. No more tedious manual installation.
If you want to run NixOS on the same system as the previous one, there is also the option of storing all hardware specifications in the "hardware-configuration.nix".
If, for example, my T470 were to give up the ghost here and I were to buy another T470 (not such a far-fetched idea), I would only need the "configuration.nix" and the "hardware-configuration.nix" files and my system would be ready for use again within a few minutes.
The only thing that then needs to be added manually are the dot files of the individual programs.
I'm working on that, though, and that will be a separate blog post.
Installation
How to install NixOS:
First of all, get the current NixOS ISO file here:
https://nixos.org/download
You put the iso on a USB stick or any bootable medium. (I explained
HERE. It doesn't matter whether you use an SD card or a USB stick).
Then you boot from the stick.
If everything worked, you will be greeted by a shell.
The standard login is user:nixos with an empty password.
First of all, it is recommended to set the keyboard layout:
CONSOLE
That would change the layout to German.
Next, we partition the hard drive.
This can be done once with UEFI and once with MBR.
In the example here, the disk is mounted as /sda.
UEFI
CONSOLE
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
Root and swap partitions are created here.
MBR
CONSOLE
parted /dev/sda -- mklabel msdos
parted /dev/sda -- mkpart primary 1MiB -8GiB
parted /dev/sda -- mkpart primary linux-swap -8GiB 100%
Next we move on to the file system.
NixOS offers various file systems.
Ext4
mkfs.ext4 -L nixos /dev/sda1
Swap
FAT
mkfs.fat -F 32 -n boot /dev/sda3
RAID
Last step - the final installation.
First, the drive is mounted:
MOUNT
mount /dev/disk/by-label/nixos /mnt
Under UEFI systems, things work a little differently:
MOUNT
mkdir -p /mnt/boot
mount /dev/disk/by-label/boot /mnt/boot
Once all of this is done, the configuration.nix file mentioned above is created.
This can be done easily using a command.
CREATE CONFIG
nixos-generate-config --root /mnt
Now you can either insert your existing config file here or leave the new config file if you want to restart.
In any case, it is worth looking at the "configuration.nix" before the next step, otherwise NixOS may not boot.
The next step is installation.
INSTALLATION
Now NixOS rattles through until everything necessary is installed. In the meantime, a root password is assigned and if everything has worked, you can reboot and have a wonderful OS on your computer.
The basic system is now ready and largely usable.
Software
But now you want to have WM, Python, Vim and so on.
There are two ways to install programs or packages.
On the one hand, packages can be installed locally, in the sense only for the current system:
local
The command would install Vim for the current user.
This is recommended for testing the package, however, since Vim is not in the "configuration.nix" in this case and is not installed when reproducing the system.
In order to include Vim when transferring the system, Vim must be included in the "configuration.nix".
configuration.nix
environment.systemPackages = with pkgs; [
vim
];
This entry must be in the "configuration.nix" so that Vim is installed when reinstalling.
After Vim is entered in the config file, a rebuild must be carried out.
Rebuild
Then you have the config stored in the configuration.nix file.
These are the basics for getting NixOS to work, at least as a basic system.
I'll be putting out a post or two about the configuration.nix file or other NixOS topics in the future.
NixOS is certainly not an OS for everyone, but once you have it, you don't want to be without it.
It's definitely worth trying.