{ config, lib, pkgs, ... }:
with lib;
let 
  cfg = config.base;
in {
  options.base = {
    name = mkOption {
      type = types.str;
      example = "server-1";
      description = "Name of the machine, use for hostname";
    };
    domainName = mkOption {
      type = types.str;
      example = "example.com";
      description = "Domain of the machine, use for hostname";
    };
    adminEmail = mkOption {
      type = types.str;
      example = "example@example.com";
      description = "Email of the admin, use for ACME and stuff";
    };
    swapSize = mkOption {
      type = types.int;
      default = 1024;
      example = 2048;
      description = "Size of the swap file";
    };
  };
  config = {
    swapDevices = [
      {
        device = "/swapfile";
        priority = 0;
        size = cfg.swapSize;
      }
    ];
  
    boot.kernelParams = [ "console=tty0" "console=ttyS0,115200"];
    services.qemuGuest.enable = true;

    system.autoUpgrade.enable = true;
    system.autoUpgrade.allowReboot = true;
  
    networking.hostName = "${cfg.name}";
  
    time.timeZone = "Europe/Paris";
  
    console = {
      font = "Lat2-Terminus16";
      keyMap = "fr";
    };
  
    environment.systemPackages = with pkgs; [
      vim
      git
      wget
    ];
  
    services.openssh.enable = true;
  };
}