about summary refs log tree commit diff
path: root/nixos/modules/virtualisation
diff options
context:
space:
mode:
authorAndrew Childs <lorne@cons.org.nz>2019-05-25 18:53:15 +0900
committerAndrew Childs <lorne@cons.org.nz>2019-09-05 00:52:17 +0900
commit5501274b5f2f53ca27775cb4ff958b131afb80de (patch)
tree37da41e3f4760ae8403d9d5022bbbab6e51a1e84 /nixos/modules/virtualisation
parente3fbbb1d108988069383a78f424463e6be087707 (diff)
downloadnixlib-5501274b5f2f53ca27775cb4ff958b131afb80de.tar
nixlib-5501274b5f2f53ca27775cb4ff958b131afb80de.tar.gz
nixlib-5501274b5f2f53ca27775cb4ff958b131afb80de.tar.bz2
nixlib-5501274b5f2f53ca27775cb4ff958b131afb80de.tar.lz
nixlib-5501274b5f2f53ca27775cb4ff958b131afb80de.tar.xz
nixlib-5501274b5f2f53ca27775cb4ff958b131afb80de.tar.zst
nixlib-5501274b5f2f53ca27775cb4ff958b131afb80de.zip
amazon-image.nix: add EFI support, enable by default for aarch64
Diffstat (limited to 'nixos/modules/virtualisation')
-rw-r--r--nixos/modules/virtualisation/amazon-image.nix12
-rw-r--r--nixos/modules/virtualisation/amazon-options.nix9
2 files changed, 19 insertions, 2 deletions
diff --git a/nixos/modules/virtualisation/amazon-image.nix b/nixos/modules/virtualisation/amazon-image.nix
index 0c4ad90b4eb6..6b1bc9cb8bd8 100644
--- a/nixos/modules/virtualisation/amazon-image.nix
+++ b/nixos/modules/virtualisation/amazon-image.nix
@@ -25,6 +25,9 @@ in
       { assertion = cfg.hvm;
         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;
@@ -35,6 +38,11 @@ in
       autoResize = true;
     };
 
+    fileSystems."/boot" = mkIf cfg.efi {
+      device = "/dev/disk/by-label/ESP";
+      fsType = "vfat";
+    };
+
     boot.extraModulePackages = [
       config.boot.kernelPackages.ena
     ];
@@ -50,8 +58,10 @@ in
 
     # 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.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.efiSupport = cfg.efi;
+    boot.loader.grub.efiInstallAsRemovable = cfg.efi;
     boot.loader.timeout = 0;
 
     boot.initrd.network.enable = true;
diff --git a/nixos/modules/virtualisation/amazon-options.nix b/nixos/modules/virtualisation/amazon-options.nix
index 15de8638bbab..2e807131e938 100644
--- a/nixos/modules/virtualisation/amazon-options.nix
+++ b/nixos/modules/virtualisation/amazon-options.nix
@@ -1,4 +1,4 @@
-{ config, lib, ... }:
+{ config, lib, pkgs, ... }:
 {
   options = {
     ec2 = {
@@ -9,6 +9,13 @@
           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.
+        '';
+      };
     };
   };
 }