grub2: refactor platforms logic, avoid abusing meta.broken
Previously, we used `platforms.gnu` and `platforms.linux` for Grub2's available platforms, but blocking unsupported platforms via asserts. An attempt has been made through marking unsupported platforms "broken" for EFI, but it would be better if we just document the supported platforms in `meta.platforms` in the first place. Also, the Grub2 package already has platform support for PC/EFI/Xen, which deserves to be restructured in a unified way. Regarding `meta.broken`, it shouldn't be used on invalid combinations of arguments, as it will cause misunderstandings. Changes have been made: - Remove `meta.broken`, along with the 3 conditions in it. - Remove `canEfi`, chain `efiSystemsBuild` on `meta.platform` if `pkgs.grub2_efi` is asked (building with `efiSupport = true;`) - Avoid reusing `efiSystemsBuild` for Xen (PV), build a dedicated `xenSystemsBuild` for Xen, and chain that into `meta.platforms` in the same format. - Revert the other 2 conditions (building with invalid arguments) back to asserts. Signed-off-by: Hongbo <hehongbo@mail.com>
This commit is contained in:
parent
63ba1c64e6
commit
f92169c861
@ -60,12 +60,12 @@ let
|
|||||||
riscv64-linux.target = "riscv64";
|
riscv64-linux.target = "riscv64";
|
||||||
};
|
};
|
||||||
|
|
||||||
canEfi = lib.any (system: stdenv.hostPlatform.system == system) (
|
xenSystemsBuild = {
|
||||||
lib.mapAttrsToList (name: _: name) efiSystemsBuild
|
i686-linux.target = "i386";
|
||||||
);
|
x86_64-linux.target = "x86_64";
|
||||||
inPCSystems = lib.any (system: stdenv.hostPlatform.system == system) (
|
};
|
||||||
lib.mapAttrsToList (name: _: name) pcSystems
|
|
||||||
);
|
inPCSystems = lib.any (system: stdenv.hostPlatform.system == system) (lib.attrNames pcSystems);
|
||||||
|
|
||||||
gnulib = fetchFromSavannah {
|
gnulib = fetchFromSavannah {
|
||||||
repo = "gnulib";
|
repo = "gnulib";
|
||||||
@ -88,6 +88,10 @@ let
|
|||||||
hash = "sha256-IoRiJHNQ58y0UhCAD0CrpFiI8Mz1upzAtyh5K4Njh/w=";
|
hash = "sha256-IoRiJHNQ58y0UhCAD0CrpFiI8Mz1upzAtyh5K4Njh/w=";
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
|
|
||||||
|
assert zfsSupport -> zfs != null;
|
||||||
|
assert !(efiSupport && xenSupport);
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation rec {
|
||||||
pname = "grub";
|
pname = "grub";
|
||||||
version = "2.12";
|
version = "2.12";
|
||||||
@ -605,7 +609,7 @@ stdenv.mkDerivation rec {
|
|||||||
]
|
]
|
||||||
++ lib.optionals xenSupport [
|
++ lib.optionals xenSupport [
|
||||||
"--with-platform=xen"
|
"--with-platform=xen"
|
||||||
"--target=${efiSystemsBuild.${stdenv.hostPlatform.system}.target}"
|
"--target=${xenSystemsBuild.${stdenv.hostPlatform.system}.target}"
|
||||||
];
|
];
|
||||||
|
|
||||||
# save target that grub is compiled for
|
# save target that grub is compiled for
|
||||||
@ -653,16 +657,13 @@ stdenv.mkDerivation rec {
|
|||||||
license = licenses.gpl3Plus;
|
license = licenses.gpl3Plus;
|
||||||
|
|
||||||
platforms =
|
platforms =
|
||||||
if xenSupport then
|
if efiSupport then
|
||||||
[
|
lib.attrNames efiSystemsBuild
|
||||||
"x86_64-linux"
|
else if xenSupport then
|
||||||
"i686-linux"
|
lib.attrNames xenSystemsBuild
|
||||||
]
|
|
||||||
else
|
else
|
||||||
platforms.gnu ++ platforms.linux;
|
platforms.gnu ++ platforms.linux;
|
||||||
|
|
||||||
maintainers = [ ];
|
maintainers = [ ];
|
||||||
|
|
||||||
broken = !(efiSupport -> canEfi) || !(zfsSupport -> zfs != null) || (efiSupport && xenSupport);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user