From b4e756627d341b042f467d725c1f9b0f2d53fbb6 Mon Sep 17 00:00:00 2001 From: r-vdp Date: Mon, 4 May 2026 13:52:52 +0200 Subject: [PATCH] nixos/systemd-boot-builder: write each ESP path only once Shared kernels and initrds appear once per generation in boot_files, so InitrdWithSecretsWriter rebuilt the same file repeatedly. Prefer the current configuration's entry so its failures stay fatal. --- .../boot/loader/systemd-boot/systemd-boot-builder.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py b/nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py index 35799e1c458d..3ca697bfe2ea 100644 --- a/nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py +++ b/nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py @@ -614,7 +614,14 @@ def garbage_collect(gc_roots: BootFileList) -> None: def write_boot_files(boot_files: BootFileList) -> None: - for boot_file in boot_files: + # Deduplicate by destination path so shared files are written once. + # Prefer the current configuration's entry so its failures are fatal. + unique: dict[Path, BootFile] = {} + for bf in boot_files: + if bf.path not in unique or bf.current: + unique[bf.path] = bf + + for boot_file in unique.values(): boot_path = BOOT_MOUNT_POINT / boot_file.path try: boot_file.writer.write_boot_file(boot_path)