{ config, pkgs, lib, ... }:

let
  theme = import ../modules/theme;
in
{
  services = {
   xserver = {
      enable = true;
      xkbOptions = "caps:escape";
      displayManager = {
        lightdm = {
          enable = true;
          greeters.gtk = {
            enable = true;
            theme = theme.gtkTheme pkgs;
          };
          background = theme.wallpaper;
        };
        defaultSession = "none+i3";
      };
      windowManager.i3 = {
        enable = true;
        # Don't install dmenu, i3status, and i3lock
        extraPackages = lib.mkOverride 0 [];
      };
    };
    udev.packages = [ pkgs.yubikey-personalization ];
    pcscd.enable = true;
    gnome.gnome-keyring.enable = true; # For remembering nextcloud login, among other things
    gvfs.enable = true; # For Trash
  };

  networking = {
    networkmanager.enable = true;
    resolvconf.enable = false; # prevent default nameservers
    nameservers = [ "1.1.1.1" "1.0.0.1" ];
  };

  xdg.portal.enable = true;

  environment.systemPackages = with pkgs; [ yubioath-flutter ];

  environment.sessionVariables = {
    # GTK Theme won't display with GTK4 (e.g. nautilus) otherwise
    # Doesn't work in some scenarios, such as open containing folder in Firefox, when declared in home.sessionVariables
    GTK_THEME = (theme.gtkTheme pkgs).name;
  };

  # Enable OpenTabletDriver, GUI configurator is otd-gui
  hardware.opentabletdriver.enable = true;

  # Scanners
  hardware.sane.enable = true;

  # To prevent `Unit dconf.service not found.` after theming GTK in HM
  programs.dconf.enable = true;

  networking.extraHosts = ''
    192.168.0.26 elnuhub
    24.199.72.8  elnudrop
  '';

  #sound.enable = true;
  #hardware.pulseaudio.enable = true;
  #nixpkgs.config.pulseaudio = true;

  # rtkit is optional but recommended
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
    # If you want to use JACK applications, uncomment this
    #jack.enable = true;
  };

  fonts = {
    enableDefaultFonts = false;
    fonts = with pkgs; [
      noto-fonts-cjk
      noto-fonts
      (nerdfonts.override { fonts = [ "FiraCode" ]; }) # required for icons
      twitter-color-emoji
    ];
  };
}
