amazon-image.nix: add EFI support, enable by default for aarch64
This commit is contained in:
parent
e3fbbb1d10
commit
5501274b5f
|
@ -51,7 +51,9 @@ in {
|
||||||
inherit lib config;
|
inherit lib config;
|
||||||
inherit (cfg) contents format name;
|
inherit (cfg) contents format name;
|
||||||
pkgs = import ../../../.. { inherit (pkgs) system; }; # ensure we use the regular qemu-kvm package
|
pkgs = import ../../../.. { inherit (pkgs) system; }; # ensure we use the regular qemu-kvm package
|
||||||
partitionTableType = if config.ec2.hvm then "legacy" else "none";
|
partitionTableType = if config.ec2.efi then "efi"
|
||||||
|
else if config.ec2.hvm then "legacy"
|
||||||
|
else "none";
|
||||||
diskSize = cfg.sizeMB;
|
diskSize = cfg.sizeMB;
|
||||||
fsType = "ext4";
|
fsType = "ext4";
|
||||||
configFile = pkgs.writeText "configuration.nix"
|
configFile = pkgs.writeText "configuration.nix"
|
||||||
|
@ -61,6 +63,9 @@ in {
|
||||||
${optionalString config.ec2.hvm ''
|
${optionalString config.ec2.hvm ''
|
||||||
ec2.hvm = true;
|
ec2.hvm = true;
|
||||||
''}
|
''}
|
||||||
|
${optionalString config.ec2.efi ''
|
||||||
|
ec2.efi = true;
|
||||||
|
''}
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
|
@ -25,6 +25,9 @@ in
|
||||||
{ assertion = cfg.hvm;
|
{ assertion = cfg.hvm;
|
||||||
message = "Paravirtualized EC2 instances are no longer supported.";
|
message = "Paravirtualized EC2 instances are no longer supported.";
|
||||||
}
|
}
|
||||||
|
{ assertion = cfg.efi -> cfg.hvm;
|
||||||
|
message = "EC2 instances using EFI must be HVM instances.";
|
||||||
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
boot.growPartition = cfg.hvm;
|
boot.growPartition = cfg.hvm;
|
||||||
|
@ -35,6 +38,11 @@ in
|
||||||
autoResize = true;
|
autoResize = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
fileSystems."/boot" = mkIf cfg.efi {
|
||||||
|
device = "/dev/disk/by-label/ESP";
|
||||||
|
fsType = "vfat";
|
||||||
|
};
|
||||||
|
|
||||||
boot.extraModulePackages = [
|
boot.extraModulePackages = [
|
||||||
config.boot.kernelPackages.ena
|
config.boot.kernelPackages.ena
|
||||||
];
|
];
|
||||||
|
@ -50,8 +58,10 @@ in
|
||||||
|
|
||||||
# Generate a GRUB menu. Amazon's pv-grub uses this to boot our kernel/initrd.
|
# Generate a GRUB menu. Amazon's pv-grub uses this to boot our kernel/initrd.
|
||||||
boot.loader.grub.version = if cfg.hvm then 2 else 1;
|
boot.loader.grub.version = if cfg.hvm then 2 else 1;
|
||||||
boot.loader.grub.device = if cfg.hvm then "/dev/xvda" else "nodev";
|
boot.loader.grub.device = if (cfg.hvm && !cfg.efi) then "/dev/xvda" else "nodev";
|
||||||
boot.loader.grub.extraPerEntryConfig = mkIf (!cfg.hvm) "root (hd0)";
|
boot.loader.grub.extraPerEntryConfig = mkIf (!cfg.hvm) "root (hd0)";
|
||||||
|
boot.loader.grub.efiSupport = cfg.efi;
|
||||||
|
boot.loader.grub.efiInstallAsRemovable = cfg.efi;
|
||||||
boot.loader.timeout = 0;
|
boot.loader.timeout = 0;
|
||||||
|
|
||||||
boot.initrd.network.enable = true;
|
boot.initrd.network.enable = true;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ config, lib, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
ec2 = {
|
ec2 = {
|
||||||
|
@ -9,6 +9,13 @@
|
||||||
Whether the EC2 instance is a HVM instance.
|
Whether the EC2 instance is a HVM instance.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
efi = lib.mkOption {
|
||||||
|
default = pkgs.stdenv.hostPlatform.isAarch64;
|
||||||
|
internal = true;
|
||||||
|
description = ''
|
||||||
|
Whether the EC2 instance is using EFI.
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue