fork/home-manager
git clone https://git.julia.blue/fork/home-manager
f58889c0
master
1{ config , lib , pkgs , ...} : 2 3with lib ; 4 5let 6 7cfg = config . programs . gnome-terminal ; 8 9eraseBinding = types . enum [ 10"auto" 11"ascii-backspace" 12"ascii-delete" 13"delete-sequence" 14"tty" 15]; 16 17backForeSubModule = types . submodule ({ ...} :{ 18options = { 19foreground = mkOption { 20type = types . str ; 21description = "The foreground color." ; 22}; 23 24background = mkOption { 25type = types . str ; 26description = "The background color." ; 27}; 28}; 29}); 30 31profileColorsSubModule = types . submodule ({ ...} :{ 32options = { 33foregroundColor = mkOption { 34type = types . str ; 35description = "The foreground color." ; 36}; 37 38backgroundColor = mkOption { 39type = types . str ; 40description = "The background color." ; 41}; 42 43boldColor = mkOption { 44default = null ; 45type = types . nullOr types . str ; 46description = "The bold color, null to use same as foreground." ; 47}; 48 49palette = mkOption { 50type = types . listOf types . str ; 51description = "The terminal palette." ; 52}; 53 54cursor = mkOption { 55default = null ; 56type = types . nullOr backForeSubModule ; 57description = "The color for the terminal cursor." ; 58}; 59 60highlight = mkOption { 61default = null ; 62type = types . nullOr backForeSubModule ; 63description = "The colors for the terminal’s highlighted area." ; 64}; 65}; 66}); 67 68profileSubModule = types . submodule ({ name , config , ...} :{ 69options = { 70default = mkOption { 71default = false ; 72type = types . bool ; 73description = "Whether this should be the default profile." ; 74}; 75 76visibleName = mkOption { 77type = types . str ; 78description = "The profile name." ; 79}; 80 81colors = mkOption { 82default = null ; 83type = types . nullOr profileColorsSubModule ; 84description = "The terminal colors, null to use system default." ; 85}; 86 87cursorBlinkMode = mkOption { 88default = "system" ; 89type = types . enum [ "system" "on" "off" ]; 90description = "The cursor blink mode." ; 91}; 92 93cursorShape = mkOption { 94default = "block" ; 95type = types . enum [ "block" "ibeam" "underline" ]; 96description = "The cursor shape." ; 97}; 98 99font = mkOption { 100default = null ; 101type = types . nullOr types . str ; 102description = "The font name, null to use system default." ; 103}; 104 105allowBold = mkOption { 106default = null ; 107type = types . nullOr types . bool ; 108description = '' 109If `true`, allow applications in the 110terminal to make text boldface. 111'' ; 112}; 113 114scrollOnOutput = mkOption { 115default = true ; 116type = types . bool ; 117description = "Whether to scroll when output is written." ; 118}; 119 120showScrollbar = mkOption { 121default = true ; 122type = types . bool ; 123description = "Whether the scroll bar should be visible." ; 124}; 125 126scrollbackLines = mkOption { 127default = 10000 ; 128type = types . nullOr types . int ; 129description = '' 130The number of scrollback lines to keep, null for infinite. 131'' ; 132}; 133 134customCommand = mkOption { 135default = null ; 136type = types . nullOr types . str ; 137description = '' 138The command to use to start the shell, or null for default shell. 139'' ; 140}; 141 142loginShell = mkOption { 143default = false ; 144type = types . bool ; 145description = "Run command as a login shell." ; 146}; 147 148backspaceBinding = mkOption { 149default = "ascii-delete" ; 150type = eraseBinding ; 151description = '' 152Which string the terminal should send to an application when the user 153presses the *Backspace* key. 154 155`auto` 156: Attempt to determine the right value from the terminal's IO settings. 157 158`ascii-backspace` 159: Send an ASCII backspace character (`0x08`). 160 161`ascii-delete` 162: Send an ASCII delete character (`0x7F`). 163 164`delete-sequence` 165: Send the `@7` control sequence. 166 167`tty` 168: Send terminal's "erase" setting. 169'' ; 170}; 171 172boldIsBright = mkOption { 173default = null ; 174type = types . nullOr types . bool ; 175description = "Whether bold text is shown in bright colors." ; 176}; 177 178deleteBinding = mkOption { 179default = "delete-sequence" ; 180type = eraseBinding ; 181description = '' 182Which string the terminal should send to an application when the user 183presses the *Delete* key. 184 185`auto` 186: Send the `@7` control sequence. 187 188`ascii-backspace` 189: Send an ASCII backspace character (`0x08`). 190 191`ascii-delete` 192: Send an ASCII delete character (`0x7F`). 193 194`delete-sequence` 195: Send the `@7` control sequence. 196 197`tty` 198: Send terminal's "erase" setting. 199'' ; 200}; 201 202audibleBell = mkOption { 203default = true ; 204type = types . bool ; 205description = "Turn on/off the terminal's bell." ; 206}; 207 208transparencyPercent = mkOption { 209default = null ; 210type = types . nullOr ( types . ints . between 0 100 ); 211description = "Background transparency in percent." ; 212}; 213}; 214}); 215 216buildProfileSet = pcfg : 217{ 218audible-bell = pcfg . audibleBell ; 219visible-name = pcfg . visibleName ; 220scroll-on-output = pcfg . scrollOnOutput ; 221scrollbar-policy = if pcfg . showScrollbar then "always" else "never" ; 222scrollback-lines = pcfg . scrollbackLines ; 223cursor-shape = pcfg . cursorShape ; 224cursor-blink-mode = pcfg . cursorBlinkMode ; 225login-shell = pcfg . loginShell ; 226backspace-binding = pcfg . backspaceBinding ; 227delete-binding = pcfg . deleteBinding ; 228} // ( if ( pcfg . customCommand != null ) then { 229use-custom-command = true ; 230custom-command = pcfg . customCommand ; 231} else { 232use-custom-command = false ; 233}) // ( if ( pcfg . font == null ) then { 234use-system-font = true ; 235} else { 236use-system-font = false ; 237font = pcfg . font ; 238}) // ( if ( pcfg . colors == null ) then { 239use-theme-colors = true ; 240} else 241({ 242use-theme-colors = false ; 243foreground-color = pcfg . colors . foregroundColor ; 244background-color = pcfg . colors . backgroundColor ; 245palette = pcfg . colors . palette ; 246} // optionalAttrs ( pcfg . allowBold != null ) { 247allow-bold = pcfg . allowBold ; 248} // ( if ( pcfg . colors . boldColor == null ) then { 249bold-color-same-as-fg = true ; 250} else { 251bold-color-same-as-fg = false ; 252bold-color = pcfg . colors . boldColor ; 253}) // optionalAttrs ( pcfg . boldIsBright != null ) { 254bold-is-bright = pcfg . boldIsBright ; 255} // ( if ( pcfg . colors . cursor != null ) then { 256cursor-colors-set = true ; 257cursor-foreground-color = pcfg . colors . cursor . foreground ; 258cursor-background-color = pcfg . colors . cursor . background ; 259} else { 260cursor-colors-set = false ; 261}) // ( if ( pcfg . colors . highlight != null ) then { 262highlight-colors-set = true ; 263highlight-foreground-color = pcfg . colors . highlight . foreground ; 264highlight-background-color = pcfg . colors . highlight . background ; 265} else { 266highlight-colors-set = false ; 267}) // optionalAttrs ( pcfg . transparencyPercent != null ) { 268background-transparency-percent = pcfg . transparencyPercent ; 269use-theme-transparency = false ; 270use-transparent-background = true ; 271})); 272 273in { 274meta . maintainers = with maintainers ; [ kamadorueda rycee ]; 275 276options = { 277programs . gnome-terminal = { 278enable = mkEnableOption "Gnome Terminal" ; 279 280showMenubar = mkOption { 281default = true ; 282type = types . bool ; 283description = "Whether to show the menubar by default" ; 284}; 285 286themeVariant = mkOption { 287default = "default" ; 288type = types . enum [ "default" "light" "dark" "system" ]; 289description = "The theme variation to request" ; 290}; 291 292profile = mkOption { 293default = { }; 294type = types . attrsOf profileSubModule ; 295description = '' 296A set of Gnome Terminal profiles. Note, the name of a profile must be 297a UUID. You can generate one, for example, using {command}`uuidgen` 298(from `util-linux`). 299'' ; 300}; 301}; 302}; 303 304config = mkIf cfg . enable { 305assertions = [ 306( let 307uuidre = 308"[[:xdigit:]]{8}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{12}" ; 309erroneous = 310filter ( n :builtins . match uuidre n == null ) ( attrNames cfg . profile ); 311in { 312assertion = erroneous == [ ]; 313message = '' 314The attribute name of a Gnome Terminal profile must be a UUID. 315Incorrect profile names: ${ concatStringsSep ", " erroneous } '' ; 316}) 317]; 318 319home . packages = [ pkgs . gnome . gnome-terminal ]; 320 321dconf . settings = let dconfPath = "org/gnome/terminal/legacy" ; 322in { 323" ${ dconfPath } " = { 324default-show-menubar = cfg . showMenubar ; 325theme-variant = cfg . themeVariant ; 326schema-version = 3 ; 327}; 328 329" ${ dconfPath } /profiles:" = { 330default = head ( attrNames ( filterAttrs ( n :v :v . default ) cfg . profile )); 331list = attrNames cfg . profile ; 332}; 333} // mapAttrs' 334( n :v :nameValuePair ( " ${ dconfPath } /profiles:/: ${ n } " ) ( buildProfileSet v )) 335cfg . profile ; 336 337programs . bash . enableVteIntegration = true ; 338programs . zsh . enableVteIntegration = true ; 339}; 340}