-
-
Notifications
You must be signed in to change notification settings - Fork 17.9k
nixos/iso-image: add support for boot.loader.efi.installDeviceTree
#439700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…Tree` to `boot.loader.efi.installDeviceTree` This is in preparation for updating `nixos/modules/installer/cd-dvd/iso-image.nix` to also honor `installDeviceTree`. That code currently uses grub, so looking at a value in the systemd-boot namespace doesn't really make sense.
c815ac2 to
c7201c3
Compare
|
@ofborg test systemd-boot.basic |
|
@ofborg test systemd-boot.specialisation |
|
@jfly and I have tested that this works on a few different aarch64 devices booting via the ESP in the ISO. We considered moving the option either at |
|
Can we first let grub module support specifying deviceTree and then make use of that option when making iso-image. |
|
This pull request implements limited DeviceTree loader support in GRUB when building ISO images. NixOS also has the EFI bootloader Limine module which does not have deviceTree specification yet, renaming Also, there's case for grub/limine not installing kernel/dtb to EFI partition. |
|
@qbisi thanks for the review! I don't think the grub PR necessarily needs to land prior to this PR. The two implementations of using grub are and have always been entirely separate. I believe @ElvishJerricco might be doing some work to move ISOs for the ESP eltorito stuff to using systemd-boot, while reusing the code in the systemd-boot module (which already supports devicetree), but that probably requires some restructuring of how the boot loader install scripts work as a whole. As for the common nixos option, there are other examples of generic nixos options that aren't supported by all boot loader install programs. The prime example I can think of is the extlinux boot loader install scripts not supporting specialisations. While I think it is nice if every bootloader install program had the same feature set for shared options, we already haven't been following that. I think what would make the most sense here is to change the grub option to assert that this new option presented in this PR is set to false, since it is not yet capable of using it. Interesting to see what your thoughts are. |
|
My concern is whether we should rename boot.loader.systemd-boot.installDeviceTree to boot.loader.efi.installDeviceTree. In my opinion, for the grub/limine implementation, it’s not essential for bootloader to install dtb into the EFI partition. |
|
It sounds like the concern here is with putting the option in the |
|
systemd-boot always need to install kernel/initrd/dtb to EFI partion, so installDeviceTree essentially means loadDeviceTree for systemd-boot. For grub/limine implemention, i think the word loadDeviceTree would be more appropriate. |
It is not always the case that systemd-boot should install the devicetree blob. For platforms that have the DTB (that linux would use) built into the firmware, and exposed via the UEFI configuration table, it is not necessary that we install a devicetree to the ESP at all. The name |
|
By saying "always" i mean if systemd-boot need to use the keyword devicetree in boot entries, it always has to install dtb to EFI partition as systemd-boot can not read ext4/btrfs/xfs in rootfs partition. So the description make sense for systemd-boot. However, this is not the case for grub/limine which can load dtb directly from rootfs. Both efi bootloadr (sd-boot,grub,limine) support specifying devicetree when executing the kernel. A more general option name to describle the common behavior would be ref
|
In theory, systemd-boot can do this as well with XBOOTLDR, where the DTB could live on something like ext4. For the argument you're making about being able to pull the DTB directly out of the nix store, while I agree that some boot loaders have the capability of doing this, I am against this for a few reasons:
As for the naming of the option, while I would like to stay detached from the bootloader implementation of what it does with the DTB, |
We have generic-extlinux-compatible module in nixos, using boot.loader.loadDeviceTree replace boot.loader.generic-extlinux-compatible.useGenerationDeviceTree. This will involve more tree-wide change. But it sounds good to me.
There is an option boot.loader.grub.copyKernels meets the need. Implemention in #403746 will also respect copyKernels when setting deviceTree blob. |
Good find! Ok, so I think it would be good to move forward with |
|
I just found #396334, which is very much related. The changes look to be very similar, though this PR does try and generalize the bootloader "use devicetree from NixOS config". |
LGTM, should i split the grub part from #403746 to a seperate pr which does not involve changes in linux kernel. This seperate pr will not include nixosTest.device-tree.{systemd-boot,grub} as it require specifying deviceTree {blob, source} directly in deviceTree module. |
I think that would be best. @ElvishJerricco any thoughts on this PR versus #396334? It seems like we have a good way forward with this one. |
|
@jfly this PR likely will need to change the aarch64 ISO to set the new option |
|
The default value for boot.loader.loadDeviceTree is "with config.hardware.deviceTree; enable && name != null;" , which will evaluate to false when making a generic ISO image. do we need to manualy set it to false in aarch64 ISO settings. |
Yes! That's what I mentioned in the previous comment |
|
@jmbaur So, to summarize, the suggestion is mainly to rename the option to One issue I see is the default value for the option. The default for So I think really the default for the option should be |
|
generic-extlinux-compatible can specify both fdtfile or fdtdir. loadDeviceTree=true is equivalent to use fdtfile in extlinux.conf. We have mainly 5 bootloader in nixos:
Only rEFInd does not support loadDeviceTree (limine and grub to be implemented), loadDevcieTree just take no effect on rEFInd. We can warn user if they set boot.loader.refind.enable = true and boot.loader.loadDeviceTree = true. |
right but the default is to use fdtdir, so that should remain its default. Hence my whole point about letting each boot loader module set its own default for the option.
I don't see why this is better than what I suggested. We can just have a clear indicator of whether the option is supported by a boot loader module and then error if it isn't supported. I don't see why we need to spaghettify the logic like that. |
|
The purpose is to migrate boot.loader.systemd-boot.installDeviceTree to more generic option, the option boot.loader.loadDeviceTree instruct downstream bootloader to manually load the specified dtb file. Then downstream bootloader module implement it rather than set they prefered default. In fact, i would prefer to make boot.loader.loadDeviceTree an internal option that equals to To be specific:
|
No, because that's not correct for other boot loaders. Plus, at that point it's just an unnecessary alias. Maybe it should be like this: Instead of having |
|
Closing this to not give the illusion that I'm working on this. (Others are free to use code/ideas from this PR.) |
There are 2 commits here: I first rename rename
boot.loader.systemd-boot.installDeviceTreetoboot.loader.efi.installDeviceTree, and then I add support forboot.loader.efi.installDeviceTreetoiso-image.nix.Many thanks to @jmbaur for introducing me to the embedded world!
Things done
passthru.tests.nixpkgs-reviewon this PR. See nixpkgs-review usage../result/bin/.Add a 👍 reaction to pull requests you find important.