Nixos-rebuild fails trying to remove old, non-existant boot entry

Today, I noticed that my audio wasn’t working quite right and I couldn’t reboot pipewire (this could be another issue with systemd and systemctl). After a lot of debugging, I decided it may be a nixos-unstable moment (I switched because there were nvidia driver bugs that weren’t being rolled back to 24.05) to try rebuilding with upgrade and restarting. Here is the output of the build attempt:

$ sudo nixos-rebuild switch --upgrade --cores 6
[sudo] password for user:
unpacking channels...
building Nix...
building the system configuration...
Traceback (most recent call last):
  File "/nix/store/7qdqmw4vpgf94rpp5xdnnbhwc54cgznc-systemd-boot", line 546, in <module>
    main()
  File "/nix/store/7qdqmw4vpgf94rpp5xdnnbhwc54cgznc-systemd-boot", line 529, in main
    install_bootloader(args)
  File "/nix/store/7qdqmw4vpgf94rpp5xdnnbhwc54cgznc-systemd-boot", line 462, in install_bootloader
    remove_old_entries(gens, entries)
  File "/nix/store/7qdqmw4vpgf94rpp5xdnnbhwc54cgznc-systemd-boot", line 354, in remove_old_entries
    os.unlink(disk_entry.path)
FileNotFoundError: [Errno 2] No such file or directory: '/boot/loader/entries/nixos-generation-182-specialisation-multi.conf'
warning: error(s) occurred while switching to the new configuration

For context, I had a specialization, “multi-monitor” bc the nvidia drivers have a major issue that still aren’t fixed at all yet to my understanding. I was told that there may be an issue with the hyphen in the name so I renamed it to “multimonitor” but I still get the same error. There was also a configuration option for counting boot entries (?) that people suggested may be an issue but to my understanding it is disabled by default and I don’t have anywhere in my config or hardware-config that enable it.

This is probably caused by the name of your specialisation (the dash breaks some scripts), see this recent thread for how to fix it and context: Unable to nixos-rebuild switch/boot: FileNotFoundError - #9 by mvanbem

You can override the nvidia package with a custom version pretty easily - I recommend doing so especially on stable, the drivers are just too fickle:

hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.mkDriver {
  version = "555.58.02";
  sha256_64bit = "sha256-xctt4TPRlOJ6r5S54h5W6PT6/3Zy2R4ASNFPu8TSHKM=";
  sha256_aarch64 = "sha256-8hyRiGB+m2hL3c9MDA/Pon+Xl6E788MZ50WrrAGUVuY=";
  openSha256 = "sha256-8hyRiGB+m2hL3c9MDA/Pon+Xl6E788MZ50WrrAGUVuY=";
  settingsSha256 = "sha256-ZpuVZybW6CFN/gz9rx+UJvQ715FZnAOYfHn5jt5Z2C8=";
  persistencedSha256 = "sha256-xctt4TPRlOJ6r5S54h5W6PT6/3Zy2R4ASNFPu8TSHKM=";
};

Just remember to update manually when nvidia publish a new version.

The fix for this bug was merged yesterday. It’ll reach unstable in the next couple of days. Until then you’ll have to rollback nixpkgs unfortunately :confused:

Ok. I’ll wait. Thank you.