nixos-configuration/users/jalr/modules/alacritty.nix
2025-04-16 22:54:28 +02:00

158 lines
3.5 KiB
Nix

{ lib, pkgs, nixosConfig, ... }:
let
solarized = import ./solarized.nix;
tomlFormat = pkgs.formats.toml { };
colorschemes = {
# https://github.com/alacritty/alacritty/wiki/Color-schemes#solarized
solarized-dark = {
# Default colors
primary = {
background = solarized.base03.hex;
foreground = solarized.base0.hex;
};
# Cursor colors
cursor = {
text = solarized.base03.hex;
cursor = solarized.base0.hex;
};
# Normal colors
normal = {
black = solarized.base02.hex;
red = solarized.red.hex;
green = solarized.green.hex;
yellow = solarized.yellow.hex;
blue = solarized.blue.hex;
magenta = solarized.magenta.hex;
cyan = solarized.cyan.hex;
white = solarized.base2.hex;
};
# Bright colors
bright = {
black = solarized.base03.hex;
red = solarized.orange.hex;
green = solarized.base01.hex;
yellow = solarized.base00.hex;
blue = solarized.base0.hex;
magenta = solarized.violet.hex;
cyan = solarized.base1.hex;
white = solarized.base3.hex;
};
};
solarized-light = {
# Default colors
primary = {
background = solarized.base3.hex;
foreground = solarized.base00.hex;
};
# Cursor colors
cursor = {
text = solarized.base3.hex;
cursor = solarized.base00.hex;
};
# Normal colors
normal = {
black = solarized.base02.hex;
red = solarized.red.hex;
green = solarized.green.hex;
yellow = solarized.yellow.hex;
blue = solarized.blue.hex;
magenta = solarized.magenta.hex;
cyan = solarized.cyan.hex;
white = solarized.base2.hex;
};
# Bright colors
bright = {
black = solarized.base03.hex;
red = solarized.orange.hex;
green = solarized.base01.hex;
yellow = solarized.base00.hex;
blue = solarized.base0.hex;
magenta = solarized.violet.hex;
cyan = solarized.base1.hex;
white = solarized.base3.hex;
};
};
};
commonSettings = {
font = {
normal = {
family = "Inconsolata for Powerline";
style = "Regular";
};
size = 12;
};
mouse.hide_when_typing = true;
keyboard.bindings = [
{
key = "F1";
mods = "Control";
action = "DecreaseFontSize";
}
{
key = "F2";
mods = "Control";
action = "IncreaseFontSize";
}
];
bell = {
duration = 100;
color = "#000000";
};
window.dynamic_title = true;
scrolling.history = 100000;
window.opacity = 0.9;
};
settings = {
dark = commonSettings // {
colors = colorschemes.solarized-dark;
};
light = commonSettings // {
colors = colorschemes.solarized-light;
};
};
in
{
programs.alacritty = {
inherit (nixosConfig.jalr.gui) enable;
};
xdg.configFile = lib.attrsets.mapAttrs'
(colorScheme: cfg:
let name = "alacritty-${colorScheme}.toml";
in
lib.attrsets.nameValuePair "alacritty/${name}" {
source = tomlFormat.generate name cfg;
target = "alacritty/${name}";
}
)
settings;
programs.fish.functions = {
ssh = {
description = "ssh wrapper function";
wraps = "ssh";
body = ''
if [ "$TERM" = alacritty ]
TERM=xterm-256color command ssh $argv
else
command ssh $argv
end
'';
};
};
}