TypeError: BootSpec.__init__() missing 1 required positional argument: 'initrdSecrets'

Hi guys!

I had a working nix configuration and thought lets try the same configuration with the nixos-unstable branch.
it did not work as expected (not sure if, and what error occured there) but i restarted and switched to an older version.
then a changed the inputs.nixpkgs.url back to nixos-23-11. but now if a build and switch i get the following error.

Copied "/nix/store/i0sdqs34r68if9s4sfmpixnnj36npiwj-systemd-254.6/lib/systemd/boot/efi/systemd-bootx64.efi" to "/boot/EFI/systemd/systemd-bootx64.efi".
Copied "/nix/store/i0sdqs34r68if9s4sfmpixnnj36npiwj-systemd-254.6/lib/systemd/boot/efi/systemd-bootx64.efi" to "/boot/EFI/BOOT/BOOTX64.EFI".
⚠️ Mount point '/boot' which backs the random seed file is world accessible, which is a security hole! ⚠️
⚠️ Random seed file '/boot/loader/random-seed' is world accessible, which is a security hole! ⚠️
Random seed file /boot/loader/random-seed successfully refreshed (32 bytes).
Created EFI boot entry "Linux Boot Manager".
Traceback (most recent call last):
  File "/nix/store/1ly3qb5ri5mhqnyiykr6cw0p0sb9kvmi-systemd-boot", line 344, in <module>
    main()
  File "/nix/store/1ly3qb5ri5mhqnyiykr6cw0p0sb9kvmi-systemd-boot", line 332, in main
    install_bootloader(args)
  File "/nix/store/1ly3qb5ri5mhqnyiykr6cw0p0sb9kvmi-systemd-boot", line 288, in install_bootloader
    remove_old_entries(gens)
  File "/nix/store/1ly3qb5ri5mhqnyiykr6cw0p0sb9kvmi-systemd-boot", line 197, in remove_old_entries
    bootspec = get_bootspec(gen.profile, gen.generation)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/1ly3qb5ri5mhqnyiykr6cw0p0sb9kvmi-systemd-boot", line 105, in get_bootspec
    return bootspec_from_json(bootspec_json)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/1ly3qb5ri5mhqnyiykr6cw0p0sb9kvmi-systemd-boot", line 110, in bootspec_from_json
    return BootSpec(**bootspec_json['org.nixos.bootspec.v1'], specialisations=specialisations)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: BootSpec.__init__() missing 1 required positional argument: 'initrdSecrets'
warning: error(s) occurred while switching to the new configuration

How can i get back to 23.11?

Fixed it!

deleted a lot of previous generations using (a for loop)

sudo nix-env --delete-generation "$i" --profile /nix/var/nix/profiles/system

after that i ran

nix-store --gc

Then i restarted!

After that, i was, again, able to build-switch

3 Likes

I was similarly trying to downgrade from unstable to 23.11 and this solution did not work for me. Instead, I had to run sudo nix-collect-garbage --delete-old, sudo nix-rebuild boot and then reboot.

For reference, I have the experimental nix command enabled, flakes enabled and I was using home-manager, which I also downgraded to the 23.11 release.

4 Likes

I have the same problem. And still trying to fix it. I also tried to change the permission of the file given in the warning, but it only created more problem, and I had to revert my changes.

Ok, so I followed advices. Just manually deleting old system builds with nix-env --delete-generations 34 --profile /nix/var/nix/profiles/system and rebuilding the boot with nixos-rebuild boot then rebooting fixed the issue.

Note: use nix-env --list-generations --profile /nix/var/nix/profiles/system to list generations.

1 Like

A word of warning about nix-env --delete-generations:

I had a similar problem: got the error when I ran nixos-rebuild for the first time after moving the config to a flake. Turned out I forgot to define nixpkgs input explicitly and it used unstable by default, which is probably why I got the above error.

To solve it I followed the nix-env --list-generations + nix-env --delete-generations path. After that I also ran nix-collect-garbage -d, “just in case”. I rebooted and to my surprise boot menu didn’t show any generations, just 2 options: “NixOS” + “something about UEFI/firmware”. I thought bootloader got broken somehow. I booted, did another nixos-rebuild (after slight config change), then rebooted. This time the boot menu showed 2 generations - the new one and the previous one.

I booted and ran nix-env --list-generations to check whether the bootloader is the problem or my generations disappeared. It listed only the 2 new ones. Before the whole operation I had ~20 older generations which were gone now.

I think what happened here is: nix-collect-garbage got rid of all the generations which had their number lower than the one I deleted with nix-env --delete-generations because there was a “whole” in generation numbering after I deleted one of them. Could that be the case here?