nichts/modules/programs/gui/ghostty.mod.nix
2025-07-16 22:15:41 +02:00

70 lines
2.1 KiB
Nix

{
config,
lib,
pkgs,
...
}: let
inherit (lib.lists) elem;
inherit (lib.meta) getExe;
inherit (lib.attrsets) mapAttrsToList;
inherit (lib.strings) concatStringsSep;
inherit (config.meta.mainUser.defaultShell) name package;
inherit (config.modules.style.colorScheme) slug;
# Shell integration for ghostty only supports
# bash, fish and zsh for now.
shell-integration =
if elem name ["bash" "fish" "zsh"]
then name
else "none";
ghostty-settings = {
font-size = 14;
font-family = "JetBrainsMonoNerdFont";
# font-style-bold = JetBrainsMono NF Regular;
# font-style-bold-italic = JetBrainsMono NF Italic;
app-notifications = "no-clipboard-copy";
background-opacity = 0.75;
bold-is-bright = "true";
confirm-close-surface = "false";
cursor-style-blink = "false";
gtk-single-instance = "true";
gtk-tabs-location = "bottom";
gtk-wide-tabs = false;
mouse-hide-while-typing = "true";
resize-overlay-duration = "0s";
shell-integration-features = "cursor,sudo,no-title";
term = "xterm-256color";
theme = slug;
window-decoration = "none";
window-padding-balance = true;
window-padding-x = 8;
window-padding-y = 8;
window-theme = "ghostty";
cursor-style = "block";
# Whether to automatically copy selected text to the clipboard. true will prefer to copy to the selection clipboard, otherwise it will copy to the system clipboard.
# The value clipboard will always copy text to the selection clipboard as well as the system clipboard.
copy-on-select = "clipboard";
inherit shell-integration;
command = getExe package;
};
settingsFile = pkgs.writeText "config" <| concatStringsSep "\n" <| mapAttrsToList (name: value: "${name} = ${toString value}") ghostty-settings;
ghostty-wrapped = pkgs.symlinkJoin {
name = "ghostty-wrapped";
paths = [pkgs.ghostty];
nativeBuildInputs = [pkgs.makeWrapper];
postBuild = ''
wrapProgram $out/bin/ghostty --add-flags "--config-file=${settingsFile}"
'';
};
in {
environment.systemPackages = builtins.attrValues {
inherit ghostty-wrapped;
};
}