aboutsummaryrefslogtreecommitdiffstats
path: root/default.nix
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-16 10:42:58 +0000
committertv <tv@krebsco.de>2026-11-16 10:42:58 +0000
commit3d92584c98c03a59e1a26184963307f0f112e73b (patch)
tree328432b72708a0785689251c69e74aee6346ba54 /default.nix
parentbe9cbaf4b35f152aa0500a9454c4bfb90cd7d89e (diff)
pass the terminal type on the kernel command line
Passing the terminal size didn't help: the serial login still completes ~0.39s after the getty started. Unless systemd.tty.term.ttyS0 is on the kernel command line, systemd also asks the terminal for its type (via DCS +q, see query_term_for_tty in src/basic/terminal-util.c), which many terminals don't answer, so it waits for the 333ms timeout. Pass $TERM along with the size.
Diffstat (limited to 'default.nix')
-rw-r--r--default.nix16
1 files changed, 10 insertions, 6 deletions
diff --git a/default.nix b/default.nix
index e757b8e..8f64d78 100644
--- a/default.nix
+++ b/default.nix
@@ -84,7 +84,7 @@ let
boot-source = {
kernel_image_path = "${kernel.dev}/vmlinux";
initrd_path = "${initialRamdisk}/${nixos.config.system.boot.loader.initrdFile}";
- boot_args = toString (nixos.config.boot.kernelParams ++ [ "init=${toplevel}/init" "@TTY_SIZE@" ]);
+ boot_args = toString (nixos.config.boot.kernelParams ++ [ "init=${toplevel}/init" "@TTY_ARGS@" ]);
};
network-interfaces = [{
iface_id = "eth0";
@@ -137,12 +137,16 @@ pkgs.writeShellScriptBin "run-firecracker-vm" ''
find "$cache" -type f ! -path "$img" -delete
fi
- # Tell systemd the terminal size, so it doesn't query it via ANSI
- # sequences (and wait up to 333ms for an answer) when starting the getty.
- tty_size=
+ # Tell systemd the terminal's type and size, so it doesn't query them via
+ # ANSI sequences (and wait up to 333ms for each answer) when starting the
+ # getty.
+ tty_args=
+ if test -n "''${TERM-}"; then
+ tty_args="systemd.tty.term.ttyS0=$TERM"
+ fi
if size=$(stty size 2>/dev/null) && test "$size" != "0 0"; then
read -r rows cols <<< "$size"
- tty_size="systemd.tty.rows.ttyS0=$rows systemd.tty.columns.ttyS0=$cols"
+ tty_args="$tty_args systemd.tty.rows.ttyS0=$rows systemd.tty.columns.ttyS0=$cols"
fi
mkdir -p xchg
@@ -152,7 +156,7 @@ pkgs.writeShellScriptBin "run-firecracker-vm" ''
sed \
-e "s|@STORE_IMAGE@|$img|" \
-e "s|@XCHG_IMAGE@|$tmp/xchg.img|" \
- -e "s|@TTY_SIZE@|$tty_size|" \
+ -e "s|@TTY_ARGS@|$tty_args|" \
${config} > "$tmp"/config.json
status=0
firecracker --no-api --config-file "$tmp"/config.json || status=$?