{ inputs, lib, config, pkgs, ... }:
# let
#   unstable = import inputs.nixpkgs-unstable { system = "x86_64-linux"; config.allowUnfree = true; };
# in
{
  options.hyprhome = {
    enable = lib.mkEnableOption "Enable hyprland home config";
    homePackages = lib.mkOption {
        default = [];
        description = "Add any additional packages desired. Merged with hyprland defaults.";
    };
  };

  config = lib.mkIf config.hyprhome.enable {
    # Note: We don't use wayland.windowManager.hyprland.enable
    # because it generates config files that conflict with our dotfiles.
    # Instead, we install hyprland via packages and manage config manually.

    # Import systemd variables for hyprland
    systemd.user.sessionVariables = {
      WAYLAND_DISPLAY = "wayland-1";
      XDG_CURRENT_DESKTOP = "Hyprland";
    };

    home.pointerCursor = {
      gtk.enable = true;
      hyprcursor.enable = true;
      x11.enable = true;
      hyprcursor.size = 32;
      name = "Bibata-Modern-Classic";
      package = pkgs.bibata-cursors;
      size = 32;
    };
    # home.sessionVariables = {
    # };
    home.packages = with pkgs; lib.lists.flatten [
      [
        ### hyprland packages
        swaybg
        swaylock-effects
        waybar
        wofi
        # NWG
        nwg-bar
        nwg-menu
        nwg-look
        nwg-dock-hyprland
        nwg-panel
        nwg-drawer
        nwg-launchers
        # Hypr Utils
        hyprpicker
        hyprshot
        hypridle
        kanshi
        # Etc
        gopsuinfo # For system stats in panel
        wl-clipboard # System clipboard
        brightnessctl
        wev
        wdisplays
        # Notifs
        libnotify
        swaynotificationcenter
        # Tray Applets
        networkmanagerapplet
        pavucontrol
        syncthingtray
        tailscale-systray
        # include portals here for flatpak
        xdg-desktop-portal-hyprland
        xdg-desktop-portal-gtk
      ]
      config.hyprhome.homePackages
    ];
    programs.cava = {
      enable = true;
      settings = {
        smoothing.noise_reduction = 55;
      };
    };
  };
}
