summary refs log tree commit diff
diff options
context:
space:
mode:
authorYour Name <graham@grahamc.com>2021-08-20 12:36:54 -0400
committerYour Name <graham@grahamc.com>2021-08-20 12:42:02 -0400
commit1b791763105fb69277d1021826bf0ea3721ca9f2 (patch)
tree7e04dc6372c17f81c1dec3bf6f03e39638816f78
parent54aa35d40e8514ab26a1334bc71ac1bf03528e7f (diff)
downloadnixpkgs-1b791763105fb69277d1021826bf0ea3721ca9f2.tar
nixpkgs-1b791763105fb69277d1021826bf0ea3721ca9f2.tar.gz
nixpkgs-1b791763105fb69277d1021826bf0ea3721ca9f2.tar.bz2
nixpkgs-1b791763105fb69277d1021826bf0ea3721ca9f2.tar.lz
nixpkgs-1b791763105fb69277d1021826bf0ea3721ca9f2.tar.xz
nixpkgs-1b791763105fb69277d1021826bf0ea3721ca9f2.tar.zst
nixpkgs-1b791763105fb69277d1021826bf0ea3721ca9f2.zip
NixOS AWS AMI: enable the serial console on ttyS0
-rw-r--r--nixos/modules/profiles/headless.nix2
-rw-r--r--nixos/modules/virtualisation/amazon-image.nix13
2 files changed, 13 insertions, 2 deletions
diff --git a/nixos/modules/profiles/headless.nix b/nixos/modules/profiles/headless.nix
index 46a9b6a7d8d..c17cb287b72 100644
--- a/nixos/modules/profiles/headless.nix
+++ b/nixos/modules/profiles/headless.nix
@@ -9,7 +9,7 @@ with lib;
   boot.vesa = false;
 
   # Don't start a tty on the serial consoles.
-  systemd.services."serial-getty@ttyS0".enable = false;
+  systemd.services."serial-getty@ttyS0".enable = lib.mkDefault false;
   systemd.services."serial-getty@hvc0".enable = false;
   systemd.services."getty@tty1".enable = false;
   systemd.services."autovt@".enable = false;
diff --git a/nixos/modules/virtualisation/amazon-image.nix b/nixos/modules/virtualisation/amazon-image.nix
index 1f3b4c3709a..7ee5c096af9 100644
--- a/nixos/modules/virtualisation/amazon-image.nix
+++ b/nixos/modules/virtualisation/amazon-image.nix
@@ -18,7 +18,15 @@ let
 in
 
 {
-  imports = [ ../profiles/headless.nix ./ec2-data.nix ./amazon-init.nix ];
+  imports = [
+    ../profiles/headless.nix
+    # Note: While we do use the headless profile, we also explicitly
+    # turn on the serial console on ttyS0 below. This is because
+    # AWS does support accessing the serial console:
+    # https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configure-access-to-serial-console.html
+    ./ec2-data.nix
+    ./amazon-init.nix
+  ];
 
   config = {
 
@@ -141,6 +149,9 @@ in
     services.openssh.enable = true;
     services.openssh.permitRootLogin = "prohibit-password";
 
+    # Enable the serial console on ttyS0
+    systemd.services."serial-getty@ttyS0".enable = true;
+
     # Creates symlinks for block device names.
     services.udev.packages = [ pkgs.ec2-utils ];