[NIXOS noob / beginner] Both nixos-rebuild switch --flake .#probook-445g6 --impure and nixos-rebuild boot --flake .#probook-445g6 --impure build properly but after reboot new [flake] generations don't show up only my first 6 generations show up

Hello there I am trying to replicate this flake: Icy-Thought/snowflake: A repository which contains my current Nix (flake-based) setup! - Codeberg.org on an almost fresh copy of nixos (only 6 generations so far). After much debugging I managed to get the flake to a state where it would build successfully with no errors (only a few warnings which I presume are harmless):

Figure 1:

 nixos-rebuild switch --use-remote-sudo --flake .#probook-445g6 --impure
warning: Git tree '/home/rudra/Workspace/public/snowflake' is dirty
building the system configuration...
warning: Git tree '/home/rudra/Workspace/public/snowflake' is dirty
evaluation warning: getExe: Package "ibus-1.5.31" does not have the meta.mainProgram attribute. We'll assume that the main program has the same name for now, but this behavior is deprecated, because it leads to surprising errors when the assumption does not hold. If the package has a main program, please set `meta.mainProgram` in its definition to make this warning go away. Otherwise, if the package does not have a main program, or if you don't control its definition, use getExe' to specify the name to the program, such as lib.getExe' foo "bar".
evaluation warning: getExe: Package "ibus-1.5.31" does not have the meta.mainProgram attribute. We'll assume that the main program has the same name for now, but this behavior is deprecated, because it leads to surprising errors when the assumption does not hold. If the package has a main program, please set `meta.mainProgram` in its definition to make this warning go away. Otherwise, if the package does not have a main program, or if you don't control its definition, use getExe' to specify the name to the program, such as lib.getExe' foo "bar".
[sudo] password for rudra: 
updating GRUB 2 menu...
Warning: os-prober will be executed to detect other bootable partitions.
Its output will be used to detect bootable binaries on them and create new boot entries.
lsblk: /dev/mapper/no*[0-9]: not a block device
lsblk: /dev/mapper/block*[0-9]: not a block device
lsblk: /dev/mapper/devices*[0-9]: not a block device
lsblk: /dev/mapper/found*[0-9]: not a block device
activating the configuration...
setting up /etc...
reloading user units for rudra...
restarting sysinit-reactivation.target
the following new units were started: NetworkManager-dispatcher.service
Done. The new configuration is /nix/store/1kwshqd1cd71lrfzs5anpq7k96lnv4k8-nixos-system-probook-445g6-25.05.20250417.b024ced

Figure 2:

 nixos-rebuild boot --use-remote-sudo --flake .#probook-445g6 --impure
warning: Git tree '/home/rudra/Workspace/public/snowflake' is dirty
building the system configuration...
warning: Git tree '/home/rudra/Workspace/public/snowflake' is dirty
evaluation warning: getExe: Package "ibus-1.5.31" does not have the meta.mainProgram attribute. We'll assume that the main program has the same name for now, but this behavior is deprecated, because it leads to surprising errors when the assumption does not hold. If the package has a main program, please set `meta.mainProgram` in its definition to make this warning go away. Otherwise, if the package does not have a main program, or if you don't control its definition, use getExe' to specify the name to the program, such as lib.getExe' foo "bar".
evaluation warning: getExe: Package "ibus-1.5.31" does not have the meta.mainProgram attribute. We'll assume that the main program has the same name for now, but this behavior is deprecated, because it leads to surprising errors when the assumption does not hold. If the package has a main program, please set `meta.mainProgram` in its definition to make this warning go away. Otherwise, if the package does not have a main program, or if you don't control its definition, use getExe' to specify the name to the program, such as lib.getExe' foo "bar".
updating GRUB 2 menu...
Warning: os-prober will be executed to detect other bootable partitions.
Its output will be used to detect bootable binaries on them and create new boot entries.
lsblk: /dev/mapper/no*[0-9]: not a block device
lsblk: /dev/mapper/block*[0-9]: not a block device
lsblk: /dev/mapper/devices*[0-9]: not a block device
lsblk: /dev/mapper/found*[0-9]: not a block device
Done. The new configuration is /nix/store/1kwshqd1cd71lrfzs5anpq7k96lnv4k8-nixos-system-probook-445g6-25.05.20250417.b024ced

Almost identical to figure 1.

Both figures show absolutely no sign of any errors / problems / issues which is what really confuses me.

