{ pkgs, inputs, options, ... }:

{
  imports = [ # Include the results of the hardware scan.
    ./hardware-configuration.nix
    ./de-twm.nix
    ./boot.nix
    ./filesystems.nix
    ./flatpak.nix
    ./audio.nix
    ./devtools.nix
    ./fontconfig.nix
    ./localisation.nix
    inputs.home-manager.nixosModules.home-manager
  ];

  ### NETWORKING
  networking = {
    hostName = "dpv";
    networkmanager.enable = true;
    timeServers = options.networking.timeServers.default ++ [ "time.google.com" ];
  };

  ### SERVICES
  services = {
    xserver = {
      enable = true;
      excludePackages = [ pkgs.xterm ];

      displayManager.lightdm.enable = true;

      xkb.layout = "us";
      xkb.variant = "";
    };

    ntp.enable = true;

    ## Daemons
    printing.enable = true;
    openssh.enable = true;

    ### Clipboard
    greenclip = {
      enable = true;
      package = pkgs.haskellPackages.greenclip;
    };

    gnome.gnome-keyring.enable = true;
    envfs.enable = true;
    gvfs.enable = true;
    tumbler.enable = true;
  };

  xdg.portal = {
    extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
    config.common.default = "gtk";
  };

  ### HARDWARE
  hardware = {
    graphics = {
      enable = true;
      extraPackages = with pkgs; [ intel-media-driver ];
    };
    bluetooth.enable = true;
  };

  ### SECURITY
  security.rtkit.enable = true;
  security.pam.services.lightdm.enableGnomeKeyring = true;

  ### USERS
  users = {
    groups.libvirtd.members = [ "dpv" ];
    users.dpv = {
      isNormalUser = true;
      description = "dpv";
      extraGroups = [ "networkmanager" "wheel" "libvirtd" "input" ];
      shell = pkgs.zsh;
      packages = [ ];
    };
  };

  ### PROGRAMS
  programs = {
    firefox.enable = false;
    ssh.startAgent = true;
    zsh.enable = true;
    xfconf.enable = true;
    dconf.enable = true;
    gnupg.agent = {
      enable = true;
    };
    thunar = {
      enable = true;
      plugins = [
        pkgs.xfce.thunar-archive-plugin
        pkgs.xfce.thunar-volman
        pkgs.xfce.thunar-media-tags-plugin
      ];
    };
  };

  ### UNFREE PACKAGES
  nixpkgs.config.allowUnfree = true;
  nixpkgs.config.permittedInsecurePackages = [
    "openssl-1.1.1w"
  ];

  ### PACKAGES TO INSTALL IN A SYSTEM
  environment.systemPackages = with pkgs; [
    fastfetch btop htop wget fzf ripgrep
    obsidian metasploit google-chrome home-manager
    sqlite lsd nsxiv pulseaudio
    mpc brightnessctl sdcv speedcrunch screenkey bitwarden-desktop
    keepassxc rustup gcc gnumake clang-tools nodejs pnpm
    imagemagick pandoc nixd dbeaver-bin gdu sl pavucontrol
    ffmpeg ffmpegthumbnailer p7zip rar unrar zip unzip dig nix-du
    nh graphviz libnotify drawing wmctrl android-tools libinput
    alsa-utils libsForQt5.qt5ct sublime4

    simplescreenrecorder gpick # stuff that will ONLY work in X

    inputs.zen-browser.packages.${pkgs.system}.default
  ];

  ### ENV
  environment.sessionVariables = {
    QT_QPA_PLATFORMTHEME = "qt5ct";
    QT_STYLE_OVERRIDE = "adwaita-dark";
  };
  environment.variables = {
    EDITOR = "nvim";
  };

  ### HOME MANAGER
  home-manager = {
    extraSpecialArgs = { inherit inputs; };
    users = {
      dpv = import ../user/home.nix;
    };
  };

  ### MORE NIX
  nix = {
    gc = {
      automatic = true;
      dates = "daily";
      options = "--delete-older-than 10d";
    };
    settings = {
      auto-optimise-store = true;
      experimental-features = [ "nix-command" "flakes" ];
    };
  };

  zramSwap = {
    enable = true;
    algorithm = "zstd";
    priority = 5;
  };

  system.stateVersion = "24.11";
}
