about summary refs log tree commit diff
path: root/nixos/modules/virtualisation
diff options
context:
space:
mode:
authorSamuel Dionne-Riel <samuel@dionne-riel.com>2021-05-28 22:02:14 -0400
committerThiago Kenji Okada <thiagokokada@gmail.com>2023-09-21 22:57:38 +0100
commit2eb41eb2087cbf7ae51c3fbe09888f1df19aaad3 (patch)
treee17360982032d0040010295a87cc23b411c64108 /nixos/modules/virtualisation
parentd944fb4a19bc55729e7dac824bde69e600df3d8f (diff)
downloadnixlib-2eb41eb2087cbf7ae51c3fbe09888f1df19aaad3.tar
nixlib-2eb41eb2087cbf7ae51c3fbe09888f1df19aaad3.tar.gz
nixlib-2eb41eb2087cbf7ae51c3fbe09888f1df19aaad3.tar.bz2
nixlib-2eb41eb2087cbf7ae51c3fbe09888f1df19aaad3.tar.lz
nixlib-2eb41eb2087cbf7ae51c3fbe09888f1df19aaad3.tar.xz
nixlib-2eb41eb2087cbf7ae51c3fbe09888f1df19aaad3.tar.zst
nixlib-2eb41eb2087cbf7ae51c3fbe09888f1df19aaad3.zip
nixos/virtualization: Allow building EFI / A1 OCI images
A couple notes:
---------------

Adding invalid `console=` parameters is not an issue. Any invalid
console is unused. The kernel will use the "rightmost" (last) valid
`console=` parameter as the default output. Thus the SBBR-mandated AMA0
on A1, and ttyS0 on x86_64 as documented by Oracle.

`nvme_core.shutdown_timeout=10` was added as it was written this way in
the A1 images. Unclear whether `nvme.shutdown_timeout=10` is wrong. At
worst this is a no-op.
Diffstat (limited to 'nixos/modules/virtualisation')
-rw-r--r--nixos/modules/virtualisation/oci-common.nix28
1 files changed, 23 insertions, 5 deletions
diff --git a/nixos/modules/virtualisation/oci-common.nix b/nixos/modules/virtualisation/oci-common.nix
index f6327445a328..edca4144c089 100644
--- a/nixos/modules/virtualisation/oci-common.nix
+++ b/nixos/modules/virtualisation/oci-common.nix
@@ -1,16 +1,26 @@
-{ lib, pkgs, ... }:
+{ config, lib, pkgs, ... }:
 
-with lib;
+let
+  cfg = config.oci;
+in
 {
   imports = [ ../profiles/qemu-guest.nix ];
 
   # Taken from /proc/cmdline of Ubuntu 20.04.2 LTS on OCI
   boot.kernelParams = [
-    "console=tty1"
-    "console=ttyS0"
     "nvme.shutdown_timeout=10"
+    "nvme_core.shutdown_timeout=10"
     "libiscsi.debug_libiscsi_eh=1"
     "crash_kexec_post_notifiers"
+
+    # VNC console
+    "console=tty1"
+
+    # x86_64-linux
+    "console=ttyS0"
+
+    # aarch64-linux
+    "console=ttyAMA0,115200"
   ];
 
   boot.growPartition = true;
@@ -21,15 +31,23 @@ with lib;
     autoResize = true;
   };
 
+  fileSystems."/boot" = lib.mkIf cfg.efi {
+    device = "/dev/disk/by-label/ESP";
+    fsType = "vfat";
+  };
+
+  boot.loader.efi.canTouchEfiVariables = false;
   boot.loader.grub = {
     version = 2;
-    device = "/dev/sda";
+    device = if cfg.efi then "nodev" else "/dev/sda";
     splashImage = null;
     extraConfig = ''
       serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1
       terminal_input --append serial
       terminal_output --append serial
     '';
+    efiInstallAsRemovable = cfg.efi;
+    efiSupport = cfg.efi;
   };
 
   # https://docs.oracle.com/en-us/iaas/Content/Compute/Tasks/configuringntpservice.htm#Configuring_the_Oracle_Cloud_Infrastructure_NTP_Service_for_an_Instance