mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
nixos/systemd-boot: allow for bootspec-less generations
Generation built with old versions of NixOS with no bootspec support may still be present on the system and must be accounted for.
This commit is contained in:
parent
4fae7293f4
commit
81e378618e
4 changed files with 44 additions and 3 deletions
|
@ -88,9 +88,20 @@ def write_loader_conf(profile: str | None, generation: int, specialisation: str
|
||||||
|
|
||||||
|
|
||||||
def get_bootspec(profile: str | None, generation: int) -> BootSpec:
|
def get_bootspec(profile: str | None, generation: int) -> BootSpec:
|
||||||
boot_json_path = os.path.realpath("%s/%s" % (system_dir(profile, generation, None), "boot.json"))
|
system_directory = system_dir(profile, generation, None)
|
||||||
boot_json_f = open(boot_json_path, 'r')
|
boot_json_path = os.path.realpath("%s/%s" % (system_directory, "boot.json"))
|
||||||
bootspec_json = json.load(boot_json_f)
|
if os.path.isfile(boot_json_path):
|
||||||
|
boot_json_f = open(boot_json_path, 'r')
|
||||||
|
bootspec_json = json.load(boot_json_f)
|
||||||
|
else:
|
||||||
|
boot_json_str = subprocess.check_output([
|
||||||
|
"@bootspecTools@/bin/synthesize",
|
||||||
|
"--version",
|
||||||
|
"1",
|
||||||
|
system_directory,
|
||||||
|
"/dev/stdout"],
|
||||||
|
universal_newlines=True)
|
||||||
|
bootspec_json = json.loads(boot_json_str)
|
||||||
return bootspec_from_json(bootspec_json)
|
return bootspec_from_json(bootspec_json)
|
||||||
|
|
||||||
def bootspec_from_json(bootspec_json: Dict) -> BootSpec:
|
def bootspec_from_json(bootspec_json: Dict) -> BootSpec:
|
||||||
|
|
|
@ -16,6 +16,8 @@ let
|
||||||
|
|
||||||
systemd = config.systemd.package;
|
systemd = config.systemd.package;
|
||||||
|
|
||||||
|
bootspecTools = pkgs.bootspec;
|
||||||
|
|
||||||
nix = config.nix.package.out;
|
nix = config.nix.package.out;
|
||||||
|
|
||||||
timeout = optionalString (config.boot.loader.timeout != null) config.boot.loader.timeout;
|
timeout = optionalString (config.boot.loader.timeout != null) config.boot.loader.timeout;
|
||||||
|
|
|
@ -277,4 +277,20 @@ in
|
||||||
machine.wait_for_unit("multi-user.target")
|
machine.wait_for_unit("multi-user.target")
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
no-bootspec = makeTest
|
||||||
|
{
|
||||||
|
name = "systemd-boot-no-bootspec";
|
||||||
|
meta.maintainers = with pkgs.lib.maintainers; [ julienmalka ];
|
||||||
|
|
||||||
|
nodes.machine = {
|
||||||
|
imports = [ common ];
|
||||||
|
boot.bootspec.enable = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
testScript = ''
|
||||||
|
machine.start()
|
||||||
|
machine.wait_for_unit("multi-user.target")
|
||||||
|
'';
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{ lib
|
{ lib
|
||||||
, rustPlatform
|
, rustPlatform
|
||||||
, fetchFromGitHub
|
, fetchFromGitHub
|
||||||
|
, fetchpatch
|
||||||
}:
|
}:
|
||||||
rustPlatform.buildRustPackage rec {
|
rustPlatform.buildRustPackage rec {
|
||||||
pname = "bootspec";
|
pname = "bootspec";
|
||||||
|
@ -13,6 +14,17 @@ rustPlatform.buildRustPackage rec {
|
||||||
hash = "sha256-5IGSMHeL0eKfl7teDejAckYQjc8aeLwfwIQSzQ8YaAg=";
|
hash = "sha256-5IGSMHeL0eKfl7teDejAckYQjc8aeLwfwIQSzQ8YaAg=";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
patches = [
|
||||||
|
# https://github.com/DeterminateSystems/bootspec/pull/127
|
||||||
|
# Fixes the synthesize tool for aarch64-linux
|
||||||
|
(fetchpatch {
|
||||||
|
name = "aarch64-support.patch";
|
||||||
|
url = "https://github.com/DeterminateSystems/bootspec/commit/1d0e925f360f0199f13422fb7541225fd162fd4f.patch";
|
||||||
|
sha256 = "sha256-wU/jWnOqVBrU2swANdXbQfzRpNd/JIS4cxSyCvixZM0=";
|
||||||
|
})
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
cargoHash = "sha256-eGSKVHjPnHK7WyGkO5LIjocNGHawahYQR3H5Lgk1C9s=";
|
cargoHash = "sha256-eGSKVHjPnHK7WyGkO5LIjocNGHawahYQR3H5Lgk1C9s=";
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue