From a9a706770a344f872035d05af7316064aa6390f5 Mon Sep 17 00:00:00 2001 From: Tuomas Tynkkynen Date: Sun, 25 Dec 2016 14:54:45 +0200 Subject: [PATCH] grub2: Make EFI grub work on aarch64 --- pkgs/tools/misc/grub/2.0x.nix | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/pkgs/tools/misc/grub/2.0x.nix b/pkgs/tools/misc/grub/2.0x.nix index eef1ac472280..7a70f2bdbff3 100644 --- a/pkgs/tools/misc/grub/2.0x.nix +++ b/pkgs/tools/misc/grub/2.0x.nix @@ -12,12 +12,21 @@ let "x86_64-linux".target = "i386"; }; - efiSystems = { + efiSystemsBuild = { "i686-linux".target = "i386"; "x86_64-linux".target = "x86_64"; + "aarch64-linux".target = "aarch64"; }; - canEfi = any (system: stdenv.system == system) (mapAttrsToList (name: _: name) efiSystems); + # For aarch64, we need to use '--target=aarch64-efi' when building, + # but '--target=arm64-efi' when installing. Insanity! + efiSystemsInstall = { + "i686-linux".target = "i386"; + "x86_64-linux".target = "x86_64"; + "aarch64-linux".target = "arm64"; + }; + + canEfi = any (system: stdenv.system == system) (mapAttrsToList (name: _: name) efiSystemsBuild); inPCSystems = any (system: stdenv.system == system) (mapAttrsToList (name: _: name) pcSystems); version = "2.x-2015-11-16"; @@ -89,11 +98,11 @@ stdenv.mkDerivation rec { patches = [ ./fix-bash-completion.patch ]; configureFlags = optional zfsSupport "--enable-libzfs" - ++ optionals efiSupport [ "--with-platform=efi" "--target=${efiSystems.${stdenv.system}.target}" "--program-prefix=" ]; + ++ optionals efiSupport [ "--with-platform=efi" "--target=${efiSystemsBuild.${stdenv.system}.target}" "--program-prefix=" ]; # save target that grub is compiled for grubTarget = if efiSupport - then "${efiSystems.${stdenv.system}.target}-efi" + then "${efiSystemsInstall.${stdenv.system}.target}-efi" else if inPCSystems then "${pcSystems.${stdenv.system}.target}-pc" else "";