My nixos-rebuild switch doesnt work

when i try to run sudo nixos-rebuild switch it gives me this error

building Nix…
building the system configuration…
Assertion ‘n <= st.st_size + 1’ failed at src/basic/efivars.c:110, function efi_get_variable(). Aborting.
Traceback (most recent call last):
File “/nix/store/zlb2i0qml2rmaqc7qdpgkhak0m7fv336-systemd-boot/bin/systemd-boot”, line 431, in
main()
File “/nix/store/zlb2i0qml2rmaqc7qdpgkhak0m7fv336-systemd-boot/bin/systemd-boot”, line 414, in main
install_bootloader(args)
File “/nix/store/zlb2i0qml2rmaqc7qdpgkhak0m7fv336-systemd-boot/bin/systemd-boot”, line 317, in install_bootloader
installed_out = run(
^^^^
File “/nix/store/zlb2i0qml2rmaqc7qdpgkhak0m7fv336-systemd-boot/bin/systemd-boot”, line 58, in run
return subprocess.run(cmd, check=True, text=True, stdout=stdout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/nix/store/jd20rkmqmkfkcvk2wl2lmzz7acq4svlr-python3-3.12.12/lib/python3.12/subprocess.py”, line 571, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command ‘[’/nix/store/2dqf465jfs9w73jihy4yk8yc47673i18-systemd-257.10/bin/bootctl’, ‘–esp-path=/boot’, ‘status’]’ died with <Signals.SIGABRT: 6>.
Failed to install bootloader
warning: error(s) occurred while switching to the new configuration

5 Likes

I second this. Since today I’m getting a very similar error when rebuilding, even though I didn’t change anything besides new fonts (which I reverted but still get the error)

 sudo nixos-rebuild switch --flake .#nixos
building the system configuration...
Assertion 'n <= st.st_size + 1' failed at src/basic/efivars.c:110, function efi_get_variable(). Aborting.
Traceback (most recent call last):
  File "/nix/store/zlb2i0qml2rmaqc7qdpgkhak0m7fv336-systemd-boot/bin/systemd-boot", line 431, in <module>
    main()
  File "/nix/store/zlb2i0qml2rmaqc7qdpgkhak0m7fv336-systemd-boot/bin/systemd-boot", line 414, in main
    install_bootloader(args)
  File "/nix/store/zlb2i0qml2rmaqc7qdpgkhak0m7fv336-systemd-boot/bin/systemd-boot", line 317, in install_bootloader
    installed_out = run(
                    ^^^^
  File "/nix/store/zlb2i0qml2rmaqc7qdpgkhak0m7fv336-systemd-boot/bin/systemd-boot", line 58, in run
    return subprocess.run(cmd, check=True, text=True, stdout=stdout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/jd20rkmqmkfkcvk2wl2lmzz7acq4svlr-python3-3.12.12/lib/python3.12/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/nix/store/2dqf465jfs9w73jihy4yk8yc47673i18-systemd-257.10/bin/bootctl', '--esp-path=/boot', 'status']' died with <Signals.SIGABRT: 6>.
Failed to install bootloader
warning: error(s) occurred while switching to the new configuration
1 Like

It looks like the assertion it’s failing on was added in the latest systemd version bump (about 3 weeks ago):

1 Like

It also looks like I can only reproduce this after resuming from hibernation. I don’t run into this problem after rebooting (until my system goes into hibernation again).

2 Likes

Bug fix is here, but it’s unclear whether it’ll land in 25.05 which goes end-of-life very soon

@nito and @yurix73 can you confirm if rebooting before trying nixos-rebuild again works around this issue?

3 Likes

Hi, for me it works now after rebooting. Thank you!

ok so i did some testing and the issue only happens if you return from hibernation and try to sudo nixos-rebuild switch --upgrade after you run that command sudo nixos-rebuild swtich will be broken for the whole hibernation session

1 Like

same symtoms on my end only happens after resuming from hibernation

Same thing for me, also using hibernation

it sound to be the same as in nixos/systemd-boot: Failed to install bootloader if /boot/loader/random-seed does not exist · Issue #461676 · NixOS/nixpkgs · GitHub