From dff88cbd79ddd9d0ba9f5b3b81d257d16e62ebc9 Mon Sep 17 00:00:00 2001 From: r-vdp Date: Tue, 9 Jun 2026 22:03:02 +0300 Subject: [PATCH] nixos/systemd-boot: drop bootspec synthesize fallback Older generations without boot.json are skipped with a warning. --- .../systemd-boot/systemd-boot-builder.py | 44 +++++++++---------- .../boot/loader/systemd-boot/systemd-boot.nix | 2 - nixos/tests/installer.nix | 1 - 3 files changed, 20 insertions(+), 27 deletions(-) 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 a0d4256c3c0f..06c15ee6674b 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 @@ -27,7 +27,6 @@ NIXOS_DIR = Path( TIMEOUT = "@timeout@" EDITOR = "@editor@" == "1" # noqa: PLR0133 CONSOLE_MODE = "@consoleMode@" -BOOTSPEC_TOOLS = "@bootspecTools@" DISTRO_NAME = "@distroName@" NIX = "@nix@" SYSTEMD = "@systemd@" @@ -291,31 +290,26 @@ def write_loader_conf(default_entry_id: str | None) -> None: os.rename(tmp, LOADER_CONF) -def get_bootspec(profile: str | None, generation: int) -> BootSpec: +def get_bootspec(profile: str | None, generation: int) -> BootSpec | None: system_directory = system_dir(profile, generation, None) boot_json_path = (system_directory / "boot.json").resolve() - if boot_json_path.is_file(): - with boot_json_path.open("r") as f: - # check if json is well-formed, else throw error with filepath - try: - bootspec_json = json.load(f) - except ValueError as e: - print( - f"error: Malformed Json: {e}, in {boot_json_path}", file=sys.stderr - ) - sys.exit(1) - else: - boot_json_str = run( - [ - f"{BOOTSPEC_TOOLS}/bin/synthesize", - "--version", - "1", - system_directory, - "/dev/stdout", - ], - stdout=subprocess.PIPE, - ).stdout - bootspec_json = json.loads(boot_json_str) + if not boot_json_path.is_file(): + print( + f"warning: skipping generation {generation}" + + (f" of profile {profile}" if profile else "") + + f": {boot_json_path} does not exist", + file=sys.stderr, + ) + return None + with boot_json_path.open("r") as f: + # check if json is well-formed, else throw error with filepath + try: + bootspec_json = json.load(f) + except ValueError as e: + print( + f"error: Malformed Json: {e}, in {boot_json_path}", file=sys.stderr + ) + sys.exit(1) return bootspec_from_json(bootspec_json) @@ -551,6 +545,8 @@ def install_bootloader(args: argparse.Namespace) -> None: for gen in gens: bootspec = get_bootspec(gen.profile, gen.generation) + if bootspec is None: + continue is_default = Path(bootspec.init).parent == default_config new_boot_files, new_bootctl_id = boot_file(*gen, machine_id, bootspec) boot_files.extend(new_boot_files) diff --git a/nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix b/nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix index 4c3c28b11e90..31590bb1101b 100644 --- a/nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix +++ b/nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix @@ -47,8 +47,6 @@ let systemd = config.systemd.package; - bootspecTools = config.boot.bootspec.package; - nix = config.nix.package.out; timeout = if config.boot.loader.timeout == null then "menu-force" else config.boot.loader.timeout; diff --git a/nixos/tests/installer.nix b/nixos/tests/installer.nix index b8f2fad73503..76b3b62c0389 100644 --- a/nixos/tests/installer.nix +++ b/nixos/tests/installer.nix @@ -793,7 +793,6 @@ let ++ optionals (bootLoader == "systemd-boot") [ pkgs.zstd.bin pkgs.mypy - config.boot.bootspec.package ] ++ optionals clevisTest [ pkgs.klibc ] ++ optional systemdStage1 config.system.nixos-init.package;