Systemd-boot still defaults to older generation

Since some weeks ago, when I do a nixos-rebuild switch --upgrade, the default generation in the systemd-boot menu is no longer upgraded, see the photo below.

At the same time, /boot/loader/loader.conf already points to the latest generation:

~: cat /boot/loader/loader.conf
timeout 5
default nixos-generation-535.conf
console-mode keep

When looking at journalctl during nixos-rebuild switch --upgrade, things seem mostly ok:

Jul 21 09:11:18 petrosilia nixos[3827]: switching to system configuration /nix/store/rc882lvflmxr9p2ryrdixmfg7k6vrshc-nixos-system-petrosilia-23.05.2084.08700de174b
[...]
Jul 21 09:11:19 petrosilia systemd[1]: plymouth-quit.service: Service has no ExecStart=, ExecStop=, or SuccessAction=. Refusing.
Jul 21 09:11:19 petrosilia systemd[1]: Reloading finished in 152 ms.
[...]
Jul 21 09:11:19 petrosilia systemd-xdg-autostart-generator[4086]: Exec binary 'teams' does not exist: No such file or directory
Jul 21 09:11:19 petrosilia systemd-xdg-autostart-generator[4086]: /home/jan/.config/autostart/teams.desktop: not generating unit, error parsing Exec= line: No such file or directory
Jul 21 09:11:19 petrosilia systemd[2917]: Starting Run user-specific NixOS activation...
Jul 21 09:11:19 petrosilia systemd[2917]: Finished Run user-specific NixOS activation.
[...]
Jul 21 09:11:19 petrosilia systemd[1]: Rebuild Journal Catalog was skipped because of an unmet condition check (ConditionNeedsUpdate=/var).
Jul 21 09:11:19 petrosilia systemd[1]: Update is Completed was skipped because no trigger condition checks were met.
[...]
Jul 21 09:11:19 petrosilia systemd[1]: Platform Persistent Storage Archival was skipped because of an unmet condition check (ConditionDirectoryNotEmpty=/sys/fs/pstore).
Jul 21 09:11:19 petrosilia nixos[3827]: finished switching to system configuration /nix/store/rc882lvflmxr9p2ryrdixmfg7k6vrshc-nixos-system-petrosilia-23.05.2084.08700de174b

Is there a step that takes loader.conf and updates the menu? I would have assumed that the loader.conf is read by the bootloader dynamically at runtime, so that with a correct loader.conf the menu should default to the latest generation, but it’s not the case. Also I did a recursive grep for 510 (the generation that is currently active in the bootloader menu per default) in /boot and didn’t find anything.

My boot related config is here: https://github.com/jheidbrink/machines/blob/85dea63893493463e00727576d7c402c9445cd7c/modules/shared_config.nix#L16-L26

This is now resolved without me doing anything. If this was an issue with nixpkgs, it must have gotten fixed between NixOS 23.05.2084.08700de174b and NixOS 23.05.2162.6da4bc6cb07, or between NixOS 23.05.2162.6da4bc6cb07 and NixOS 23.05.2209.ac1acba43b2

Lol, I really wish I knew how this was resolved for you as the exect same thing is happening to me. If you can think of anythign please let me know.

For what it is worth there is another thread that describes something similar (NixOS defaults to booting older generation? - #4 by Mapybara) but the suggestion is to run nixos-rebuilt boot. But I tried this and it does not seem to fix the issue.

Hm, it looks like it wasn’t fixed by a commit in Nixpkgs then. :person_shrugging:

Hey, I actually found that if you press ‘d’ in the boot menu on a previous generation it will set that to the default. Pressing ‘d’ on it again will mean that the latest generation is set… This was driving me crazy

3 Likes

Wow I did not know that. Looks like it sets an EFI variable that takes precedence over which entry is the default. One of the things nobody seems to know systemd-boot does I guess :stuck_out_tongue: