# customize nixos-rebuild build-vm to be a bit more convenient
{ pkgs, ... }:
{
  # let us log in
  users.mutableUsers = false;
  users.users.root.hashedPassword = "";
  services.openssh = {
    enable = true;
    settings = {
      PermitRootLogin = "yes";
      PermitEmptyPasswords = "yes";
      UsePAM = false;
    };
  };

  # automatically log in
  services.getty.autologinUser = "root";
  services.getty.helpLine = ''
    Type `C-a c` to access the qemu console
    Type `C-a x` to quit
  '';
  # access to convenient things
  environment.systemPackages = with pkgs; [
    w3m
    python3
    xterm # for `resize`
  ];
  environment.loginShellInit = ''
    eval "$(resize)"
  '';
  nix.extraOptions = ''
    extra-experimental-features = nix-command flakes
  '';

  virtualisation.memorySize = 2048;

  virtualisation.forwardPorts = [
    {
      from = "host";
      host.port = 22222;
      guest.port = 22;
    }
    {
      from = "host";
      host.port = 8080;
      guest.port = 80;
    }
    {
      from = "host";
      host.port = 8443;
      guest.port = 443;
    }
  ];
}