#
# Per-system configuration for Laudna.
#
# vim: et:ts=2:sw=2:
#
{
  config,
  deprekages,
  pkgs,
  lib,
  modulesPath,
  ...
}:

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

  networking.hostName = "laudna";

  #
  # CLion server support (experimental).
  #
  nixpkgs.overlays = [ (import ../overlays/clion/default.nix) ];
  environment.systemPackages = [
    pkgs.jetbrains.clion
    pkgs.dsview
  ];

  #
  # Hardware setup.
  #

  # Bootloader.
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;
  boot.loader.efi.efiSysMountPoint = "/boot/efi";
  boot.loader.systemd-boot.memtest86.enable = true;

  # As a build server, Laudna should never sleep.
  systemd.targets.sleep.enable = false;
  systemd.targets.suspend.enable = false;
  systemd.targets.hibernate.enable = false;
  systemd.targets.hybrid-sleep.enable = false;

  #
  # Drivers
  #
  services.xserver.videoDrivers = [ "nvidia" ];

  hardware.opengl.enable = true;
  hardware.opengl.driSupport = true;
  hardware.enableRedistributableFirmware = true;
  hardware.nvidia.modesetting.enable = true;
  hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.stable;

  boot.kernelPackages = pkgs.linuxPackages_latest;

  #
  # Services.
  #
  networking.networkmanager.enable = true;
  services.onedrive.enable = true;

  #
  # Extra packages for Laudna.
  #

  #
  # Hardware configuration.
  #
  boot.initrd.availableKernelModules = [
    "nvme"
    "xhci_pci"
    "ahci"
    "usb_storage"
    "usbhid"
    "sd_mod"
  ];
  boot.extraModulePackages = [ ];

  fileSystems."/" = {
    device = "/dev/disk/by-uuid/14ed4687-28ab-4c74-822f-137e785e8acd";
    fsType = "ext4";
  };

  fileSystems."/boot/efi" = {
    device = "/dev/disk/by-uuid/B368-B3DB";
    fsType = "vfat";
  };

  swapDevices = [ { device = "/dev/disk/by-uuid/4d40dc84-693f-4ac9-ac08-c374ada4bbbd"; } ];

  # 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.enp7s0.useDHCP = lib.mkDefault true;
  # networking.interfaces.wlp6s0.useDHCP = lib.mkDefault true;

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