Skip to content

Commit 76aef7a

Browse files
wolfgangwalthercolemickens
authored andcommitted
grub2: refactor platforms logic, avoid abusing meta.broken (NixOS#428878)
2 parents a666d85 + a677a45 commit 76aef7a

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

pkgs/tools/misc/grub/default.nix

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ let
6060
riscv64-linux.target = "riscv64";
6161
};
6262

63-
canEfi = lib.any (system: stdenv.hostPlatform.system == system) (
64-
lib.mapAttrsToList (name: _: name) efiSystemsBuild
65-
);
66-
inPCSystems = lib.any (system: stdenv.hostPlatform.system == system) (
67-
lib.mapAttrsToList (name: _: name) pcSystems
68-
);
63+
xenSystemsBuild = {
64+
i686-linux.target = "i386";
65+
x86_64-linux.target = "x86_64";
66+
};
67+
68+
inPCSystems = lib.any (system: stdenv.hostPlatform.system == system) (lib.attrNames pcSystems);
6969

7070
gnulib = fetchFromSavannah {
7171
repo = "gnulib";
@@ -88,6 +88,10 @@ let
8888
hash = "sha256-IoRiJHNQ58y0UhCAD0CrpFiI8Mz1upzAtyh5K4Njh/w=";
8989
};
9090
in
91+
92+
assert zfsSupport -> zfs != null;
93+
assert !(efiSupport && xenSupport);
94+
9195
stdenv.mkDerivation rec {
9296
pname = "grub";
9397
version = "2.12";
@@ -605,7 +609,7 @@ stdenv.mkDerivation rec {
605609
]
606610
++ lib.optionals xenSupport [
607611
"--with-platform=xen"
608-
"--target=${efiSystemsBuild.${stdenv.hostPlatform.system}.target}"
612+
"--target=${xenSystemsBuild.${stdenv.hostPlatform.system}.target}"
609613
];
610614

611615
# save target that grub is compiled for
@@ -653,16 +657,13 @@ stdenv.mkDerivation rec {
653657
license = licenses.gpl3Plus;
654658

655659
platforms =
656-
if xenSupport then
657-
[
658-
"x86_64-linux"
659-
"i686-linux"
660-
]
660+
if efiSupport then
661+
lib.attrNames efiSystemsBuild
662+
else if xenSupport then
663+
lib.attrNames xenSystemsBuild
661664
else
662665
platforms.gnu ++ platforms.linux;
663666

664667
maintainers = [ ];
665-
666-
broken = !(efiSupport -> canEfi) || !(zfsSupport -> zfs != null) || (efiSupport && xenSupport);
667668
};
668669
}

0 commit comments

Comments
 (0)