{
  pkgs,
  lib,
  hostname,
  ...
}: let
  wrap_gl = program: let
    name = lib.strings.getName program.name;
  in
    pkgs.symlinkJoin {
      name = name;
      paths = [
        (pkgs.writeShellScriptBin name ''
          ${pkgs.nixgl.nixGLIntel}/bin/nixGLIntel ${program}/bin/${name} $@
        '')
        program
      ];
    };

  package =
    if hostname == "deck"
    then (wrap_gl pkgs.kitty)
    else pkgs.kitty;
in {
  home.file.".config/kitty/catppuccin.conf" = {
    source = ./catppuccin.conf;
  };

  home.shellAliases = {
    s = "kitty +kitten ssh";
  };

  programs.kitty = {
    enable = true;
    font = {
      name = "Iosevka Nerd Font";
    };
    package = package;
    keybindings = {
      # Windows/Panes
      "kitty_mod+enter" = "new_window_with_cwd";

      "kitty_mod+h" = "neighboring_window left";
      "kitty_mod+j" = "neighboring_window down";
      "kitty_mod+k" = "neighboring_window up";
      "kitty_mod+l" = "neighboring_window right";

      "kitty_mod+r" = "start_resizing_window";

      # Tabs
      "kitty_mod+t" = "new_tab";
      "kitty_mod+w" = "close_tab";
      "kitty_mod+f" = "toggle_layout stack";

      # Clipboard
      "ctrl+shift+c" = "copy_to_clipboard";
      "ctrl+shift+v" = "paste_from_clipboard";
    };
    settings = {
      "include" = "catppuccin.conf";
      "scrollback_lines" = 50000;

      "shell_integration" = "enabled no-cursor";

      "allow_remote_control" = "yes";

      "cursor_shape" = "underline";
      "cursor_blink_interval" = 0;

      "disable_ligatures" = "always";

      "enable_audio_bell" = "no";

      "tab_bar_margin_width" = "10";
      "tab_bar_margin_height" = "0 1";

      "tab_bar_edge" = "top";
      "tab_bar_style" = "powerline";
      "tab_powerline_style" = "slanted";

      "clear_all_shortcuts" = "yes";
    };
  };
}
