nixos/systemd-boot: use unique path for devicetree blob
Use the store directory for the devicetree package containing the desired DTB when installing to the ESP. This allows for more than one NixOS generation containing differing DTBs to coexist on the same ESP (similar to how we can have multiple kernels & initrds). This change removes the assumption that the filepath passed to `copy_from_file` is a file that lives at the toplevel of a nix output path (which prior to the systemd-boot DTB support was the case for the kernel and initrd derivations).
This commit is contained in:
@@ -33,6 +33,7 @@ CAN_TOUCH_EFI_VARIABLES = "@canTouchEfiVariables@"
|
||||
GRACEFUL = "@graceful@"
|
||||
COPY_EXTRA_FILES = "@copyExtraFiles@"
|
||||
CHECK_MOUNTPOINTS = "@checkMountpoints@"
|
||||
STORE_DIR = "@storeDir@"
|
||||
|
||||
@dataclass
|
||||
class BootSpec:
|
||||
@@ -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:
|
||||
|
||||
@@ -28,6 +28,8 @@ let
|
||||
|
||||
isExecutable = true;
|
||||
|
||||
inherit (builtins) storeDir;
|
||||
|
||||
inherit (pkgs) python3;
|
||||
|
||||
systemd = config.systemd.package;
|
||||
|
||||
Reference in New Issue
Block a user