{ config, lib, pkgs, inputs, system, ... }:
let
  cfg = config.mods;
  keys = [
    "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKEio+Y5wBVD1wILaH2R3wV10FvVjiqy/4gGBWHOITTB muon@muon"
    "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKevYmkH7xvYoquBjnYZ7PJiVqf+GOh9fxAJBN6wZGBB gin4@hi.is"
    "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILmAOd9VbhyJeibt6Vrb101MNTk5W8+rh94Djv/C+pyu muon@muho"
  ];
in {
  # Hardware
  imports = [ ./hardware-configuration.nix ../ports.nix ];

  # System
  mods.user.name = "muon";
  networking.hostName = "muho";
  networking.hostId = "56e55e83";
  mods.home.file = ./home.nix;

  # Hosting
  networking.firewall.allowedTCPPorts =
    lib.attrsets.mapAttrsToList (name: value: value) cfg.server.nginx.ports;

  # Modules
  mods.desktop.enable = false;
  mods.desktop.gaming.enable = false;

  mods.boot.enable = true;

  mods.theme.enable = true;
  mods.theme.scheme = "woodland";

  mods.server.photos.enable = true;
  mods.server.search.enable = true;
  mods.server.videos.enable = true;
  mods.server.reddit.enable = true;

  mods.server.grav.enable = true;
  mods.server.homebox.enable = true;
  mods.server.share.enable = false;
  mods.server.vault.enable = true;
  mods.server.git.enable = true;
  mods.server.cal.enable = true;
  mods.server.chat.enable = false;
  mods.server.ntfy.enable = true;
  mods.server.lemmy.enable = true;
  mods.server.audio.enable = true;
  mods.server.atuin.enable = true;

  mods.server.dash.enable = false;
  mods.server.nginx.ports.dash = 3009;

  mods.tailscale.enable = true;
  mods.wireguard.id = 3;

  services.xserver.windowManager.i3.enable = false;

  users.users.muon.openssh.authorizedKeys.keys = keys;
  users.users.root.openssh.authorizedKeys.keys = keys;

  # Proprietary </3
  mods.unfree.steam.enable = false;
  mods.unfree.nvidia.enable = false;
  mods.unfree.minecraft.enable = true;

  mods.unfree.valheim.enable = false;
  mods.server.vrising.enable = false;
  # mods.server.statech.enable = true;
  # mods.server.astral.enable = true;

  # Hardware preferences

  ## Mouse
  services.libinput.mouse.accelProfile = "flat";

  ## Monitors
  mods.monitors = {
    primary = {
      name = "DVI-D-0";
      config = {
        enable = true;
        mode = "1920x1080";
        position = "0x0";
        primary = true;
        rate = "59.93";
      };
    };
    secondary = {
      name = "HDMI-0";
      config = {
        enable = true;
        mode = "1280x768";
        position = "1920x312";
        rate = "59.99";
      };
    };
  };

  # Turn off screen-saver
  environment.extraInit = ''
    xset s off -dpms
  '';

  environment.variables = {
    WINIT_HIDPI_FACTOR = "1";
    WINIT_X11_SCALE_FACTOR = "1";
  };

  boot.loader = {
    timeout = 2;
    efi.canTouchEfiVariables = true;
    grub = {
      enable = true;
      zfsSupport = true;
      efiSupport = true;
      device = "nodev";
    };
  };

  # hardware.graphics = {
  #   enable = true;
  #   enable32Bit = true;
  # };

  ## GPU (AMD Radeon 7950)
  ## https://wiki.nixos.org/wiki/AMD_GPU
  # boot.kernelParams = [ "radeon.si_support=0" "amdgpu.si_support=1" ];

  ## GPU (NVidia GTX 1060)
  ## https://nixos.wiki/wiki/Nvidia
  # hardware.nvidia.powerManagement.enable = false;

  # Version of first install
  system.stateVersion = "23.11";
}
