{ config, pkgs, ... }:
let
	# Theme/Mode
	THEME = "nord";
	MODE = "dark";

	# Colours
	inherit (import ./themes/${THEME}_${MODE}.nix) BG FG GRAY DARK_GRAY RED DARK_RED GREEN DARK_GREEN YELLOW DARK_YELLOW BLUE DARK_BLUE PURPLE DARK_PURPLE CYAN DARK_CYAN;
	ACCENT = "${BLUE}";
	ACTIVE_BORDER_COLOR = "${ACCENT}";
	INACTIVE_BORDER_COLOR = "${FG}";

	# Programs
	MENU = "fuzzel";
	TERMINAL = "kitty";

	# Numbers
	GAPS_IN = "10";
	GAPS_OUT = "20";
	BORDER_WIDTH = "2";
	CORNER_RADIUS = "10";
	WAYBAR_CORNER_RADIUS = "15";
	TERMINAL_OPACITY = "0.7";
	SCREEN_HEIGHT = 1080;
	SCREEN_WIDTH = 1920;
	FUZZEL_WIDTH = "25";
	FUZZEL_HEIGHT = "15";
	FUZZEL_OPACITY = "99";

	# Other
	HOME = "/home/deadvey";
	WALLPAPER = "${THEME}_${MODE}.png";
	WALLPAPER_PATH = "${HOME}/.config/home-manager/themes/${WALLPAPER}";
	FONT = "VictorMono Nerd Font Mono";
	FUZZEL_PROMPT = " >>     ";
