# ./modules/users/psljr/home.nix
# Configure the home environment for user psljr

{ config, pkgs, ... }:

{
  imports = [
    ./fish.nix
    ./git.nix
    ./hyprland.nix
    ./hyprlock.nix
    ./kitty.nix
    ./rofi.nix
    ./waybar.nix
  ];
  
  # Configure users with home-manager
  home-manager.users.psljr = { pkgs, ... }: {
    # Declare home state version. This should match the version of the NixOS configuration, and should not change
    home.stateVersion = "25.05";

    # Allow unfree packages
    nixpkgs.config.allowUnfree = true;

    # Accept the EULA for Android Studio
    nixpkgs.config.android_sdk.accept_license = true;

    # Define session variables for terminal use
    home.sessionVariables = {
      NIX="/etc/nixos";
      NIX_MODS="/etc/nixos/modules";
      NIX_USERS="/etc/nixos/modules/users";
    };

    # Allow home-manager to manage fonts
    fonts.fontconfig.enable = true;
    
    # Declare packages to be installed on the user profile
    home.packages = with pkgs; [
      discord
      chromium
      gparted
      helix
      htop
      jetbrains-mono
      kitty
      nerd-fonts.space-mono
      signal-desktop

      # Web
      jetbrains.webstorm
      nodejs_22
      
      # Rust
      rustc
      rustup
      jetbrains.rust-rover

      # C
      gcc
      glibc

      # LSP
      svelte-language-server
      typescript-language-server
    ];

    # Configure services
    services = {
      # hyprpaper, the wallpaper manager
      hyprpaper = {
        enable = true;
        settings = {
          preload = [
            "/etc/nixos/modules/users/psljr/theme/wallpaper.jpg"
          ];

          wallpaper = ", /etc/nixos/modules/users/psljr/theme/wallpaper.jpg";
        };
      };

      # hypridle, the idle daemon
      hypridle = {
        enable = true;

        settings = {
          general = {
            lock_cmd = "pidof hyprlock || hyprlock";
          };

          listener = [
            {
              on-resume = "brightnessctl -r";
              on-timeout = "brightnessctl -s set 10";
              timeout = 240;
            }
            {
              timeout = 900;
              on-timeout = "loginctl lock-session";
            }
          ];
        };
      };

      # hyprpolkitagent, the policykit agent
      hyprpolkitagent = {
        enable = true;
      };
    };
  };
}