Anyway when I reboot rather than seeing a 7th generation with icy-thought’s amazing snowflake flake. I see only gnerations 1 to 6.

My first thought was maybe issue with bootloader so I found https://wiki.nixos.org/wiki/Bootloader and started following it. I determined that my system is UEFI with [ -d /sys/firmware/efi/efivars ] && echo "UEFI" || echo "Legacy" No surprises there!

Then i read:

Limiting amount of entries with grub or systemd-boot

The grub and systemd-boot modules has an option to limit the number of configurations made available in the boot partition, boot.loader.grub.configurationLimit or boot.loader.systemd-boot.configurationLimit. Setting this to a lower amount than the default may help reduce the occasions where too many different kernels and initrds are added to the /boot partition or ESP.

and confirmed neither of those two options is even present anywhere (the flake uses GRUB btw.)

Then I read:

Re-installing the bootloader

  • Something happened, and the bootloader doesn’t work as expected.
  • The ESP was re-made and nothing was kept.
  • The ESP wasn’t mounted and I want to re-generate the menu entries.

From a running system

sudo nixos-rebuild --install-bootloader boot

So I tried nixos-rebuild boot --use-remote-sudo --flake .#probook-445g6 --impure --install-bootloader
and
nixos-rebuild switch --use-remote-sudo --flake .#probook-445g6 --impure --install-bootloader

Both very successfull yet after reboot no change :cry:

Anyway then I read:

New generations are not in the boot menu

The most common cause for this situation is when the ESP isn’t mounted where NixOS expects it to be on UEFI systems. NixOS assumes the ESP is mounted under /boot and that it is on the ESP that NixOS will install the files needed for the boot process for UEFI systems.[1] This issue should affect all supported UEFI bootloaders equally for NixOS.

The usual fix for this problem is to add the missing entry for fileSystems."/boot" in hardware-configuration.nix (or where your mount points are defined).

If for some reason it is impossible to boot the existing generations, follow the steps in #Re-installing the bootloader to re-generate the menu entries, then boot in your system to add the missing configuration. The next generations should work as expected in your bootloader.

I sanity checked myself and yes fileSystems."/boot" is configured correctly with correct UUID shown in lsblk -f and everything. So as it recommended I re-tryed re-installing the bootloader, same story still though!

So now I’m unsure what the next steps I should take to troubleshoot this are, if you can provide guidance or point me to more helpful resources. I’d highly appreciate it :smiley: .

Anyways sorry if that was a bit ranty its just I really like the flake and would be overjoyed to get it successfully reproduced.

PS: Here is the github repo of my modified / debugged version of the flake: GitHub - rudra-code-creator/snowflake: A repository which contains my current Nix (flake-based) setup!

Thanks for any help in advanced

Btw every time I do any of the nixos-rebuild commands it always outputs Done. The new configuration is /nix/store/1kwshqd1cd71lrfzs5anpq7k96lnv4k8-nixos-system-probook-445g6-25.05.20250417.b024ced The hash and all never changes that is very odd

Oh hang on silly me I just realised it is because I didnt make any change to config but when I make a minor change e.g. add cowsay to packages it changes. I forgot that nixos loves hashes LOL.

If you were using systemd-boot in the past, and switched to grub without cleaning out the ESP, then systemd-boot and its outdated boot entries may still be installed and may still be the boot loader your system is booting into. In that case, rebuilds will be adding entries for grub, but not for systemd-boot, and your systemd-boot menu will be obsolete.

I also tried deleting everything in /boot/* and running a rebuild with --install-bootloader so that it could switch over to grub but it still stays on systemD boot. I tried using sudo grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=NixOS --recheck and sudo grub-mkconfig -o /boot/grub/grub.cfg and both didn’t work

I also tried adding boot.loader.grub.copyKernels = true; but nothing changed.

Do you know any other way to clear the esp apart from what I just mentioned?

Oh I just had an idea, if I reinstall from the ISO image and change the bootloader options in configuration.nix before booting into a new fresh system will that allow me to more painlessly switch to grub. Bypassing any potential bugs I’m facing in relation to nixos-rebuild and grub-install? After that I can probably just pull down my version of the flake from GitHub and rebuild I guess?

You should never run the grub- commands manually on NixOS. What NixOS does when it handles grub is highly custom.

Sounds like you didn’t actually delete systemd-boot then. Either your EFI partition isn’t mounted at /boot or systemd-boot is installed on some other EFI partition.