grub2: refactor platforms logic, avoid abusing meta.broken
#428878
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously, we used
platforms.gnu
, plusplatforms.linux
for Grub2's available platforms, but not all of them can build if we ask for a specific grub variant (like EFI). SocanEfi
is there to comparestdenv.hostPlatform.system
against efiSystemsBuild. But it's used as an assert, which is bad and fixed by grub2_efi: turn asserts into meta.broken #427180.However, as we know, the Grub2 package has been unmaintained for a while and has different variants with their available platforms loosely defined; it has never been restructured in a unified way. See:
if xenSupport
that overrides meta.platforms if we're buildingpkgs.grub2_xen
. That's the PVGrub2 used by Xen.pkgs.grub2_efi
, however, has no such treatment. An assert (and latermeta.broken
) is used to block platforms that can't do EFI.pkgs.grub2_xen
is documented to be available forx86_64-linux
andi686-linux
, butefiSystemsBuild
is reused for building it, but not all of them can produce a proper PVGrub2 binary.So I think it would be worthwhile to restructure them and document the supporting status of each variant clearly in
meta.platforms
, and this is a part of what this PR is trying to do.Regarding the use of
meta.broken
(and the use of it on the other 2 argument misuse situations in particular), I'm sorry for questioning this in this way, but I believe it's semantically incorrect, and potentially misleading to the user. Assertions are the correct contract for disallowed feature combinations: they’re not broken, they’re logically nonsensical.meta.broken
, however, is for actual broken packages, or known-unbuildable targets; it would mislead end users, who might think support is missing rather than invoked incorrectly.assert !(efiSupport && xenSupport);
before, that reads "don't build a Grub2 package that is both EFI and Xen, that's nonsense."meta.broken = efiSupport && xenSupport;
, however, reads "the EFI+Xen variant of Grub (likepkgs.grub2_efi_xen
) is broken"pkgs.grub2_zfs
; the Grub2 with ZFS support is built locally once the corresponding option is set. But imagine someone who tries to install NixOS on their zpool without reading much into the documentation, they might build the Grub2 with ZFS support but forget to passzfs
as its dependency, then seeing the broken message might mislead them that the ZFS support of Grub2 is currently broken, and they should try another day.pkgs.grub2_xen
is for booting guests that use the old PV guest type. We (the Xen team) are cooking up the support of PVH (as #374753), which is the new guest type that a modern Xen Project hypervisor can run, and will eventually replace the old PV type. Until then, we will have more conditions to stack to themeta.broken
, which makes it more misleading for future users and contributors.Also, correct me from wrong: Unlike
efiSupport
, which will be built oncepkgs.grub2_efi
is evaluated,zfsSupport
andxenSupport
default tofalse
, so our Hydra/CI won't evaluate them, right?So I reverted the other 2 argument misuse situations back to asserts, but this one is open to discussion:
xenSupport = true; efiSupport = true;
will not result in failure, though the artifact might be meaningless; and evenzfsSupport = true; zfs = null;
will not fail the build, but whether or not this thing can boot a zpool is another story.)cc @wolfgangwalther
Things done
passthru.tests
.nixpkgs-review
on this PR. See nixpkgs-review usage../result/bin/
.Add a 👍 reaction to pull requests you find important.