My experience when switching to NixOS - Part 8

So I (re)installed NixOS on my old Notebook yesterday and today. Besides some small problems it worked like a charm. Read about it here.

Why did I reinstall?

Well, the old setup was fine. Besides one thing: I hadn’t my configuration repository on the device. You may think, well, where is the problem? Just install git and clone it from the other machines, right? The point is, I like to keep my configuration parts private and only share snippets of it if someone asks. Also because there are passwords in it and so on. You know what I mean.

That’s why I need disc encryption when I want to clone my configuration repository on a device. So I had to reinstall the device because it had no disc encryption. No problem, as nixos is awesome!

The process of reinstalling

Well, it was really simple: Boot the USB stick, format the drive with fdisk and create encrypted volumes with cryptsetup, then mount them and create file systems with mkfs. Then mount these and do a nixos-install - smooth as hell!

After that, I edited the configuration.nix file which was created by nixos-install, so had vim and git available when rebooting - also smooth as hell.

But then, I did the big mistake.

The problem

I was a bit tired yesterday, so apologies here. But I actually did adduser. Of course, it worked for the first step. I then logged in with this user, edited the configuration.nix file to have the user as well, rebuild the system and rebooted. The user still existed, but the packages were not available. I had already cloned my configuration repository onto the encrypted drive and linked it from the /etc/nixos/configuration.nix path, but the packages were not available to the user.

The solution

The solution I found this morning was rather simple: I had two boot loader configurations in my configuration files, as my workstation machine boots via gummiboot for UEFI but the old notebook had to use grub. Two bootloader definitions are not that good - the bootloader didn’t get any updates, so I always rebooted into the same generation, resulting in a way to old environment, where the packages were not available.

I fixed this one and also removed everything which was related to the user I had created. I did a nixos-rebuild switch. The user got created, the bootloader got its update.

Everything worked.

Awesomeness

So, overall, you can reproduce by:

  • Don’t be tired when installing a OS
  • fdisk
  • cryptsetup
  • mkfs
  • mount
  • nixos-install
  • vim
  • nixos-rebuild

in this order.

And you have everything available. It is SO awesome. I just logged into the machine over SSH and did some things. It was SO easy, because I didn’t need to reinstall all my stuff, I already had it available and it worked. That’s pure awesomeness to me (pun intended)!