nixos/bootspec: remove enable option (#530066)
This commit is contained in:
@@ -97,13 +97,13 @@ let
|
||||
};
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
(lib.mkRemovedOptionModule [ "boot" "bootspec" "enable" ] ''
|
||||
Bootspec is now always generated and can no longer be disabled.
|
||||
'')
|
||||
];
|
||||
|
||||
options.boot.bootspec = {
|
||||
enable =
|
||||
lib.mkEnableOption "the generation of RFC-0125 bootspec in $system/boot.json, e.g. /run/current-system/boot.json"
|
||||
// {
|
||||
default = true;
|
||||
internal = true;
|
||||
};
|
||||
enableValidation = lib.mkEnableOption ''
|
||||
the validation of bootspec documents for each build.
|
||||
This will introduce Go in the build-time closure as we are relying on [Cuelang](https://cuelang.org/) for schema validation.
|
||||
|
||||
@@ -44,7 +44,7 @@ let
|
||||
|
||||
printf "%s " "''${extraDependencies[@]}" > "$out/extra-dependencies"
|
||||
|
||||
${optionalString (!config.boot.isContainer && config.boot.bootspec.enable) ''
|
||||
${optionalString (!config.boot.isContainer) ''
|
||||
${config.boot.bootspec.writer}
|
||||
${optionalString config.boot.bootspec.enableValidation ''${config.boot.bootspec.validator} "$out/${config.boot.bootspec.filename}"''}
|
||||
''}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -24,8 +24,6 @@ let
|
||||
environment.systemPackages = [ pkgs.efibootmgr ];
|
||||
};
|
||||
standard = {
|
||||
boot.bootspec.enable = true;
|
||||
|
||||
imports = [
|
||||
baseline
|
||||
systemd-boot
|
||||
@@ -53,8 +51,6 @@ in
|
||||
meta.maintainers = with pkgs.lib.maintainers; [ raitobezarius ];
|
||||
|
||||
nodes.machine = {
|
||||
boot.bootspec.enable = true;
|
||||
|
||||
imports = [
|
||||
baseline
|
||||
grub
|
||||
@@ -75,8 +71,6 @@ in
|
||||
meta.maintainers = with pkgs.lib.maintainers; [ raitobezarius ];
|
||||
|
||||
nodes.machine = {
|
||||
boot.bootspec.enable = true;
|
||||
|
||||
imports = [
|
||||
baseline
|
||||
grub
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -772,26 +772,6 @@ in
|
||||
}
|
||||
);
|
||||
|
||||
no-bootspec = runTest (
|
||||
{ lib, ... }:
|
||||
{
|
||||
name = "systemd-boot-no-bootspec";
|
||||
meta.maintainers = with lib.maintainers; [ julienmalka ];
|
||||
|
||||
nodes.machine = {
|
||||
imports = [ common ];
|
||||
boot.bootspec.enable = false;
|
||||
};
|
||||
|
||||
testScript =
|
||||
# python
|
||||
''
|
||||
machine.start()
|
||||
machine.wait_for_unit("multi-user.target")
|
||||
'';
|
||||
}
|
||||
);
|
||||
|
||||
bootCounting =
|
||||
let
|
||||
baseConfig = {
|
||||
|
||||
Reference in New Issue
Block a user