{
  lib,
  config,
  ...
}: let
  inherit (lib) mkIf mkEnableOption mkOption types catppuccin;
  cfg = config.horseman.dots.kitty;
  username = config.horseman.username;
  colors = config.horseman.catppuccin.colors;
in {
  options = {
    horseman.dots.kitty = {
      enable = mkEnableOption "~/.config/kitty/kitty.conf";

      fontSize = mkOption {
        type = types.int;
        default = 11;
      };

      opacity = mkOption {
        type = types.number;
        default = 0.5;
      };
    };
  };

  config = mkIf cfg.enable {
    home-manager.users.${username}.xdg.configFile."kitty/kitty.conf".text = ''
      enable_audio_bell no
      confirm_os_window_close 0

      background_opacity ${toString cfg.opacity}

      font_family      family='CaskaydiaCove Nerd Font' postscript_name=CaskaydiaCoveNF-Light
      bold_font        family='CaskaydiaCove Nerd Font' style=SemiBold
      italic_font      family='CaskaydiaCove Nerd Font' postscript_name=CaskaydiaCoveNF-LightItalic
      bold_italic_font family='CaskaydiaCove Nerd Font' style='SemiBold Italic'
      font_size ${toString cfg.fontSize}

      # The basic colors
      foreground              ${catppuccin.toHex colors.text}
      background              ${catppuccin.toHex colors.base}
      selection_foreground    ${catppuccin.toHex colors.base}
      selection_background    ${catppuccin.toHex colors.rosewater}

      # Cursor colors
      cursor                  ${catppuccin.toHex colors.rosewater}
      cursor_text_color       ${catppuccin.toHex colors.base}

      # URL underline color when hovering with mouse
      url_color               ${catppuccin.toHex colors.rosewater}

      # Kitty window border colors
      active_border_color     ${catppuccin.toHex colors.lavender}
      inactive_border_color   ${catppuccin.toHex colors.overlay0}
      bell_border_color       ${catppuccin.toHex colors.yellow}

      # OS Window titlebar colors
      wayland_titlebar_color system
      macos_titlebar_color   system

      # Tab bar colors
      active_tab_foreground   ${catppuccin.toHex colors.crust}
      active_tab_background   ${catppuccin.toHex colors.mauve}
      inactive_tab_foreground ${catppuccin.toHex colors.text}
      inactive_tab_background ${catppuccin.toHex colors.mantle}
      tab_bar_background      ${catppuccin.toHex colors.crust}

      # Colors for marks (marked text in the terminal)
      mark1_foreground ${catppuccin.toHex colors.base}
      mark1_background ${catppuccin.toHex colors.lavender}
      mark2_foreground ${catppuccin.toHex colors.base}
      mark2_background ${catppuccin.toHex colors.mauve}
      mark3_foreground ${catppuccin.toHex colors.base}
      mark3_background ${catppuccin.toHex colors.sapphire}

      # The 16 terminal colors

      # black
      color0 ${catppuccin.toHex colors.surface1}
      color8 ${catppuccin.toHex colors.surface2}

      # red
      color1 ${catppuccin.toHex colors.red}
      color9 ${catppuccin.toHex colors.red}

      # green
      color2  ${catppuccin.toHex colors.green}
      color10 ${catppuccin.toHex colors.green}

      # yellow
      color3  ${catppuccin.toHex colors.yellow}
      color11 ${catppuccin.toHex colors.yellow}

      # blue
      color4  ${catppuccin.toHex colors.blue}
      color12 ${catppuccin.toHex colors.blue}

      # magenta
      color5  ${catppuccin.toHex colors.mauve}
      color13 ${catppuccin.toHex colors.mauve}

      # cyan
      color6  ${catppuccin.toHex colors.teal}
      color14 ${catppuccin.toHex colors.teal}

      # white
      color7  ${catppuccin.toHex colors.subtext1}
      color15 ${catppuccin.toHex colors.subtext0}
    '';
  };
}