in
{
  

  # Home Manager needs a bit of information about you and the paths it should
  # manage.
  home.username = "deadvey";
  home.homeDirectory = "/home/deadvey";

  # Disable nixpkgs release check
  home.enableNixpkgsReleaseCheck = false;

  # This value determines the Home Manager release that your configuration is
  # compatible with. This helps avoid breakage when a new Home Manager release
  # introduces backwards incompatible changes.
  #
  # You should not change this value, even if you update Home Manager. If you do
  # want to update the value, then make sure to first check the Home Manager
  # release notes.
  home.stateVersion = "24.11"; # Please read the comment before changing.

  # The home.packages option allows you to install Nix packages into your
  # environment.
  home.packages = with pkgs; [
  	librewolf
	hyprland
	hyprpicker
	hyprpaper
	hyprlock
	hypridle
	hyprcursor
	fuzzel
	waybar
	kitty
	dunst
	fastfetch
	mpv
	anki
	minetest
	gimp
	fractal
    # # It is sometimes useful to fine-tune packages, for example, by applying
    # # overrides. You can do that directly here, just don't forget the
    # # parentheses. Maybe you want to install Nerd Fonts with a limited number of
    # # fonts?
    # (pkgs.nerdfonts.override { fonts = [ "FantasqueSansMono" ]; })

    # # You can also create simple shell scripts directly inside your
    # # configuration. For example, this adds a command 'my-hello' to your
    # # environment:
    # (pkgs.writeShellScriptBin "my-hello" ''
    #   echo "Hello, ${config.home.username}!"
    # '')
  ];
  programs = {
  	  vim = {
	  	defaultEditor = true;
	  	enable = true;
	  	settings = {
			relativenumber=true;
		};
	  };
	  bash = {
	    enable = true;
	    shellAliases = {
		vim="nvim";
		ls="ls -l";
	    };
	    bashrcExtra=''
	    	PS1="[\[\033[32m\]\w]\[\033[0m\]\n\[\033[1;36m\]\u\[\033[1;33m\] => \[\033[0m\]"
	    	fastfetch
	    '';
	  };
	  git = {
	    enable = true;
	    userName  = "deadvey";
	    userEmail = "deadvey@nixos";
	  };
	  kitty = {
		enable = true;
		settings = {
			confirm_os_window_close = 0;
			background_opacity = "${TERMINAL_OPACITY}";
			foreground = "#${FG}";
			background = "#${BG}";
			selection_foreground = "#${BG}";
			selection_background = "#${FG}";
			color0 = "#${GRAY}";
			color8 = "#${BG}";
			color1 = "#${RED}";
			color9 = "#${DARK_RED}";
			color2 = "#${GREEN}";
			color10 = "#${DARK_GREEN}";
			color3 = "#${YELLOW}";
			color11 = "#${DARK_YELLOW}";
			color4 = "#${BLUE}";
			color12 = "#${DARK_BLUE}";
			color5 = "#${PURPLE}";
			color13 = "#${DARK_PURPLE}";
			color6 = "#${BLUE}";
			color14 = "#${DARK_BLUE}";
			color7 = "#${GRAY}";
			color15 = "#${DARK_GRAY}";
		};
		font = {
			name = "VictorMono Nerd Font Mono";
			package = pkgs.victor-mono;
			size = 8;
		};
	  };
	  hyprlock = {
		enable = true;
		settings = {
			general = {
				disable_loading_bar = true;
				grace = 1;
				no_fade_in = false;
			};
			background = [
				{
					path = "${WALLPAPER_PATH}";
				}
			];
			input-field = [
			    {
			      size = "200, 50";
			      position = "0, 0";
			      dots_rounding = "${CORNER_RADIUS}";
			      dots_center = true;
			      fade_on_empty = true;
			      font_color = "${FG}";
			      inner_color = "${FG}";
			      outer_color = "${ACCENT}";
			      outline_thickness = "${BORDER_WIDTH}";
			      placeholder_text = "Password...";
			      fail_text = "😬 Oooooh that was wrong mate!⚠️";
			    }
			];
		};	
	  };
	  fuzzel = {
		enable = true;
		settings = {
			main = {
				prompt = "${FUZZEL_PROMPT}";
				width = "${FUZZEL_WIDTH}";
				lines = "${FUZZEL_HEIGHT}";
				icons-enables = "no";
				font = "${FONT}";
			};
			colors = {
				background = "${BG}${FUZZEL_OPACITY}";
				border = "${ACCENT}ff";
				match = "${RED}ff";
				selection = "${FG}ff";
				selection-text = "${BG}ff";
				text = "${FG}ff";
				prompt = "${FG}ff";
				input = "${FG}ff";
			};
			border = {
				width = "${BORDER_WIDTH}";
				radius = "${CORNER_RADIUS}";
			};
		};
	  };
	  waybar = {
		enable = true;
		settings = {
			screenBorder = {
				mode = "overlay";
				layer = "bottom";
				position = "top";
				height = SCREEN_HEIGHT;
				width = SCREEN_WIDTH;
				modules-center = ["custom/empty"];
				"custom/empty" = {
					format = " ";
					interval = 1;
				};
			};
		};
		style = ''
			window {
				border: ${BORDER_WIDTH}px solid #${ACCENT};
				background-color: transparent;
				box-shadow: 0px 0px 0px 60px black, 0px 0px 0px 0.5px #${FG};
				border-radius: ${WAYBAR_CORNER_RADIUS}px;
				margin: 20px;
			}
		'';
	  };
  };
  services = {
	  hyprpaper = {
		enable = true;
		settings = {
			ipc = "on";
			preload = [ "${WALLPAPER_PATH}" ];
			wallpaper = [ "HDMI-A-1,${WALLPAPER_PATH}" ];
		};
	  };
  };
  wayland = {
  	windowManager = {
		hyprland = {
			enable = true;
			extraConfig = ''
				exec-once="waybar"; 
				exec-once="dunst";
				exec-once="wpaperd -d -c $HOME/.config/wpaperd/wallpaper.toml";
			'';
			settings = {
				"$mod" = "SUPER";
				general = {
					gaps_in = "${GAPS_IN}";
					gaps_out = "${GAPS_OUT}";
					border_size = "${BORDER_WIDTH}";
					"col.active_border" = "rgb(${ACCENT})";
					"col.inactive_border" = "rgb(${INACTIVE_BORDER_COLOR})";
					resize_on_border = false;
					layout = "dwindle";
				};
				decoration = {
					rounding="${CORNER_RADIUS}";
				};
				input = {
					kb_layout = "gb";
				};
				bindm = [
					"$mod, mouse:272, movewindow"
					"$mod, mouse:273, resizewindow"
				];
				bind = [
					"$mod, Space, exec, ${MENU}"
					"$mod, Q, exec, ${TERMINAL}"
					"$mod, P, exec, grimshot copy area"
					"$mod, L, exec, hyprlock"
					"$mod, C, killactive"
					"$mod, M, fullscreen, 1"
					"$mod SHIFT, E, exit"
					"$mod, J, togglesplit,"
					"$mod, V, toggleFloating,"
					"$mod, U, pseudo,"
					"$mod SHIFT, Q, exit"
					"$mod, left, movefocus, l"
					"$mod, right, movefocus, r"
					"$mod, up, movefocus, u"
					"$mod, down, movefocus, d"
					"$mod SHIFT, left, movewindow, l"
					"$mod SHIFT, right, movewindow, r"
					"$mod SHIFT, up, movewindow, u"
					"$mod SHIFT, down, movewindow, d"
					"$mod, 1, workspace, 1"
					"$mod, 2, workspace, 2"
					"$mod, 3, workspace, 3"
					"$mod, 4, workspace, 4"
					"$mod, 5, workspace, 5"
					"$mod, 6, workspace, 6"
					"$mod, 7, workspace, 7"
					"$mod, 8, workspace, 8"
					"$mod, 9, workspace, 9"
					"$mod, 0, workspace, 10"
					"$mod SHIFT, 1, movetoworkspace, 1"
					"$mod SHIFT, 2, movetoworkspace, 2"
					"$mod SHIFT, 3, movetoworkspace, 3"
					"$mod SHIFT, 4, movetoworkspace, 4"
					"$mod SHIFT, 5, movetoworkspace, 5"
					"$mod SHIFT, 6, movetoworkspace, 6"
					"$mod SHIFT, 7, movetoworkspace, 7"
					"$mod SHIFT, 8, movetoworkspace, 8"
					"$mod SHIFT, 9, movetoworkspace, 9"
					"$mod SHIFT, 0, movetoworkspace, 10"
				];
				
			};
		};
  	};
  };
  # Home Manager is pretty good at managing dotfiles. The primary way to manage
  # plain files is through 'home.file'.
  home.file = {
    # # Building this configuration will create a copy of 'dotfiles/screenrc' in
    # # the Nix store. Activating the configuration will then make '~/.screenrc' a
    # # symlink to the Nix store copy.
    # ".screenrc".source = dotfiles/screenrc;

    # # You can also set the file content immediately.
    # ".gradle/gradle.properties".text = ''
    #   org.gradle.console=verbose
    #   org.gradle.daemon.idletimeout=3600000
    # '';
  };

  # Home Manager can also manage your environment variables through
  # 'home.sessionVariables'. These will be explicitly sourced when using a
  # shell provided by Home Manager. If you don't want to manage your shell
  # through Home Manager then you have to manually source 'hm-session-vars.sh'
  # located at either
  #
  #  ~/.nix-profile/etc/profile.d/hm-session-vars.sh
  #
  # or
  #
  #  ~/.local/state/nix/profiles/profile/etc/profile.d/hm-session-vars.sh
  #
  # or
  #
  #  /etc/profiles/per-user/deadvey/etc/profile.d/hm-session-vars.sh
  #
  home.sessionVariables = {
    # EDITOR = "emacs";
  };

  # Let Home Manager install and manage itself.
  programs.home-manager.enable = true;
}