diff --git a/pkgs/tools/misc/grub/2.0x.nix b/pkgs/tools/misc/grub/2.0x.nix index eef1ac47228..7a70f2bdbff 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 "";