home, modules: add myFlake.home-manager.terminal

This commit is contained in:
Guanran Wang 2023-11-22 14:29:50 +08:00
parent 1cd12ecf97
commit 212fe0dab3
Signed by: nyancat
SSH key fingerprint: SHA256:8oWGKciPALWut/6WA27oFKofX+6Wtc0gQnsefXLQx/8
6 changed files with 97 additions and 73 deletions

View file

@ -0,0 +1,5 @@
{...}: {
imports = [
./terminal.nix
];
}

View file

@ -0,0 +1,84 @@
{
lib,
config,
pkgs,
...
}: let
cfg = config.myFlake.home-manager.terminal;
in {
# 3 terminals, one module.
# -- The Orange Box (wtf)
# FAQ (for future myself):
#
# - Q: font?
# A: use fontconfig.
#
# - Q: WezTerm?
# A: - I don't use it.
# - I don't know Lua.
# - extraConfig is probably not enough if you want customize it yourself.
#
# - Q: which terminal should I use?
# A: - Alacritty - rusty
# - Foot - fast
# - Kitty - feature rich
#
# - Q: why does kitty's font look bold
# A: I dont know, might be related to this: https://sw.kovidgoyal.net/kitty/conf/#opt-kitty.text_composition_strategy
options = {
myFlake.home-manager.terminal = {
cursorStyle = lib.mkOption {
type = lib.types.enum ["block" "beam" "underline"];
default = "beam";
example = "block";
description = "Select desired terminal cursor style.";
};
fontSize = lib.mkOption {
type = lib.types.int;
default = 12;
example = 8;
description = "Select desired terminal font size.";
};
padding = lib.mkOption {
type = lib.types.int;
default = 12;
example = 8;
description = "Select desired terminal padding size (in px).";
};
colorScheme = lib.mkOption {
type = lib.types.enum [null "tokyonight"];
default = "tokyonight";
description = "Select desired terminal color scheme.";
};
};
};
config.programs = lib.mkMerge [
{
alacritty.settings.cursor.style = cfg.cursorStyle;
kitty.settings.cursor_shape = cfg.cursorStyle;
foot.settings.cursor.style = cfg.cursorStyle;
alacritty.settings.font.size = cfg.fontSize;
kitty.settings.font_size = cfg.fontSize;
foot.settings.main.font = "monospace:size=${builtins.toString cfg.fontSize}";
alacritty.settings.window.padding.x = cfg.padding;
alacritty.settings.window.padding.y = cfg.padding;
kitty.settings.window_padding_width = builtins.toString (cfg.padding * (3.0 / 4.0)); # px -> pt
foot.settings.main.pad = "${builtins.toString cfg.padding}x${builtins.toString cfg.padding}";
}
# TODO: split this part to ./color-scheme.nix (???)
(lib.mkIf (cfg.colorScheme == "tokyonight") {
alacritty.settings.import = ["${pkgs.vimPlugins.tokyonight-nvim}/extras/alacritty/tokyonight_night.yml"];
kitty.settings.include = "${pkgs.vimPlugins.tokyonight-nvim}/extras/kitty/tokyonight_night.conf";
foot.settings.main.include = "${pkgs.vimPlugins.tokyonight-nvim}/extras/foot/tokyonight_night.ini";
})
];
}

View file

@ -23,4 +23,8 @@
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
imports = [
./actual-modules
];
}

View file

@ -1,40 +1,6 @@
{
lib,
pkgs,
...
}: {
{...}: {
programs.alacritty = {
enable = true;
settings = {
import = ["${pkgs.vimPlugins.tokyonight-nvim}/extras/alacritty/tokyonight_night.yml"];
cursor.style = "beam";
env.WINIT_X11_SCALE_FACTOR = "1";
window = {
#opacity = 0.9;
padding = {
x = 12;
y = 12;
};
};
font = {
size = 12;
normal = {
family = lib.mkDefault "monospace"; # macOS dont have fontconfig, so mkDefault is nessesary
style = "SemiBold";
};
bold = {
family = lib.mkDefault "monospace";
style = "Bold";
};
bold_italic = {
family = lib.mkDefault "monospace";
style = "Bold Itailc";
};
italic = {
family = lib.mkDefault "monospace";
style = "SemiBold Italic";
};
};
};
#settings.env.WINIT_X11_SCALE_FACTOR = "1"; # workaround for.. something?
};
}

View file

@ -1,34 +1,5 @@
{...}: {
programs.foot = {
enable = true;
settings = {
font = "monospace:size=12";
pad = "12x12 center";
colors = {
#"alpha" = 0.9;
# Tokyonight
"background" = "1a1b26";
"foreground" = "c0caf5";
"regular0" = "15161e"; # black
"regular1" = "f7768e"; # red
"regular2" = "9ece6a"; # green
"regular3" = "e0af68"; # yellow
"regular4" = "7aa2f7"; # blue
"regular5" = "bb9af7"; # magenta
"regular6" = "7dcfff"; # cyan
"regular7" = "a91bd6"; # white
"bright0" = "414868"; # bright black
"bright1" = "f7768e"; # bright red
"bright2" = "9ece6a"; # bright green
"bright3" = "e0af68"; # bright yellow
"bright4" = "7aa2f7"; # bright blue
"bright5" = "bb9af7"; # bright magenta
"bright6" = "7dcfff"; # bright cyan
"bright7" = "c0caf5"; # bright white
"16" = "ff9e64";
"17" = "db4b4b";
};
};
};
}

View file

@ -1,12 +1,6 @@
{pkgs, ...}: {
{...}: {
programs.kitty = {
enable = true;
settings = {
include = "${pkgs.vimPlugins.tokyonight-nvim}/extras/kitty/tokyonight_night.conf";
font_size = 12;
confirm_os_window_close = 0;
window_padding_width = 6;
adjust_line_height = 0;
};
settings.confirm_os_window_close = 0;
};
}