summary refs log tree commit diff
path: root/nixos/maintainers/scripts/ec2/amazon-image.nix
diff options
context:
space:
mode:
authorTimothy DeHerrera <tim.deh@pm.me>2021-11-10 14:12:01 -0700
committerTimothy DeHerrera <tim.deh@pm.me>2021-11-10 17:38:58 -0700
commited4170733c141b610484fc452f1d0a0302213abd (patch)
treef515898d3cac43618fdec86e8385cac68486278e /nixos/maintainers/scripts/ec2/amazon-image.nix
parent523850d2466cb6c3d61ad1f3bc0deff55db8adec (diff)
downloadnixpkgs-ed4170733c141b610484fc452f1d0a0302213abd.tar
nixpkgs-ed4170733c141b610484fc452f1d0a0302213abd.tar.gz
nixpkgs-ed4170733c141b610484fc452f1d0a0302213abd.tar.bz2
nixpkgs-ed4170733c141b610484fc452f1d0a0302213abd.tar.lz
nixpkgs-ed4170733c141b610484fc452f1d0a0302213abd.tar.xz
nixpkgs-ed4170733c141b610484fc452f1d0a0302213abd.tar.zst
nixpkgs-ed4170733c141b610484fc452f1d0a0302213abd.zip
amis: enable setting ami boot mode on registration
This is important since legacy bios mode is still the default for Intel
and AMD based instances on AWS. That is, even if your image is setup to
use UEFI on the OS level, the AMI will still use BIOS unless the boot
mode is explicitly set during registration.
Diffstat (limited to 'nixos/maintainers/scripts/ec2/amazon-image.nix')
-rw-r--r--nixos/maintainers/scripts/ec2/amazon-image.nix5
1 files changed, 5 insertions, 0 deletions
diff --git a/nixos/maintainers/scripts/ec2/amazon-image.nix b/nixos/maintainers/scripts/ec2/amazon-image.nix
index fcb369e87ff..6358ec68f7c 100644
--- a/nixos/maintainers/scripts/ec2/amazon-image.nix
+++ b/nixos/maintainers/scripts/ec2/amazon-image.nix
@@ -4,6 +4,7 @@ with lib;
 
 let
   cfg = config.amazonImage;
+  amiBootMode = if config.ec2.efi then "uefi" else "legacy-bios";
 
 in {
 
@@ -106,10 +107,12 @@ in {
          --arg system ${lib.escapeShellArg pkgs.stdenv.hostPlatform.system} \
          --arg root_logical_bytes "$(${pkgs.qemu}/bin/qemu-img info --output json "$rootDisk" | ${pkgs.jq}/bin/jq '."virtual-size"')" \
          --arg boot_logical_bytes "$(${pkgs.qemu}/bin/qemu-img info --output json "$bootDisk" | ${pkgs.jq}/bin/jq '."virtual-size"')" \
+         --arg boot_mode "${amiBootMode}" \
          --arg root "$rootDisk" \
          --arg boot "$bootDisk" \
         '{}
           | .label = $system_label
+          | .boot_mode = $boot_mode
           | .system = $system
           | .disks.boot.logical_bytes = $boot_logical_bytes
           | .disks.boot.file = $boot
@@ -145,9 +148,11 @@ in {
          --arg system_label ${lib.escapeShellArg config.system.nixos.label} \
          --arg system ${lib.escapeShellArg pkgs.stdenv.hostPlatform.system} \
          --arg logical_bytes "$(${pkgs.qemu}/bin/qemu-img info --output json "$diskImage" | ${pkgs.jq}/bin/jq '."virtual-size"')" \
+         --arg boot_mode "${amiBootMode}" \
          --arg file "$diskImage" \
           '{}
           | .label = $system_label
+          | .boot_mode = $boot_mode
           | .system = $system
           | .logical_bytes = $logical_bytes
           | .file = $file