{ config, pkgs, host, lib, inputs, userconf, ... }:

let
  # Load user-specific variables
  userVars = import ./variables/user-vars.nix;
  inherit (userVars) username gitUsername gitEmail keyboardLayout;
  nixDirectory = "/home/${username}/NixOS";
in {
  ################################################################
  # Module Imports
  ################################################################

  imports = [
    # Host-specific hardware configuration (autogenerated)
    ./hardware-configuration.nix

    # System-level user definition
    ./user.nix

    # Base and global modules
    ../../../Modules/System

    # Home Manager integration
    inputs.home-manager.nixosModules.home-manager

    # nixos95
    inputs.self.nixosModules.nixos95

  ];
  ################################################################
  # Display & Desktop Environment
  ################################################################

  nixos95 = {
    enable = true;
    user = username;

    taskbar = {
      homeIcon = "whisker-menu-button";
      battery-plugin.enable = false;
      applications = [
        {
          name = "Brave";
          description = "Browse the Web";
          pkg = pkgs.brave;
          icon = "world";
        }
        {
          name = "Signal";
          description = "Private Messenger";
          pkg = pkgs.signal-desktop;
          icon = "signal";
        }
        {
          name = "Obsidian";
          description = "Markdown Editor";
          exe = "obsidian %u";
          icon = "obsidian";
        }
        {
          name = "Spotify";
          description = "Spotify Music";
          exe = "spotify %U";
          icon = "spotify";
        }
      ];
    };

    keybinds = {
      commands = [
        { key="<Super>l";  exe="xflock4"; }
      ];
    };
  };

  ################################################################
  # System Packages (XFCE & Utilities)
  ################################################################

  environment.systemPackages = with pkgs; [

    # Optional Extras
    xfce.gigolo
    xfce.xfce4-screenshooter
    xfce.parole
    # xfce.xfce4-clipman
    
    # other:
    zsh


  ];



  programs.steam = {
      enable = true;
      remotePlay.openFirewall = true; # Open ports in the firewall for Steam Remote Play
      dedicatedServer.openFirewall = true; # Open ports in the firewall for Source Dedicated Server
      localNetworkGameTransfers.openFirewall = true; # Open ports in the firewall for Steam Local Network Game Transfers
    };

  services.openssh.enable = true;

  programs.zsh = {
      enable = true;
      ohMyZsh = {
        enable = true;
        theme = "xiong-chiamiov-plus";
        plugins = ["git"];
      };
    };





  ################################################################
  # Home Manager Configuration
  ################################################################

  home-manager = {
    useGlobalPkgs = true;
    useUserPackages = true;
    backupFileExtension = "delme-HMbackup";

    users.${username} = import ./home/home.nix {
      inherit config nixDirectory pkgs;
    };
  };

  ################################################################
  # Bootloader
  ################################################################

  boot.loader = {
    grub = {
      enable = true;
      efiSupport = false;
      useOSProber = false;
      devices = ["nodev"];
    };
    systemd-boot.enable = false;
    efi.canTouchEfiVariables = false;
  };

  ################################################################
  # System Version
  ################################################################

  system.stateVersion = "25.05";
}
