2025-06-12 20:09:05 +02:00
{
config ,
lib ,
pkgs ,
. . .
} : let
inherit ( lib . lists ) elem ;
inherit ( lib . meta ) getExe ;
2025-07-03 23:34:56 +02:00
inherit ( lib . attrsets ) mapAttrsToList ;
inherit ( lib . strings ) concatStringsSep ;
2025-06-12 20:09:05 +02:00
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 [ " b a s h " " f i s h " " z s h " ]
then name
else " n o n e " ;
2025-07-03 23:34:56 +02:00
ghostty-settings = {
font-family = " J e t B r a i n s M o n o N e r d F o n t " ;
font-family-bold = " J e t B r a i n s M o n o N e r d F o n t B o l d " ;
font-family-italic = " J e t B r a i n s M o n o N e r d F o n t I t a l i c " ;
font-family-bold-italic = " J e t B r a i n s M o n o N e r d F o n t B o l d I t a l i c " ;
font-size = 14 ;
2025-06-12 20:09:05 +02:00
2025-07-03 23:34:56 +02:00
window-padding-x = 8 ;
window-padding-y = 8 ;
background-opacity = 0 .85 ;
gtk-single-instance = " t r u e " ;
gtk-tabs-location = " b o t t o m " ;
gtk-wide-tabs = false ;
window-padding-balance = true ;
window-decoration = " n o n e " ;
theme = slug ;
resize-overlay-duration = " 0 s " ;
cursor-style-blink = " f a l s e " ;
confirm-close-surface = " f a l s e " ;
mouse-hide-while-typing = " t r u e " ;
window-theme = " g h o s t t y " ;
bold-is-bright = " t r u e " ;
term = " x t e r m - 2 5 6 c o l o r " ;
app-notifications = " n o - c l i p b o a r d - c o p y " ;
shell-integration-features = " c u r s o r , s u d o , n o - t i t l e " ;
# window-padding-y = 10;
cursor-style = " b l o c k " ;
# 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 = " c l i p b o a r d " ;
2025-07-08 13:57:04 +02:00
inherit shell-integration ;
2025-07-03 23:34:56 +02:00
command = getExe package ;
} ;
settingsFile = pkgs . writeText " c o n f i g " < | concatStringsSep " \n " < | mapAttrsToList ( name : value : " ${ name } = ${ toString value } " ) ghostty-settings ;
ghostty = pkgs . ghostty . overrideAttrs ( _ : {
preBuild = ''
shopt - s globstar
sed - i ' s / ^ const xev = @ import ( " x e v " ) ; $ /const xev = @ import ( " x e v " ) . Epoll ; / ' * * /* . z i g
shopt - u globstar
'' ;
} ) ;
2025-06-12 20:09:05 +02:00
ghostty-wrapped = pkgs . symlinkJoin {
name = " g h o s t t y - w r a p p e d " ;
2025-07-03 23:34:56 +02:00
paths = [ ghostty ] ;
2025-06-12 20:09:05 +02:00
nativeBuildInputs = [ pkgs . makeWrapper ] ;
postBuild = ''
2025-07-03 23:34:56 +02:00
wrapProgram $ out/bin/ghostty - - add-flags " - - c o n f i g - f i l e = ${ settingsFile } "
2025-06-12 20:09:05 +02:00
'' ;
} ;
in {
environment . systemPackages = builtins . attrValues {
inherit ghostty-wrapped ;
} ;
}