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}
|
isoBootFlags="-eltorito-boot ${bootImage}
|
||||||
-eltorito-catalog .boot.cat
|
-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
|
fi
|
||||||
|
|
||||||
if test -n "$usbBootable"; then
|
if test -n "$usbBootable"; then
|
||||||
@ -112,7 +113,7 @@ xorriso="xorriso
|
|||||||
-r
|
-r
|
||||||
-path-list pathlist
|
-path-list pathlist
|
||||||
--sort-weight 0 /
|
--sort-weight 0 /
|
||||||
--sort-weight 1 /isolinux" # Make sure isolinux is near the beginning of the ISO
|
"
|
||||||
|
|
||||||
$xorriso -output $out/iso/$isoName
|
$xorriso -output $out/iso/$isoName
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ let
|
|||||||
finalCfg = {
|
finalCfg = {
|
||||||
name = "NixOS ${config.system.nixos.label}${config.isoImage.appendToMenuLabel}";
|
name = "NixOS ${config.system.nixos.label}${config.isoImage.appendToMenuLabel}";
|
||||||
params = "init=${config.system.build.toplevel}/init ${additional} ${toString config.boot.kernelParams}";
|
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";
|
initrd = "/boot/initrd";
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
@ -163,7 +163,7 @@ let
|
|||||||
cp -v ${pkgs.refind}/share/refind/refind_x64.efi $out/EFI/boot/
|
cp -v ${pkgs.refind}/share/refind/refind_x64.efi $out/EFI/boot/
|
||||||
''
|
''
|
||||||
else
|
else
|
||||||
"# No refind for ia32"
|
"# No refind for ${targetArch}"
|
||||||
;
|
;
|
||||||
|
|
||||||
grubMenuCfg = ''
|
grubMenuCfg = ''
|
||||||
@ -222,18 +222,34 @@ let
|
|||||||
efiDir = pkgs.runCommand "efi-directory" {} ''
|
efiDir = pkgs.runCommand "efi-directory" {} ''
|
||||||
mkdir -p $out/EFI/boot/
|
mkdir -p $out/EFI/boot/
|
||||||
|
|
||||||
|
# ALWAYS required modules.
|
||||||
MODULES="fat iso9660 part_gpt part_msdos \
|
MODULES="fat iso9660 part_gpt part_msdos \
|
||||||
normal boot linux configfile loopback chain halt \
|
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 \
|
ls search search_label search_fs_uuid search_fs_file \
|
||||||
gfxmenu gfxterm gfxterm_background gfxterm_menu test all_video loadenv \
|
gfxmenu gfxterm gfxterm_background gfxterm_menu test all_video loadenv \
|
||||||
exfat ext2 ntfs btrfs hfsplus udf \
|
exfat ext2 ntfs btrfs hfsplus udf \
|
||||||
videoinfo png \
|
videoinfo png \
|
||||||
echo serial \
|
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
|
# Make our own efi program, we can't rely on "grub-install" since it seems to
|
||||||
# probe for devices, even with --skip-fs-probe.
|
# 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
|
$MODULES
|
||||||
cp ${pkgs.grub2_efi}/share/grub/unicode.pf2 $out/EFI/boot/
|
cp ${pkgs.grub2_efi}/share/grub/unicode.pf2 $out/EFI/boot/
|
||||||
|
|
||||||
@ -344,12 +360,19 @@ let
|
|||||||
${pkgs.dosfstools}/sbin/fsck.vfat -vn "$out"
|
${pkgs.dosfstools}/sbin/fsck.vfat -vn "$out"
|
||||||
''; # */
|
''; # */
|
||||||
|
|
||||||
targetArch = if pkgs.stdenv.isi686 then
|
# Name used by UEFI for architectures.
|
||||||
"ia32"
|
targetArch =
|
||||||
else if pkgs.stdenv.isx86_64 then
|
if pkgs.stdenv.isi686 then
|
||||||
"x64"
|
"ia32"
|
||||||
else
|
else if pkgs.stdenv.isx86_64 then
|
||||||
throw "Unsupported architecture";
|
"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
|
in
|
||||||
|
|
||||||
@ -483,9 +506,9 @@ in
|
|||||||
# here and it causes a cyclic dependency.
|
# here and it causes a cyclic dependency.
|
||||||
boot.loader.grub.enable = false;
|
boot.loader.grub.enable = false;
|
||||||
|
|
||||||
# !!! Hack - attributes expected by other modules.
|
environment.systemPackages = [ pkgs.grub2 pkgs.grub2_efi ]
|
||||||
system.boot.loader.kernelFile = "bzImage";
|
++ optional canx86BiosBoot pkgs.syslinux
|
||||||
environment.systemPackages = [ pkgs.grub2 pkgs.grub2_efi pkgs.syslinux ];
|
;
|
||||||
|
|
||||||
# In stage 1 of the boot, mount the CD as the root FS by label so
|
# 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
|
# 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
|
# Individual files to be included on the CD, outside of the Nix
|
||||||
# store on the CD.
|
# store on the CD.
|
||||||
isoImage.contents =
|
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;
|
{ source = config.boot.kernelPackages.kernel + "/" + config.system.boot.loader.kernelFile;
|
||||||
target = "/boot/" + config.system.boot.loader.kernelFile;
|
target = "/boot/" + config.system.boot.loader.kernelFile;
|
||||||
}
|
}
|
||||||
@ -572,9 +589,6 @@ in
|
|||||||
{ source = config.system.build.squashfsStore;
|
{ source = config.system.build.squashfsStore;
|
||||||
target = "/nix-store.squashfs";
|
target = "/nix-store.squashfs";
|
||||||
}
|
}
|
||||||
{ source = "${pkgs.syslinux}/share/syslinux";
|
|
||||||
target = "/isolinux";
|
|
||||||
}
|
|
||||||
{ source = config.isoImage.efiSplashImage;
|
{ source = config.isoImage.efiSplashImage;
|
||||||
target = "/EFI/boot/efi-background.png";
|
target = "/EFI/boot/efi-background.png";
|
||||||
}
|
}
|
||||||
@ -584,6 +598,17 @@ in
|
|||||||
{ source = pkgs.writeText "version" config.system.nixos.label;
|
{ source = pkgs.writeText "version" config.system.nixos.label;
|
||||||
target = "/version.txt";
|
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 [
|
] ++ optionals config.isoImage.makeEfiBootable [
|
||||||
{ source = efiImg;
|
{ source = efiImg;
|
||||||
target = "/boot/efi.img";
|
target = "/boot/efi.img";
|
||||||
@ -591,7 +616,7 @@ in
|
|||||||
{ source = "${efiDir}/EFI";
|
{ source = "${efiDir}/EFI";
|
||||||
target = "/EFI";
|
target = "/EFI";
|
||||||
}
|
}
|
||||||
] ++ optionals config.boot.loader.grub.memtest86.enable [
|
] ++ optionals (config.boot.loader.grub.memtest86.enable && canx86BiosBoot) [
|
||||||
{ source = "${pkgs.memtest86plus}/memtest.bin";
|
{ source = "${pkgs.memtest86plus}/memtest.bin";
|
||||||
target = "/boot/memtest.bin";
|
target = "/boot/memtest.bin";
|
||||||
}
|
}
|
||||||
@ -606,9 +631,10 @@ in
|
|||||||
# Create the ISO image.
|
# Create the ISO image.
|
||||||
system.build.isoImage = pkgs.callPackage ../../../lib/make-iso9660-image.nix ({
|
system.build.isoImage = pkgs.callPackage ../../../lib/make-iso9660-image.nix ({
|
||||||
inherit (config.isoImage) isoName compressImage volumeID contents;
|
inherit (config.isoImage) isoName compressImage volumeID contents;
|
||||||
bootable = true;
|
bootable = canx86BiosBoot;
|
||||||
bootImage = "/isolinux/isolinux.bin";
|
bootImage = "/isolinux/isolinux.bin";
|
||||||
} // optionalAttrs config.isoImage.makeUsbBootable {
|
syslinux = if canx86BiosBoot then pkgs.syslinux else null;
|
||||||
|
} // optionalAttrs (config.isoImage.makeUsbBootable && canx86BiosBoot) {
|
||||||
usbBootable = true;
|
usbBootable = true;
|
||||||
isohybridMbrImage = "${pkgs.syslinux}/share/syslinux/isohdpfx.bin";
|
isohybridMbrImage = "${pkgs.syslinux}/share/syslinux/isohdpfx.bin";
|
||||||
} // optionalAttrs config.isoImage.makeEfiBootable {
|
} // optionalAttrs config.isoImage.makeEfiBootable {
|
||||||
|
Loading…
Reference in New Issue
Block a user