Trouble upgrading to 19.03

#1

Hey, I’ve been asking in the IRC about this and I feel my trouble, at least in part, stems from having a bad mental model of how nix works so I figure this is worth being a (searchable) post.

Things I did:

  1. Got a new laptop half a year ago, set up NixOS and bare minimum of tools (already had a configuration from another computer).
  2. Didn’t update or change anything for a few months (~3) everything is smooth like butter.
  3. Finished school (I now have a degree :^) and started the process of tailoring my system with trying to upgrade to 19.03. I figured nothing could really go wrong since I could rollback and just tried to nixos-rebuild switch --upgrade straight out the gates.
  4. System broke, most of the services couldn’t restart on the fly and I had no internet etc. Rebooting into the new generation didn’t fix things. Also the new generation was still 18.09. For the same reason my immediate attempt to switch with rollback also had everything broken.
  5. Boot into the old generation and start reading what I should have done, nix-channel --list is just empty, so it seems I wasn’t on any channel when I did the upgrade.
  6. Add the stable 19.03 channel and do a nix-channel --update and try to rebuild the system several times, both with nixos-rebuild switch and nixos-rebuild boot but no bueno.

The problem as I perceive it is that I can’t delete or overwrite the initial (failed) new generation. This is because every time I rebuild or try to upgrade (whether it is after having rolled back to the working system or while having the new generation as current) the timestamp doesn’t get updated and the version number doesn’t get bumped (eventually I tried changing the version in configuration.nix but still no change). My diagnosis is that nix is trying to reuse the work done by the first update and so what I want to try is a clean slate (i.e. delete the new generation so that the update will link to the last working system).

Another way to approach it is to assume that everything is building fine but that plasma is broken in 19.03 (since the bar and the desktop background crashes when I boot into it, but at this point I do have working internet at the very least) but that doesn’t explain the timestamp + version number phenomena. If it’s really just an issue with plasma then I don’t care since I am changing my WM anyway, but I’d like to be sure, so any help with understanding what is happening under the covers would be greatly appreciated.

Okay thank you and sorry about the unnecessary details (and maybe lack of necessary details :innocent:)

#2

When you say “version number doesn’t get bumped”, do you mean the entry at the bottom of your main config file, system.stateVersion = "19.03";? As I understand it the process of upgrading nix channels, and building a new generation with those new packages does not modify your configuration files. So nothing changes that value automatically.

AFAIK, once you successfully get through the upgrade and boot and its working, then you can update that field?

At least that is what I’ve done with my system upgrades since 17.09, but my config is very barebones. I’m not sure exactly what it affects. Hopefully someone who really knows when to change that stateVersion value will chime in.

When booted into your newest generation that has internet and generally works, etc, will you share the following?

nix-env --list-generations --profile /nix/var/nix/profiles/system

&

nix-channel --list
(be sure to run as root to see the channels for system and not just your user account)

and I’m guessing that nix-channel will show (if I followed your post info correctly) nixos https://nixos.org/channels/nixos-19.03?

Since package expressions change and nixpkgs is ever moving forward, sometimes all that is needed is to read the expressions for whatever is failing. Usually when nixos options themselves change, you’ll see some red text output from nixos-rebuild warning you about the new settings. For packages it can be trickier. I’m not very familiar with plasma or KDE but if that is the only thing which is broken on your newest system generation, it might be worth digging into that.

#3

AIUI the answer is “never”. Or more accurately, only change it if the release notes for the version explicitly state that you have to change it for some reason, and even so, do it carefully.

2 Likes
#4

There was this topic about the stateVersion: When should I change system.stateVersion?

Of course if you have done it now it’s only hindsight while we really should focus on how to fix your system.

As for how updating goes, you are supposed to change your channel through nix-channel and then do a regular nixos-rebuild switch --upgrade. Then again, you did say you didn’t have any channels listed there?

#5

You’ll have to do this before rebuilding:

sudo nix-channel --add https://nixos.org/channels/nixos-19.03 nixos

https://nixos.org/nixos/manual/index.html#sec-upgrading

#6

Incredibly helpful responses!

First off, I am a bit disappointed in myself for not realizing that nix-channel is different for the user and the root, this much should have been obvious to me. The root was still on the 18.09 channel and once I put the new channel in it actually did build a new generation (and in the manual it says run the following as root, which I did for some of the commands but obviously not all, seriously sorry to bother you guys with this). Also I changed my configuration.nix to say 18.09 before I did it, I hope nothing really happened since every time I rebuilt with the changed config there was nothing to build.

I am still a bit afraid that something is broken in the intermediate generation and that it will be linked into the new system, but I am going to reboot and be sure everything works. Will come here and edit this post once I’m 19.03.

Okay a quick skim indicates everything is working except I got an error “The KDE Power Management System has triggered an internal error” which is known and seems to be related to just Plasma so I don’t really care.

Great thank you guys!

2 Likes
#7

Okay this thread really cleared things up for me, I guess I will just never think about that number again…

#8

For larger upgrades, especially when branch changes (like 18.09 -> 19.03), I prefer to be safer and only switch on boot, i.e. use nixos-rebuild boot instead of nixos-rebuild switch. Some large changes aren’t that easy to always deploy correctly without a restart, and besides – it’s good to update kernel from time to time anyway (no live kernel patching on NixOS yet AFAIK).