diff options
author | Ryan Lahfa <masterancpp@gmail.com> | 2023-11-17 18:07:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-17 18:07:10 +0100 |
commit | 65481ecfef4dda8f8248e0428ac8c41f66cb32fc (patch) | |
tree | ce7b98ecfe62ea00f07e20cf5eed0f3a2c5e170b /nixos/modules | |
parent | ccfe07c3168109567b98462533f7ddf14c7ba18d (diff) | |
parent | 81e378618e3f201e1d55abcbd920fdca394c21a5 (diff) | |
download | nixpkgs-65481ecfef4dda8f8248e0428ac8c41f66cb32fc.tar nixpkgs-65481ecfef4dda8f8248e0428ac8c41f66cb32fc.tar.gz nixpkgs-65481ecfef4dda8f8248e0428ac8c41f66cb32fc.tar.bz2 nixpkgs-65481ecfef4dda8f8248e0428ac8c41f66cb32fc.tar.lz nixpkgs-65481ecfef4dda8f8248e0428ac8c41f66cb32fc.tar.xz nixpkgs-65481ecfef4dda8f8248e0428ac8c41f66cb32fc.tar.zst nixpkgs-65481ecfef4dda8f8248e0428ac8c41f66cb32fc.zip |
Merge pull request #267985 from JulienMalka/absent-bootspec
Diffstat (limited to 'nixos/modules')
-rw-r--r-- | nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py | 17 | ||||
-rw-r--r-- | nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix | 2 |
2 files changed, 16 insertions, 3 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 96b42066b22..7d06e0131d9 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 @@ -88,9 +88,20 @@ def write_loader_conf(profile: str | None, generation: int, specialisation: str def get_bootspec(profile: str | None, generation: int) -> BootSpec: - boot_json_path = os.path.realpath("%s/%s" % (system_dir(profile, generation, None), "boot.json")) - boot_json_f = open(boot_json_path, 'r') - bootspec_json = json.load(boot_json_f) + system_directory = system_dir(profile, generation, None) + boot_json_path = os.path.realpath("%s/%s" % (system_directory, "boot.json")) + 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) def bootspec_from_json(bootspec_json: Dict) -> BootSpec: 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 1086ab80b14..9d55c21077d 100644 --- a/nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix +++ b/nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix @@ -16,6 +16,8 @@ let systemd = config.systemd.package; + bootspecTools = pkgs.bootspec; + nix = config.nix.package.out; timeout = optionalString (config.boot.loader.timeout != null) config.boot.loader.timeout; |