Unverified Commit bf193629 authored by Will Fancher's avatar Will Fancher Committed by GitHub
Browse files

nixos/systemd-boot: use unique path for devicetree blob (#336263)

parents 0a93ca37 05aefd6f
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ CAN_TOUCH_EFI_VARIABLES = "@canTouchEfiVariables@"
GRACEFUL = "@graceful@"
COPY_EXTRA_FILES = "@copyExtraFiles@"
CHECK_MOUNTPOINTS = "@checkMountpoints@"
STORE_DIR = "@storeDir@"

@dataclass
class BootSpec:
@@ -106,7 +107,7 @@ def write_loader_conf(profile: str | None, generation: int, specialisation: str
        if not EDITOR:
            f.write("editor 0\n")
        if REBOOT_FOR_BITLOCKER:
            f.write("reboot-for-bitlocker yes\n");
            f.write("reboot-for-bitlocker yes\n")
        f.write(f"console-mode {CONSOLE_MODE}\n")
        f.flush()
        os.fsync(f.fileno())
@@ -150,12 +151,13 @@ def bootspec_from_json(bootspec_json: dict[str, Any]) -> BootSpec:
def copy_from_file(file: str, dry_run: bool = False) -> str:
    store_file_path = os.path.realpath(file)
    suffix = os.path.basename(store_file_path)
    store_dir = os.path.basename(os.path.dirname(store_file_path))
    efi_file_path = f"{NIXOS_DIR}/{store_dir}-{suffix}.efi"
    store_subdir = os.path.relpath(store_file_path, start=STORE_DIR).split(os.path.sep)[0]
    efi_file_path = f"{NIXOS_DIR}/{suffix}.efi" if suffix == store_subdir else f"{NIXOS_DIR}/{store_subdir}-{suffix}.efi"
    if not dry_run:
        copy_if_not_exists(store_file_path, f"{BOOT_MOUNT_POINT}{efi_file_path}")
    return efi_file_path


def write_entry(profile: str | None, generation: int, specialisation: str | None,
                machine_id: str, bootspec: BootSpec, current: bool) -> None:
    if specialisation:
+2 −0
Original line number Diff line number Diff line
@@ -28,6 +28,8 @@ let

    isExecutable = true;

    inherit (builtins) storeDir;

    inherit (pkgs) python3;

    systemd = config.systemd.package;
+1 −1
Original line number Diff line number Diff line
@@ -200,7 +200,7 @@ in
      )
    '' + pkgs.lib.optionalString pkgs.stdenv.hostPlatform.isAarch64 ''
      machine.succeed(
          "grep 'devicetree .*dummy' /boot/loader/entries/nixos-generation-1-specialisation-something.conf"
          r"grep 'devicetree /EFI/nixos/[a-z0-9]\{32\}.*dummy' /boot/loader/entries/nixos-generation-1-specialisation-something.conf"
      )
    '';
  };