nixos/systemd-boot: drop bootspec synthesize fallback

Older generations without boot.json are skipped with a
warning.
This commit is contained in:
r-vdp
2026-06-09 22:03:07 +03:00
parent c44bf2a69d
commit dff88cbd79
3 changed files with 20 additions and 27 deletions
@@ -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)
@@ -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;
-1
View File
@@ -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;