#
# Per-system configuration for Veth.
#
# vim: et:ts=2:sw=2:
#
{
  config,
  deprekages,
  pkgs,
  lib,
  modulesPath,
  ...
}:
{
  system.stateVersion = "23.11";

  imports = [
    (modulesPath + "/installer/scan/not-detected.nix")
  ];

  # Bootloader.
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;

  # Networking.
  networking.hostName = "veth";
  networking.networkmanager.enable = true;
  networking.firewall.enable = false;

  # This is a local machine, rather than our typical network-accesed ones.
  # Run an ssh-agent locally.
  programs.ssh.startAgent = true;

  #
  # Rotate the screen.
  #
  boot.kernelParams = [ "fbcon=rotate:1" ];

  # Wayland+weston doesn't seem to rotate properly, so we'll run SDDM on X.
  services.displayManager.sddm.wayland.enable = lib.mkForce false;
  services.xserver = {
    enable = true;

    displayManager = {

      # Rotate SDDM.
      setupCommands = ''
        ${pkgs.xorg.xrandr}/bin/xrandr --output eDP-1 --auto --rotate right;
      '';
    };

  };

  #
  # Niri configuration for our monitors.
  #
  home-manager.users.deprekated.programs.niri.settings = {
    outputs."eDP-1".transform.rotation = 270;
  };

  # Override stylix font sizes.
  stylix.fonts.sizes.desktop = lib.mkForce 32;

  #
  # Undervolting.
  #
  services.undervolt = {
    enable = true;

    # Voltages are in mV.
    coreOffset = -70;
    gpuOffset = -100;
  };

  #
  # Hardware config.
  #
  boot.initrd.availableKernelModules = [
    "xhci_pci"
    "usb_storage"
    "usbhid"
    "sd_mod"
    "sdhci_pci"
  ];
  boot.initrd.kernelModules = [ ];
  boot.kernelModules = [ "kvm-intel" ];
  boot.extraModulePackages = [ ];

  fileSystems."/" = {
    device = "/dev/disk/by-uuid/04ac3013-5745-4194-a469-d4beee909a34";
    fsType = "ext4";
  };

  fileSystems."/boot" = {
    device = "/dev/disk/by-uuid/134E-5DB2";
    fsType = "vfat";
    options = [
      "fmask=0022"
      "dmask=0022"
    ];
  };

  swapDevices = [ ];

  # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
  # (the default) this is the recommended approach. When using systemd-networkd it's
  # still possible to use this option, but it's recommended to use it in conjunction
  # with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
  networking.useDHCP = lib.mkDefault true;
  # networking.interfaces.wlp1s0.useDHCP = lib.mkDefault true;

  nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
  hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}
