From 44030658f2e084c99bfe37ddaca653ce28c11b00 Mon Sep 17 00:00:00 2001 From: OPNA2608 Date: Sun, 23 Nov 2025 04:25:43 +0100 Subject: [PATCH] grub2_ieee1275: init at 2.12 --- pkgs/tools/misc/grub/default.nix | 26 ++++++++++++++++++++++++-- pkgs/top-level/all-packages.nix | 4 ++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/pkgs/tools/misc/grub/default.nix b/pkgs/tools/misc/grub/default.nix index 68f3921354a1..4f66c3753500 100644 --- a/pkgs/tools/misc/grub/default.nix +++ b/pkgs/tools/misc/grub/default.nix @@ -26,6 +26,7 @@ runtimeShell, zfs ? null, efiSupport ? false, + ieee1275Support ? false, zfsSupport ? false, xenSupport ? false, xenPvhSupport ? false, @@ -61,6 +62,11 @@ let riscv64-linux.target = "riscv64"; }; + ieee1275SystemsBuild = { + x86_64-linux.target = "i386"; + powerpc64-linux.target = "powerpc"; + }; + xenSystemsBuild = { i686-linux.target = "i386"; x86_64-linux.target = "x86_64"; @@ -90,8 +96,16 @@ let in assert zfsSupport -> zfs != null; -assert !(efiSupport && (xenSupport || xenPvhSupport)); -assert !(xenSupport && xenPvhSupport); +assert lib.asserts.assertMsg ( + lib.lists.length ( + lib.lists.filter (x: x) [ + efiSupport + ieee1275Support + xenSupport + xenPvhSupport + ] + ) <= 1 # (0 == pc) +) "Only <= 1 of grub2's platform-related *Support options may be enabled at the same time"; stdenv.mkDerivation rec { pname = "grub"; @@ -618,6 +632,10 @@ stdenv.mkDerivation rec { "--target=${efiSystemsBuild.${stdenv.hostPlatform.system}.target}" "--program-prefix=" ] + ++ lib.optionals ieee1275Support [ + "--with-platform=ieee1275" + "--target=${ieee1275SystemsBuild.${stdenv.hostPlatform.system}.target}" + ] ++ lib.optionals xenSupport [ "--with-platform=xen" "--target=${xenSystemsBuild.${stdenv.hostPlatform.system}.target}" @@ -631,6 +649,8 @@ stdenv.mkDerivation rec { grubTarget = if efiSupport then "${efiSystemsInstall.${stdenv.hostPlatform.system}.target}-efi" + else if ieee1275Support then + "${ieee1275SystemsBuild.${stdenv.hostPlatform.system}.target}-ieee1275" else lib.optionalString inPCSystems "${pcSystems.${stdenv.hostPlatform.system}.target}-pc"; @@ -674,6 +694,8 @@ stdenv.mkDerivation rec { platforms = if efiSupport then lib.attrNames efiSystemsBuild + else if ieee1275Support then + lib.attrNames ieee1275SystemsBuild else if xenSupport then lib.attrNames xenSystemsBuild else if xenPvhSupport then diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index ce75607dd4eb..0d8d94121672 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -2894,6 +2894,10 @@ with pkgs; efiSupport = true; }; + grub2_ieee1275 = grub2.override { + ieee1275Support = true; + }; + grub2_light = grub2.override { zfsSupport = false; };