Skip to content

nixos/systemd-boot: different generations cannot use different device trees #338024

Description

@kuruczgy

Describe the bug

The device tree support introduced in #319422 has an issue where the name of the device tree file copied to the ESP has the same name for all generations, making all generations boot with the device tree corresponding to the oldest one.

Steps To Reproduce

  1. Set hardware.deviceTree.enable = true and hardware.deviceTree.name = "qcom/x1e80100-lenovo-yoga-slim7x.dtb".
  2. Update your kernel, which also brings with it an updated device tree.
  3. Observe that all device trees are attempted to be written to $ESP/EFI/nixos/qcom-x1e80100-lenovo-yoga-slim7x.dtb.efi. If this file already exists it will not be overwritten, making all generations boot with the oldest device tree.

Expected behavior

Each generation boots with the device tree specified in its bootspec.

Additional context

This is an issue with the copy_from_file function:

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"
    if not dry_run:
        copy_if_not_exists(store_file_path, f"{BOOT_MOUNT_POINT}{efi_file_path}")
    return efi_file_path

This function assumes that file is contained in the root of a store directory, and computes store_dir as the parent of file. In my case, store_dir gets set to qcom, and so the resulting filename will be qcom-x1e80100-lenovo-yoga-slim7x.dtb.efi.

Notify maintainers

@jmbaur
@colemickens you also might be interested

Add a 👍 reaction to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions