installer: Adds AArch64 UEFI installer support.
This commit is contained in:
parent
e85c1f5868
commit
ad27b068d7
|
@ -47,7 +47,8 @@ if test -n "$bootable"; then
|
|||
|
||||
isoBootFlags="-eltorito-boot ${bootImage}
|
||||
-eltorito-catalog .boot.cat
|
||||
-no-emul-boot -boot-load-size 4 -boot-info-table"
|
||||
-no-emul-boot -boot-load-size 4 -boot-info-table
|
||||
--sort-weight 1 /isolinux" # Make sure isolinux is near the beginning of the ISO
|
||||
fi
|
||||
|
||||
if test -n "$usbBootable"; then
|
||||
|
@ -112,7 +113,7 @@ xorriso="xorriso
|
|||
-r
|
||||
-path-list pathlist
|
||||
--sort-weight 0 /
|
||||
--sort-weight 1 /isolinux" # Make sure isolinux is near the beginning of the ISO
|
||||
"
|
||||
|
||||
$xorriso -output $out/iso/$isoName
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ let
|
|||
finalCfg = {
|
||||
name = "NixOS ${config.system.nixos.label}${config.isoImage.appendToMenuLabel}";
|
||||
params = "init=${config.system.build.toplevel}/init ${additional} ${toString config.boot.kernelParams}";
|
||||
image = "/boot/bzImage";
|
||||
image = "/boot/${config.system.boot.loader.kernelFile}";
|
||||
initrd = "/boot/initrd";
|
||||
};
|
||||
in
|
||||
|
@ -163,7 +163,7 @@ let
|
|||
cp -v ${pkgs.refind}/share/refind/refind_x64.efi $out/EFI/boot/
|
||||
''
|
||||
else
|
||||
"# No refind for ia32"
|
||||
"# No refind for ${targetArch}"
|
||||
;
|
||||
|
||||
grubMenuCfg = ''
|
||||
|
@ -222,18 +222,34 @@ let
|
|||
efiDir = pkgs.runCommand "efi-directory" {} ''
|
||||
mkdir -p $out/EFI/boot/
|
||||
|
||||
# ALWAYS required modules.
|
||||
MODULES="fat iso9660 part_gpt part_msdos \
|
||||
normal boot linux configfile loopback chain halt \
|
||||
efifwsetup efi_gop efi_uga \
|
||||
efifwsetup efi_gop \
|
||||
ls search search_label search_fs_uuid search_fs_file \
|
||||
gfxmenu gfxterm gfxterm_background gfxterm_menu test all_video loadenv \
|
||||
exfat ext2 ntfs btrfs hfsplus udf \
|
||||
videoinfo png \
|
||||
echo serial \
|
||||
"
|
||||
|
||||
echo "Building GRUB with modules:"
|
||||
for mod in $MODULES; do
|
||||
echo " - $mod"
|
||||
done
|
||||
|
||||
# Modules that may or may not be available per-platform.
|
||||
echo "Adding additional modules:"
|
||||
for mod in efi_uga; do
|
||||
if [ -f ${pkgs.grub2_efi}/lib/grub/${pkgs.grub2_efi.grubTarget}/$mod.mod ]; then
|
||||
echo " - $mod"
|
||||
MODULES+=" $mod"
|
||||
fi
|
||||
done
|
||||
|
||||
# Make our own efi program, we can't rely on "grub-install" since it seems to
|
||||
# probe for devices, even with --skip-fs-probe.
|
||||
${pkgs.grub2_efi}/bin/grub-mkimage -o $out/EFI/boot/${if targetArch == "x64" then "bootx64" else "bootia32"}.efi -p /EFI/boot -O ${if targetArch == "x64" then "x86_64" else "i386"}-efi \
|
||||
${pkgs.grub2_efi}/bin/grub-mkimage -o $out/EFI/boot/boot${targetArch}.efi -p /EFI/boot -O ${pkgs.grub2_efi.grubTarget} \
|
||||
$MODULES
|
||||
cp ${pkgs.grub2_efi}/share/grub/unicode.pf2 $out/EFI/boot/
|
||||
|
||||
|
@ -344,13 +360,20 @@ let
|
|||
${pkgs.dosfstools}/sbin/fsck.vfat -vn "$out"
|
||||
''; # */
|
||||
|
||||
targetArch = if pkgs.stdenv.isi686 then
|
||||
# Name used by UEFI for architectures.
|
||||
targetArch =
|
||||
if pkgs.stdenv.isi686 then
|
||||
"ia32"
|
||||
else if pkgs.stdenv.isx86_64 then
|
||||
"x64"
|
||||
else if pkgs.stdenv.isAarch64 then
|
||||
"aa64"
|
||||
else
|
||||
throw "Unsupported architecture";
|
||||
|
||||
# Syslinux (and isolinux) only supports x86-based architectures.
|
||||
canx86BiosBoot = pkgs.stdenv.isi686 || pkgs.stdenv.isx86_64;
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
|
@ -483,9 +506,9 @@ in
|
|||
# here and it causes a cyclic dependency.
|
||||
boot.loader.grub.enable = false;
|
||||
|
||||
# !!! Hack - attributes expected by other modules.
|
||||
system.boot.loader.kernelFile = "bzImage";
|
||||
environment.systemPackages = [ pkgs.grub2 pkgs.grub2_efi pkgs.syslinux ];
|
||||
environment.systemPackages = [ pkgs.grub2 pkgs.grub2_efi ]
|
||||
++ optional canx86BiosBoot pkgs.syslinux
|
||||
;
|
||||
|
||||
# In stage 1 of the boot, mount the CD as the root FS by label so
|
||||
# that we don't need to know its device. We pass the label of the
|
||||
|
@ -556,13 +579,7 @@ in
|
|||
# Individual files to be included on the CD, outside of the Nix
|
||||
# store on the CD.
|
||||
isoImage.contents =
|
||||
[ { source = pkgs.substituteAll {
|
||||
name = "isolinux.cfg";
|
||||
src = pkgs.writeText "isolinux.cfg-in" isolinuxCfg;
|
||||
bootRoot = "/boot";
|
||||
};
|
||||
target = "/isolinux/isolinux.cfg";
|
||||
}
|
||||
[
|
||||
{ source = config.boot.kernelPackages.kernel + "/" + config.system.boot.loader.kernelFile;
|
||||
target = "/boot/" + config.system.boot.loader.kernelFile;
|
||||
}
|
||||
|
@ -572,9 +589,6 @@ in
|
|||
{ source = config.system.build.squashfsStore;
|
||||
target = "/nix-store.squashfs";
|
||||
}
|
||||
{ source = "${pkgs.syslinux}/share/syslinux";
|
||||
target = "/isolinux";
|
||||
}
|
||||
{ source = config.isoImage.efiSplashImage;
|
||||
target = "/EFI/boot/efi-background.png";
|
||||
}
|
||||
|
@ -584,6 +598,17 @@ in
|
|||
{ source = pkgs.writeText "version" config.system.nixos.label;
|
||||
target = "/version.txt";
|
||||
}
|
||||
] ++ optionals canx86BiosBoot [
|
||||
{ source = pkgs.substituteAll {
|
||||
name = "isolinux.cfg";
|
||||
src = pkgs.writeText "isolinux.cfg-in" isolinuxCfg;
|
||||
bootRoot = "/boot";
|
||||
};
|
||||
target = "/isolinux/isolinux.cfg";
|
||||
}
|
||||
{ source = "${pkgs.syslinux}/share/syslinux";
|
||||
target = "/isolinux";
|
||||
}
|
||||
] ++ optionals config.isoImage.makeEfiBootable [
|
||||
{ source = efiImg;
|
||||
target = "/boot/efi.img";
|
||||
|
@ -591,7 +616,7 @@ in
|
|||
{ source = "${efiDir}/EFI";
|
||||
target = "/EFI";
|
||||
}
|
||||
] ++ optionals config.boot.loader.grub.memtest86.enable [
|
||||
] ++ optionals (config.boot.loader.grub.memtest86.enable && canx86BiosBoot) [
|
||||
{ source = "${pkgs.memtest86plus}/memtest.bin";
|
||||
target = "/boot/memtest.bin";
|
||||
}
|
||||
|
@ -606,9 +631,10 @@ in
|
|||
# Create the ISO image.
|
||||
system.build.isoImage = pkgs.callPackage ../../../lib/make-iso9660-image.nix ({
|
||||
inherit (config.isoImage) isoName compressImage volumeID contents;
|
||||
bootable = true;
|
||||
bootable = canx86BiosBoot;
|
||||
bootImage = "/isolinux/isolinux.bin";
|
||||
} // optionalAttrs config.isoImage.makeUsbBootable {
|
||||
syslinux = if canx86BiosBoot then pkgs.syslinux else null;
|
||||
} // optionalAttrs (config.isoImage.makeUsbBootable && canx86BiosBoot) {
|
||||
usbBootable = true;
|
||||
isohybridMbrImage = "${pkgs.syslinux}/share/syslinux/isohdpfx.bin";
|
||||
} // optionalAttrs config.isoImage.makeEfiBootable {
|
||||
|
|
Loading…
Reference in a new issue