2022-06-10 17:41:53 +00:00
|
|
|
{ pkgs, config, lib, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.nki.programs.kitty;
|
2024-10-09 09:47:29 +00:00
|
|
|
|
|
|
|
theme = { lib, options, config, ... }: {
|
|
|
|
programs.kitty = lib.mkIf config.nki.programs.kitty.enable (
|
|
|
|
if builtins.hasAttr "themeFile" options.programs.kitty then {
|
|
|
|
themeFile = "ayu_light";
|
|
|
|
} else {
|
|
|
|
theme = "Ayu Light";
|
|
|
|
}
|
|
|
|
);
|
|
|
|
};
|
2022-06-10 17:41:53 +00:00
|
|
|
in
|
|
|
|
with lib;
|
|
|
|
{
|
2024-10-09 09:47:29 +00:00
|
|
|
imports = [ theme ./darwin.nix ./linux.nix ./tabs.nix ];
|
2022-06-10 17:41:53 +00:00
|
|
|
|
|
|
|
options.nki.programs.kitty = {
|
|
|
|
enable = mkEnableOption "Enable kitty";
|
|
|
|
|
2022-07-06 19:56:28 +00:00
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.kitty;
|
|
|
|
};
|
|
|
|
|
2022-06-10 17:41:53 +00:00
|
|
|
# font
|
|
|
|
fontSize = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
description = "Font size";
|
|
|
|
default = 21;
|
|
|
|
};
|
|
|
|
|
2022-10-17 08:20:10 +00:00
|
|
|
background = mkOption {
|
|
|
|
type = types.nullOr types.path;
|
|
|
|
description = "Path to the background image. If not set, default to a 0.9 opacity";
|
|
|
|
default = null;
|
|
|
|
};
|
|
|
|
|
|
|
|
cmd = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = "The main control key";
|
|
|
|
default = if pkgs.stdenv.isDarwin then "cmd" else "ctrl";
|
|
|
|
};
|
|
|
|
|
|
|
|
enableTabs = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
description = "Enable tabs";
|
2022-10-21 11:17:07 +00:00
|
|
|
default = pkgs.stdenv.isDarwin;
|
2022-10-17 08:20:10 +00:00
|
|
|
};
|
2022-06-10 17:41:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
config.programs.kitty = mkIf cfg.enable {
|
|
|
|
enable = true;
|
|
|
|
|
2022-07-06 19:56:28 +00:00
|
|
|
package = cfg.package;
|
|
|
|
|
2022-06-10 17:41:53 +00:00
|
|
|
font.package = pkgs.fantasque-sans-mono;
|
|
|
|
font.name = "Fantasque Sans Mono";
|
|
|
|
font.size = cfg.fontSize;
|
|
|
|
|
2022-06-11 15:59:56 +00:00
|
|
|
settings =
|
2022-06-10 17:41:53 +00:00
|
|
|
let
|
2022-06-11 15:59:56 +00:00
|
|
|
# Background color and transparency
|
2022-06-10 17:41:53 +00:00
|
|
|
background =
|
2022-06-11 15:59:56 +00:00
|
|
|
if isNull cfg.background then {
|
2023-04-18 23:09:20 +00:00
|
|
|
background_opacity = "0.85";
|
2022-06-11 15:59:56 +00:00
|
|
|
dynamic_background_opacity = true;
|
|
|
|
} else {
|
2022-06-11 19:51:49 +00:00
|
|
|
background_image = "${cfg.background}";
|
2022-06-11 15:59:56 +00:00
|
|
|
background_image_layout = "scaled";
|
|
|
|
background_tint = "0.85";
|
|
|
|
};
|
2022-06-10 17:41:53 +00:00
|
|
|
in
|
2022-07-06 16:42:03 +00:00
|
|
|
mkMerge [
|
|
|
|
background
|
|
|
|
{
|
|
|
|
# Scrollback (128MBs)
|
|
|
|
scrollback_pager_history_size = 128;
|
2022-06-10 17:41:53 +00:00
|
|
|
|
2022-07-06 16:42:03 +00:00
|
|
|
# Disable Shell integration (leave it for Nix)
|
|
|
|
shell_integration = "no-rc";
|
|
|
|
|
|
|
|
# Allow remote control (for kakoune integration)
|
|
|
|
allow_remote_control = true;
|
2022-10-17 08:20:10 +00:00
|
|
|
|
|
|
|
# Mouse focus
|
|
|
|
focus_follows_mouse = true;
|
2022-07-06 16:42:03 +00:00
|
|
|
}
|
|
|
|
];
|
2022-06-10 17:41:53 +00:00
|
|
|
|
2022-10-12 16:07:09 +00:00
|
|
|
keybindings = {
|
2022-10-17 08:20:10 +00:00
|
|
|
"${cfg.cmd}+shift+equal" = "no_op"; # Not possible with a JIS keyboard
|
|
|
|
"${cfg.cmd}+shift+^" = "change_font_size all +2.0"; # ... so use ^ instead
|
|
|
|
|
|
|
|
## Clear screen
|
|
|
|
"${cfg.cmd}+backspace" = "clear_terminal to_cursor active";
|
|
|
|
"${cfg.cmd}+shift+backspace" = "clear_terminal reset active";
|
|
|
|
## Hints
|
|
|
|
"${cfg.cmd}+shift+p>n" = "kitten hints --type=linenum --linenum-action=tab kak {path} +{line}";
|
2022-10-12 16:07:09 +00:00
|
|
|
};
|
2024-06-19 17:24:57 +00:00
|
|
|
|
|
|
|
extraConfig =
|
|
|
|
let
|
|
|
|
# Nerd Fonts glyph map
|
|
|
|
glyphMap = pkgs.fetchurl {
|
|
|
|
url = "https://raw.githubusercontent.com/Sharparam/dotfiles/main/kitty/.config/kitty/font-nerd-symbols.conf";
|
|
|
|
hash = "sha256-1OaDWLC3y8ASD2ttRWWgPEpRnfKXu6H6vS3cFVpzT0o=";
|
|
|
|
};
|
|
|
|
in
|
|
|
|
''
|
|
|
|
include ${glyphMap}
|
|
|
|
'';
|
2022-06-10 17:41:53 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|