fork/home-manager
git clone https://git.julia.blue/fork/home-manager
75790441
master
1{ config , pkgs , lib , ...} : 2 3with lib ; 4 5let 6 7cfg = config . programs . zsh . prezto ; 8 9relToDotDir = file : 10( optionalString ( config . programs . zsh . dotDir != null ) 11( config . programs . zsh . dotDir + "/" )) + file ; 12 13preztoModule = types . submodule { 14options = { 15enable = mkEnableOption "prezto" ; 16 17caseSensitive = mkOption { 18type = types . nullOr types . bool ; 19default = null ; 20example = true ; 21description = 22"Set case-sensitivity for completion, history lookup, etc." ; 23}; 24 25color = mkOption { 26type = types . nullOr types . bool ; 27default = true ; 28example = false ; 29description = '' 30Color output (automatically set to `false` on dumb terminals). 31'' ; 32}; 33 34pmoduleDirs = mkOption { 35type = types . listOf types . path ; 36default = [ ]; 37example = [ "$HOME/.zprezto-contrib" ]; 38description = "Add additional directories to load prezto modules from." ; 39}; 40 41extraConfig = mkOption { 42type = types . lines ; 43default = "" ; 44description = '' 45Additional configuration to add to {file}`.zpreztorc`. 46'' ; 47}; 48 49extraModules = mkOption { 50type = types . listOf types . str ; 51default = [ ]; 52example = [ "attr" "stat" ]; 53description = '' 54Set the Zsh modules to load ({manpage}`zshmodules(1)`). 55'' ; 56}; 57 58extraFunctions = mkOption { 59type = types . listOf types . str ; 60default = [ ]; 61example = [ "zargs" "zmv" ]; 62description = '' 63Set the Zsh functions to load ({manpage}`zshcontrib(1)`). 64'' ; 65}; 66 67pmodules = mkOption { 68type = types . listOf types . str ; 69default = [ 70"environment" 71"terminal" 72"editor" 73"history" 74"directory" 75"spectrum" 76"utility" 77"completion" 78"prompt" 79]; 80description = 81"Set the Prezto modules to load (browse modules). The order matters." ; 82}; 83 84autosuggestions . color = mkOption { 85type = types . nullOr types . str ; 86default = null ; 87example = "fg=blue" ; 88description = "Set the query found color." ; 89}; 90 91completions . ignoredHosts = mkOption { 92type = types . listOf types . str ; 93default = [ ]; 94example = [ "0.0.0.0" "127.0.0.1" ]; 95description = '' 96Set the entries to ignore in static {file}`/etc/hosts` for 97host completion. 98'' ; 99}; 100 101editor = { 102keymap = mkOption { 103type = types . nullOr ( types . enum [ "emacs" "vi" ]); 104default = "emacs" ; 105example = "vi" ; 106description = '' 107Set the key mapping style to `emacs` or `vi`. 108'' ; 109}; 110 111dotExpansion = mkOption { 112type = types . nullOr types . bool ; 113default = null ; 114example = true ; 115description = '' 116Automatically convert `....` to `../..` 117'' ; 118}; 119 120promptContext = mkOption { 121type = types . nullOr types . bool ; 122default = null ; 123example = true ; 124description = "Allow the Zsh prompt context to be shown." ; 125}; 126}; 127 128git . submoduleIgnore = mkOption { 129type = types . nullOr ( types . enum [ "dirty" "untracked" "all" "none" ]); 130default = null ; 131example = "all" ; 132description = '' 133Ignore submodules when they are `dirty`, `untracked`, `all`, 134or `none`. 135'' ; 136}; 137 138gnuUtility . prefix = mkOption { 139type = types . nullOr types . str ; 140default = null ; 141example = "g" ; 142description = "Set the command prefix on non-GNU systems." ; 143}; 144 145historySubstring = { 146foundColor = mkOption { 147type = types . nullOr types . str ; 148default = null ; 149example = "fg=blue" ; 150description = "Set the query found color." ; 151}; 152 153notFoundColor = mkOption { 154type = types . nullOr types . str ; 155default = null ; 156example = "fg=red" ; 157description = "Set the query not found color." ; 158}; 159 160globbingFlags = mkOption { 161type = types . nullOr types . str ; 162default = null ; 163description = "Set the search globbing flags." ; 164}; 165}; 166 167macOS . dashKeyword = mkOption { 168type = types . nullOr types . str ; 169default = null ; 170example = "manpages" ; 171description = '' 172Set the keyword used by {command}`mand` to open man pages 173in Dash.app. 174'' ; 175}; 176 177prompt = { 178theme = mkOption { 179type = types . nullOr types . str ; 180default = "sorin" ; 181example = "pure" ; 182description = '' 183Set the prompt theme to load. Setting it to `random` 184loads a random theme. Automatically set to `off` on dumb 185terminals. 186'' ; 187}; 188 189pwdLength = mkOption { 190type = types . nullOr ( types . enum [ "short" "long" "full" ]); 191default = null ; 192example = "short" ; 193description = '' 194Set the working directory prompt display length. By 195default, it is set to `short`. Set it to `long` (without `~` 196expansion) for longer or `full` (with `~` expansion) for 197even longer prompt display. 198'' ; 199}; 200 201showReturnVal = mkOption { 202type = types . nullOr types . bool ; 203default = null ; 204example = true ; 205description = '' 206Set the prompt to display the return code along with an 207indicator for non-zero return codes. This is not supported by all prompts. 208'' ; 209}; 210}; 211 212python = { 213virtualenvAutoSwitch = mkOption { 214type = types . nullOr types . bool ; 215default = null ; 216example = true ; 217description = "Auto switch to Python virtualenv on directory change." ; 218}; 219 220virtualenvInitialize = mkOption { 221type = types . nullOr types . bool ; 222default = null ; 223example = true ; 224description = 225"Automatically initialize virtualenvwrapper if pre-requisites are met." ; 226}; 227}; 228 229ruby . chrubyAutoSwitch = mkOption { 230type = types . nullOr types . bool ; 231default = null ; 232example = true ; 233description = "Auto switch the Ruby version on directory change." ; 234}; 235 236screen = { 237autoStartLocal = mkOption { 238type = types . nullOr types . bool ; 239default = null ; 240example = true ; 241description = 242"Auto start a session when Zsh is launched in a local terminal." ; 243}; 244 245autoStartRemote = mkOption { 246type = types . nullOr types . bool ; 247default = null ; 248example = true ; 249description = 250"Auto start a session when Zsh is launched in a SSH connection." ; 251}; 252}; 253 254ssh . identities = mkOption { 255type = types . listOf types . str ; 256default = [ ]; 257example = [ "id_rsa" "id_rsa2" "id_github" ]; 258description = "Set the SSH identities to load into the agent." ; 259}; 260 261syntaxHighlighting = { 262highlighters = mkOption { 263type = types . listOf types . str ; 264default = [ ]; 265example = [ "main" "brackets" "pattern" "line" "cursor" "root" ]; 266description = '' 267Set syntax highlighters. By default, only the main 268highlighter is enabled. 269'' ; 270}; 271 272styles = mkOption { 273type = types . attrsOf types . str ; 274default = { }; 275example = { 276builtin = "bg=blue" ; 277command = "bg=blue" ; 278function = "bg=blue" ; 279}; 280description = "Set syntax highlighting styles." ; 281}; 282 283pattern = mkOption { 284type = types . attrsOf types . str ; 285default = { }; 286example = { "rm*-rf*" = "fg=white,bold,bg=red" ; }; 287description = "Set syntax pattern styles." ; 288}; 289}; 290 291terminal = { 292autoTitle = mkOption { 293type = types . nullOr types . bool ; 294default = null ; 295example = true ; 296description = "Auto set the tab and window titles." ; 297}; 298 299windowTitleFormat = mkOption { 300type = types . nullOr types . str ; 301default = null ; 302example = "%n@%m: %s" ; 303description = "Set the window title format." ; 304}; 305 306tabTitleFormat = mkOption { 307type = types . nullOr types . str ; 308default = null ; 309example = "%m: %s" ; 310description = "Set the tab title format." ; 311}; 312 313multiplexerTitleFormat = mkOption { 314type = types . nullOr types . str ; 315default = null ; 316example = "%s" ; 317description = "Set the multiplexer title format." ; 318}; 319}; 320 321tmux = { 322autoStartLocal = mkOption { 323type = types . nullOr types . bool ; 324default = null ; 325example = true ; 326description = 327"Auto start a session when Zsh is launched in a local terminal." ; 328}; 329 330autoStartRemote = mkOption { 331type = types . nullOr types . bool ; 332default = null ; 333example = true ; 334description = 335"Auto start a session when Zsh is launched in a SSH connection." ; 336}; 337 338itermIntegration = mkOption { 339type = types . nullOr types . bool ; 340default = null ; 341example = true ; 342description = "Integrate with iTerm2." ; 343}; 344 345defaultSessionName = mkOption { 346type = types . nullOr types . str ; 347default = null ; 348example = "YOUR DEFAULT SESSION NAME" ; 349description = "Set the default session name." ; 350}; 351}; 352 353utility . safeOps = mkOption { 354type = types . nullOr types . bool ; 355default = null ; 356example = true ; 357description = '' 358Enabled safe options. This aliases {command}`cp`, 359{command}`ln`, {command}`mv` and {command}`rm` so that they 360prompt before deleting or overwriting files. Set to `no` to 361disable this safer behavior. 362'' ; 363}; 364}; 365}; 366 367in { 368meta . maintainers = [ maintainers . nickhu ]; 369options = { 370programs . zsh = { 371prezto = mkOption { 372type = preztoModule ; 373default = { }; 374description = "Options to configure prezto." ; 375}; 376}; 377}; 378config = mkIf cfg . enable ( mkMerge [{ 379home . file . " ${ relToDotDir ".zprofile" } " . text = 380builtins . readFile " ${ pkgs . zsh-prezto } /share/zsh-prezto/runcoms/zprofile" ; 381home . file . " ${ relToDotDir ".zlogin" } " . text = 382builtins . readFile " ${ pkgs . zsh-prezto } /share/zsh-prezto/runcoms/zlogin" ; 383home . file . " ${ relToDotDir ".zlogout" } " . text = 384builtins . readFile " ${ pkgs . zsh-prezto } /share/zsh-prezto/runcoms/zlogout" ; 385home . packages = with pkgs ; [ zsh-prezto ]; 386 387home . file . " ${ relToDotDir ".zshenv" } " . text = 388builtins . readFile " ${ pkgs . zsh-prezto } /share/zsh-prezto/runcoms/zshenv" ; 389home . file . " ${ relToDotDir ".zpreztorc" } " . text = '' 390# Generated by Nix 391${ optionalString ( cfg . caseSensitive != null ) '' 392zstyle ':prezto:*:*' case-sensitive ' ${ 393lib . hm . booleans . yesNo cfg . caseSensitive 394} ' 395'' } 396${ optionalString ( cfg . color != null ) '' 397zstyle ':prezto:*:*' color ' ${ lib . hm . booleans . yesNo cfg . color } ' 398'' } 399${ optionalString ( cfg . pmoduleDirs != [ ]) '' 400zstyle ':prezto:load' pmodule-dirs ${ 401builtins . concatStringsSep " " cfg . pmoduleDirs 402} 403'' } 404${ optionalString ( cfg . extraModules != [ ]) '' 405zstyle ':prezto:load' zmodule ${ 406strings . concatMapStringsSep " " strings . escapeShellArg 407cfg . extraModules 408} 409'' } 410${ optionalString ( cfg . extraFunctions != [ ]) '' 411zstyle ':prezto:load' zfunction ${ 412strings . concatMapStringsSep " " strings . escapeShellArg 413cfg . extraFunctions 414} 415'' } 416${ optionalString ( cfg . pmodules != [ ]) '' 417zstyle ':prezto:load' pmodule \ 418${ 419strings . concatMapStringsSep " \\\n " strings . escapeShellArg 420cfg . pmodules 421} 422'' } 423${ optionalString ( cfg . autosuggestions . color != null ) '' 424zstyle ':prezto:module:autosuggestions:color' found ' ${ cfg . autosuggestions . color } ' 425'' } 426${ optionalString ( cfg . completions . ignoredHosts != [ ]) '' 427zstyle ':prezto:module:completion:*:hosts' etc-host-ignores \ 428${ 429strings . concatMapStringsSep " " strings . escapeShellArg 430cfg . completions . ignoredHosts 431} 432'' } 433${ optionalString ( cfg . editor . keymap != null ) '' 434zstyle ':prezto:module:editor' key-bindings ' ${ cfg . editor . keymap } ' 435'' } 436${ optionalString ( cfg . editor . dotExpansion != null ) '' 437zstyle ':prezto:module:editor' dot-expansion ' ${ 438lib . hm . booleans . yesNo cfg . editor . dotExpansion 439} ' 440'' } 441${ optionalString ( cfg . editor . promptContext != null ) '' 442zstyle ':prezto:module:editor' ps-context ' ${ 443lib . hm . booleans . yesNo cfg . editor . promptContext 444} ' 445'' } 446${ optionalString ( cfg . git . submoduleIgnore != null ) '' 447zstyle ':prezto:module:git:status:ignore' submodules ' ${ cfg . git . submoduleIgnore } ' 448'' } 449${ optionalString ( cfg . gnuUtility . prefix != null ) '' 450zstyle ':prezto:module:gnu-utility' prefix ' ${ cfg . gnuUtility . prefix } ' 451'' } 452${ optionalString ( cfg . historySubstring . foundColor != null ) '' 453zstyle ':prezto:module:history-substring-search:color' found ' ${ cfg . historySubstring . foundColor } ' 454'' } 455${ optionalString ( cfg . historySubstring . notFoundColor != null ) '' 456zstyle ':prezto:module:history-substring-search:color' not-found ' ${ cfg . historySubstring . notFoundColor } ' 457'' } 458${ optionalString ( cfg . historySubstring . globbingFlags != null ) '' 459zstyle ':prezto:module:history-substring-search:color' globbing-flags ' ${ cfg . historySubstring . globbingFlags } ' 460'' } 461${ optionalString ( cfg . macOS . dashKeyword != null ) '' 462zstyle ':prezto:module:osx:man' dash-keyword ' ${ cfg . macOS . dashKeyword } ' 463'' } 464${ optionalString ( cfg . prompt . theme != null ) '' 465zstyle ':prezto:module:prompt' theme ' ${ cfg . prompt . theme } ' 466'' } 467${ optionalString ( cfg . prompt . pwdLength != null ) '' 468zstyle ':prezto:module:prompt' pwd-length ' ${ cfg . prompt . pwdLength } ' 469'' } 470${ optionalString ( cfg . prompt . showReturnVal != null ) '' 471zstyle ':prezto:module:prompt' show-return-val ' ${ 472lib . hm . booleans . yesNo cfg . prompt . showReturnVal 473} ' 474'' } 475${ optionalString ( cfg . python . virtualenvAutoSwitch != null ) '' 476zstyle ':prezto:module:python:virtualenv' auto-switch ' ${ 477lib . hm . booleans . yesNo cfg . python . virtualenvAutoSwitch 478} ' 479'' } 480${ optionalString ( cfg . python . virtualenvInitialize != null ) '' 481zstyle ':prezto:module:python:virtualenv' initialize ' ${ 482lib . hm . booleans . yesNo cfg . python . virtualenvInitialize 483} ' 484'' } 485${ optionalString ( cfg . ruby . chrubyAutoSwitch != null ) '' 486zstyle ':prezto:module:ruby:chruby' auto-switch ' ${ 487lib . hm . booleans . yesNo cfg . ruby . chrubyAutoSwitch 488} ' 489'' } 490${ optionalString ( cfg . screen . autoStartLocal != null ) '' 491zstyle ':prezto:module:screen:auto-start' local ' ${ 492lib . hm . booleans . yesNo cfg . screen . autoStartLocal 493} ' 494'' } 495${ optionalString ( cfg . screen . autoStartRemote != null ) '' 496zstyle ':prezto:module:screen:auto-start' remote ' ${ 497lib . hm . booleans . yesNo cfg . screen . autoStartRemote 498} ' 499'' } 500${ optionalString ( cfg . ssh . identities != [ ]) '' 501zstyle ':prezto:module:ssh:load' identities \ 502${ 503strings . concatMapStringsSep " " strings . escapeShellArg 504cfg . ssh . identities 505} 506'' } 507${ optionalString ( cfg . syntaxHighlighting . highlighters != [ ]) '' 508zstyle ':prezto:module:syntax-highlighting' highlighters \ 509${ 510strings . concatMapStringsSep " \\\n " strings . escapeShellArg 511cfg . syntaxHighlighting . highlighters 512} 513'' } 514${ optionalString ( cfg . syntaxHighlighting . styles != { }) '' 515zstyle ':prezto:module:syntax-highlighting' styles \ 516${ 517builtins . concatStringsSep " \\\n" ( attrsets . mapAttrsToList 518( k : v : strings . escapeShellArg k + " " + strings . escapeShellArg v ) 519cfg . syntaxHighlighting . styles ) 520} 521'' } 522${ optionalString ( cfg . syntaxHighlighting . pattern != { }) '' 523zstyle ':prezto:module:syntax-highlighting' pattern \ 524${ 525builtins . concatStringsSep " \\\n" ( attrsets . mapAttrsToList 526( k : v : strings . escapeShellArg k + " " + strings . escapeShellArg v ) 527cfg . syntaxHighlighting . pattern ) 528} 529'' } 530${ optionalString ( cfg . terminal . autoTitle != null ) '' 531zstyle ':prezto:module:terminal' auto-title ' ${ 532lib . hm . booleans . yesNo cfg . terminal . autoTitle 533} ' 534'' } 535${ optionalString ( cfg . terminal . windowTitleFormat != null ) '' 536zstyle ':prezto:module:terminal:window-title' format ' ${ cfg . terminal . windowTitleFormat } ' 537'' } 538${ optionalString ( cfg . terminal . tabTitleFormat != null ) '' 539zstyle ':prezto:module:terminal:tab-title' format ' ${ cfg . terminal . tabTitleFormat } ' 540'' } 541${ optionalString ( cfg . terminal . multiplexerTitleFormat != null ) '' 542zstyle ':prezto:module:terminal:multiplexer-title' format ' ${ cfg . terminal . multiplexerTitleFormat } ' 543'' } 544${ optionalString ( cfg . tmux . autoStartLocal != null ) '' 545zstyle ':prezto:module:tmux:auto-start' local ' ${ 546lib . hm . booleans . yesNo cfg . tmux . autoStartLocal 547} ' 548'' } 549${ optionalString ( cfg . tmux . autoStartRemote != null ) '' 550zstyle ':prezto:module:tmux:auto-start' remote ' ${ 551lib . hm . booleans . yesNo cfg . tmux . autoStartRemote 552} ' 553'' } 554${ optionalString ( cfg . tmux . itermIntegration != null ) '' 555zstyle ':prezto:module:tmux:iterm' integrate ' ${ 556lib . hm . booleans . yesNo cfg . tmux . itermIntegration 557} ' 558'' } 559${ optionalString ( cfg . tmux . defaultSessionName != null ) '' 560zstyle ':prezto:module:tmux:session' name ' ${ cfg . tmux . defaultSessionName } ' 561'' } 562${ optionalString ( cfg . utility . safeOps != null ) '' 563zstyle ':prezto:module:utility' safe-ops ' ${ 564lib . hm . booleans . yesNo cfg . utility . safeOps 565} ' 566'' } 567${ cfg . extraConfig } 568'' ; 569}]); 570}