aboutsummaryrefslogtreecommitdiffstats
path: root/layers/console.nix
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-21 05:19:09 +0000
committertv <tv@krebsco.de>2026-11-21 05:19:09 +0000
commit0c8d9e30cb8fb9b42d1093540a2b73901c770fc5 (patch)
tree0a9d0b57c20eb2d7cdb629ed02d6199b007e7971 /layers/console.nix
parent5e77974dc9953b162610b6c3bc0a1362c72cf291 (diff)
layers/console.nix: a shell on the serial console, to import into a layer
Since the base system turned off the console (and with it kbd), it had no getty at all: NixOS's gettys come with the console (services/ttys/getty.nix), so there was no shell on ttyS0 any more, only the kernel's and systemd's messages, and ssh. That stays the default, and the base system's console.enable is only that now, a default, for layers/console.nix: the console, with root logged in on ttyS0 (a default, too: services.getty.autologinUser can name another user, or be null for a login prompt), but no getty on tty1, and no systemd-vconsole-setup, which moved there from the base system, like the autologin. It's small, so the README has it imported into another layer, rather than as a layer, with an image, of its own, which works, too.
Diffstat (limited to 'layers/console.nix')
-rw-r--r--layers/console.nix23
1 files changed, 23 insertions, 0 deletions
diff --git a/layers/console.nix b/layers/console.nix
new file mode 100644
index 0000000..378e3fa
--- /dev/null
+++ b/layers/console.nix
@@ -0,0 +1,23 @@
+# A shell on the serial console, i.e. in the run script's terminal: root,
+# logged in, unless services.getty.autologinUser says otherwise (another
+# user, or null for a login prompt, which needs a password). Small, so
+# better imported by another layer than a layer, with an image, of its
+# own:
+# imports = [ /path/to/firecracker/layers/console.nix ];
+# though that works, too:
+# --arg layers '[ layers/console.nix ./my-layer.nix ]'
+# Without it, the guest has no console (no getty, no kbd), and the way in
+# is ssh (see users.users.<name>.openssh.authorizedKeys in a layer).
+{ lib, ... }:
+{
+ # NixOS's gettys come with the console (services/ttys/getty.nix), and
+ # with them kbd and systemd-vconsole-setup, which has nothing to do
+ # here, but would still get started at boot.
+ console.enable = true;
+ systemd.units."systemd-vconsole-setup.service".enable = lib.mkForce false;
+
+ # Only on ttyS0 (console= on the kernel command line, which systemd's
+ # getty generator goes by), not on tty1.
+ services.getty.autologinUser = lib.mkDefault "root";
+ systemd.targets.getty.wants = lib.mkForce [ ];
+}