nixos/systemd-boot-builder: fall back to pristine initrd when secrets fail

Otherwise the .conf for that generation references a missing initrd and
the boot entry fails to load.
This commit is contained in:
r-vdp
2026-06-02 12:20:54 +03:00
parent 3ff32972f8
commit 76673e2736
@@ -622,6 +622,10 @@ def write_boot_files(boot_files: BootFileList) -> None:
if boot_file.current:
print("failed to create initrd secrets!", file=sys.stderr)
sys.exit(1)
# Keep the entry bootable by leaving at least a pristine initrd
# in place. CopyWriter is a no-op if one already exists.
assert isinstance(boot_file.writer, InitrdWithSecretsWriter)
CopyWriter(source=boot_file.writer.source).write_boot_file(boot_path)
print(
"warning: failed to create initrd secrets for generation "
f"{boot_file.system_identifier.generation}, an older generation",