{
  config,
  lib,
  inputs,
  pkgs,
  timeZone,
  ...
}:
let
  deskCfg = config.deskCfg;
in
{
  imports = [
    ./nixos/hardware-configuration.nix
    ./modules/sway/sway_conf.nix
    ../../shared/modules/desktop/base.nix
    ../../shared/modules/desktop/stylix.nix
    ../../shared/modules/desktop/silent-boot.nix
    ../../shared/modules/desktop/greetd.nix
    ../../shared/modules/wm/niri.nix
    ../../shared/modules/services/syncthing.nix
    ../../shared/modules/services/kdeconnect.nix
    ../../shared/modules/services/docker.nix
    ../../shared/modules/services/tailscale.nix
    ../../shared/modules/services/avahi.nix
    ../../shared/modules/services/motu-m4-combined.nix
  ];

  deskCfg = {
    userName = "nate";
    hostName = "winmax";
    fullName = "Nate Anderson";
    de = "niri";
    installGaming = true;
  };

  # Stylix — derive color scheme from wallpaper
  stylix = {
    image = ./bot-wallpaper.jpg;
    base16Scheme = "${pkgs.base16-schemes}/share/themes/kimber.yaml";
    fonts.sizes = {
      applications = 14;
      desktop = 16;
      popups = 14;
      terminal = 14;
    };
  };

  # Limit the number of generations to keep
  boot.loader.systemd-boot.configurationLimit = 5;

  # Systemd initrd for faster boot
  boot.initrd.systemd.enable = true;

  # Silent boot
  silentBoot.enable = true;

  # Plymouth boot animation
  boot.plymouth = {
    enable = true;
    theme = "rings";
    themePackages = with pkgs; [
      (adi1090x-plymouth-themes.override {
        selected_themes = [ "rings" ];
      })
    ];
  };

  # Perform garbage collection weekly to maintain low disk usage
  nix.gc = {
    automatic = true;
    dates = "weekly";
    options = "--delete-older-than 14d";
  };
  nix.settings.auto-optimise-store = true;

  # Extra groups
  main_user.extraGroups = [
    "dialout"
    "docker"
    "i2c"
    "lp"
    "scanner"
    "syncthing"
  ];

  # Sway WM (legacy, kept for fallback)
  swaywm = {
    enable = deskCfg.de == "sway";
    useNonFree = true;
    installGaming = deskCfg.installGaming;
    systemPackages = [ ];
  };

  # Niri WM config
  niriwm = {
    enable = deskCfg.de == "niri";
    useNonFree = true;
    user = deskCfg.userName;
    installGaming = deskCfg.installGaming;
    systemPackages = [ ];
  };

  # Steam with remote play + gamescope
  programs.steam = {
    enable = true;
    remotePlay.openFirewall = true;
    gamescopeSession.enable = true;
  };

  # MOTU M4 audio interface
  services.motu-m4-combined = {
    enable = true;
    user = deskCfg.userName;
    latencyMs = 10;
  };

  # ADB for Android
  programs.adb.enable = true;

  # usbmuxd for iOS
  services.usbmuxd.enable = true;

  # Nate-specific session variables
  environment.sessionVariables = {
    FIREFOX_USE_SYSTEM_THEME = "true";
    GTK_THEME = "stylix";
  };

  # Firewall — allow dev server ports
  networking.firewall = {
    enable = true;
    allowedTCPPorts = [
      8080
      8081
    ];
  };

  # Bluetooth
  hardware.bluetooth.settings.General = {
    Name = "Nate-WinMax";
    Privacy = "device";
    JustWorksRepairing = "always";
    Class = "0x000100";
  };
  hardware.xpadneo.enable = true;

  # AMD GPU setup (WinMax uses AMD)
  services.xserver.videoDrivers = [ "amdgpu" ];
  # Enable HIP for ROCm
  systemd.tmpfiles.rules = [
    "L+    /opt/rocm/hip   -    -    -     -    ${pkgs.rocmPackages.clr}"
  ];
  hardware.graphics = {
    enable = true;
    enable32Bit = true;
    extraPackages = with pkgs; [
      rocmPackages.clr.icd
    ];
  };

  system.stateVersion = "23.11";
}
