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)