nixos-generators/formats/vm-nogui.nix
2019-01-17 22:01:05 +01:00

21 lines
560 B
Nix

{ pkgs, ... }:
let
resize = pkgs.writeScriptBin "resize" ''
old=$(stty -g)
stty raw -echo min 0 time 5
printf '\033[18t' > /dev/tty
IFS=';t' read -r _ rows cols _ < /dev/tty
stty "$old"
stty cols "$cols" rows "$rows"
''; # https://unix.stackexchange.com/questions/16578/resizable-serial-console-window
in {
imports = [
./vm.nix
];
virtualisation.graphics = false;
virtualisation.qemu.options = [ "-serial mon:stdio" ];
environment.systemPackages = [ resize ];
environment.loginShellInit = "${resize}/bin/resize";
}