flocon/modules/programs/terminal/emulators/ghostty.nix

113 lines
3.2 KiB
Nix
Raw Normal View History

{
lib,
pkgs,
config,
...
}: let
inherit (lib) mapAttrs mkIf mkMerge optionalAttrs removePrefix;
inherit (config.local.systemVars) username;
styleCfg = config.local.style;
prefix = "ctrl+a";
mkGhosttyTheme = palette: let
colors = mapAttrs (_: value: removePrefix "#" value) palette;
2025-02-17 23:12:35 +01:00
in
with colors; {
base16 = {
palette = {
"0" = "#${base00}";
"1" = "#${base08}";
"2" = "#${base0B}";
"3" = "#${base0A}";
"4" = "#${base0D}";
"5" = "#${base0E}";
"6" = "#${base0C}";
"7" = "#${base05}";
"8" = "#${base02}";
"9" = "#${base08}";
"10" = "#${base0B}";
"11" = "#${base0A}";
"12" = "#${base0D}";
"13" = "#${base0E}";
"14" = "#${base0C}";
"15" = "#${base07}";
"16" = "#${base09}";
"17" = "#${base0F}";
"18" = "#${base01}";
"19" = "#${base02}";
"20" = "#${base04}";
"21" = "#${base06}";
};
2025-02-17 23:12:35 +01:00
background = base00;
foreground = base05;
cursor-color = base06;
selection-background = base02;
selection-foreground = base05;
};
};
in {
config = mkIf config.local.profiles.desktop.enable {
hjem.users.${username} = {
2025-02-17 23:12:35 +01:00
programs.ghostty = mkMerge [
{
2025-02-17 23:12:35 +01:00
enable = true;
settings = {
font-family = ["monospace" "Symbols Nerd Font"];
font-size = 14;
gtk-single-instance = true;
gtk-adwaita = false;
confirm-close-surface = false;
keybind = {
"${prefix}>c" = "new_tab";
"${prefix}>p" = "move_tab:-1";
"${prefix}>n" = "move_tab:1";
"${prefix}>\\" = "new_split:right";
"${prefix}>-" = "new_split:down";
"${prefix}>h" = "goto_split:left";
"${prefix}>j" = "goto_split:bottom";
"${prefix}>k" = "goto_split:top";
"${prefix}>l" = "goto_split:right";
"${prefix}>shift+h" = "resize_split:left,10";
"${prefix}>shift+j" = "resize_split:down,10";
"${prefix}>shift+k" = "resize_split:up,10";
"${prefix}>shift+l" = "resize_split:right,11";
"${prefix}>z" = "toggle_split_zoom";
};
2025-02-17 23:12:35 +01:00
adw-toolbar-style = "flat";
gtk-tabs-location = "bottom";
gtk-wide-tabs = false;
window-decoration = false;
2025-02-17 23:12:35 +01:00
linux-cgroup = "always";
};
}
(optionalAttrs styleCfg.enable
{
2025-02-17 23:12:35 +01:00
settings.theme = "base16";
themes.base16 = mkGhosttyTheme styleCfg.scheme.palette;
})
];
};
systemd.user.services.ghostty = {
name = "ghostty";
description = "ghosttyd";
partOf = ["graphical-session.target"];
after = ["graphical-session.target"];
wantedBy = ["graphical-session.target"];
path = lib.mkForce [];
serviceConfig = {
Type = "simple";
ExecStart = "${pkgs.ghostty}/bin/ghostty --initial-window=false --quit-after-last-window-closed=false";
Restart = "on-failure";
Slice = "background-graphical.slice";
};
};
};
}