{ 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-family = "JetBrainsMonoNerdFont"; font-family-bold = "JetBrainsMonoNerdFontBold"; font-family-italic = "JetBrainsMonoNerdFontItalic"; font-family-bold-italic = "JetBrainsMonoNerdFontBoldItalic"; font-size = 14; window-padding-x = 8; window-padding-y = 8; background-opacity = 0.85; gtk-single-instance = "true"; gtk-tabs-location = "bottom"; gtk-wide-tabs = false; window-padding-balance = true; window-decoration = "none"; theme = slug; resize-overlay-duration = "0s"; cursor-style-blink = "false"; confirm-close-surface = "false"; mouse-hide-while-typing = "true"; window-theme = "ghostty"; bold-is-bright = "true"; term = "xterm-256color"; app-notifications = "no-clipboard-copy"; shell-integration-features = "cursor,sudo,no-title"; # window-padding-y = 10; 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"; shell-integration = shell-integration; command = getExe package; }; settingsFile = pkgs.writeText "config" <| concatStringsSep "\n" <| mapAttrsToList (name: value: "${name} = ${toString value}") ghostty-settings; ghostty = pkgs.ghostty.overrideAttrs (_: { preBuild = '' shopt -s globstar sed -i 's/^const xev = @import("xev");$/const xev = @import("xev").Epoll;/' **/*.zig shopt -u globstar ''; }); ghostty-wrapped = pkgs.symlinkJoin { name = "ghostty-wrapped"; paths = [ghostty]; nativeBuildInputs = [pkgs.makeWrapper]; postBuild = '' wrapProgram $out/bin/ghostty --add-flags "--config-file=${settingsFile}" ''; }; in { environment.systemPackages = builtins.attrValues { inherit ghostty-wrapped; }; }