Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)

Merge pull request #67376 from oxij/nixos/zsh-doc

nixos: zsh: add more helpful documentation into generated files

authored by

Michael Raskin and committed by
GitHub
f320a023 6763bdd8

+53 -13
+53 -13
nixos/modules/programs/zsh/zsh.nix
··· 15 (filterAttrs (k: v: v != null) cfg.shellAliases) 16 ); 17 18 in 19 20 { ··· 69 70 promptInit = mkOption { 71 default = '' 72 autoload -U promptinit && promptinit && prompt walters && setopt prompt_sp 73 ''; 74 description = '' ··· 100 ]; 101 example = [ "EXTENDED_HISTORY" "RM_STAR_WAIT" ]; 102 description = '' 103 - Configure zsh options. 104 ''; 105 }; 106 ··· 147 . ${config.system.build.setEnvironment} 148 fi 149 150 ${cfge.shellInit} 151 152 ${cfg.shellInit} ··· 161 '' 162 # /etc/zprofile: DO NOT EDIT -- this file has been generated automatically. 163 # This file is read for login shells. 164 165 # Only execute this file once per shell. 166 if [ -n "$__ETC_ZPROFILE_SOURCED" ]; then return; fi 167 __ETC_ZPROFILE_SOURCED=1 168 169 ${cfge.loginShellInit} 170 171 ${cfg.loginShellInit} ··· 180 '' 181 # /etc/zshrc: DO NOT EDIT -- this file has been generated automatically. 182 # This file is read for interactive shells. 183 184 # Only execute this file once per shell. 185 if [ -n "$__ETC_ZSHRC_SOURCED" -o -n "$NOSYSZSHRC" ]; then return; fi 186 __ETC_ZSHRC_SOURCED=1 187 188 - . /etc/zinputrc 189 190 - # Don't export these, otherwise other shells (bash) will try to use same histfile 191 SAVEHIST=${toString cfg.histSize} 192 HISTSIZE=${toString cfg.histSize} 193 HISTFILE=${cfg.histFile} 194 195 - HELPDIR="${pkgs.zsh}/share/zsh/$ZSH_VERSION/help" 196 197 - # Tell zsh how to find installed completions 198 - for p in ''${(z)NIX_PROFILES}; do 199 - fpath+=($p/share/zsh/site-functions $p/share/zsh/$ZSH_VERSION/functions $p/share/zsh/vendor-completions) 200 - done 201 - 202 - ${optionalString cfg.enableGlobalCompInit "autoload -U compinit && compinit"} 203 204 ${cfge.interactiveShellInit} 205 206 ${cfg.interactiveShellInit} 207 208 - ${optionalString (cfg.setOptions != []) "setopt ${concatStringsSep " " cfg.setOptions}"} 209 - 210 ${zshAliases} 211 212 ${cfg.promptInit} 213 214 - # Need to disable features to support TRAMP 215 if [ "$TERM" = dumb ]; then 216 unsetopt zle prompt_cr prompt_subst 217 unset RPS1 RPROMPT
··· 15 (filterAttrs (k: v: v != null) cfg.shellAliases) 16 ); 17 18 + zshStartupNotes = '' 19 + # Note that generated /etc/zprofile and /etc/zshrc files do a lot of 20 + # non-standard setup to make zsh usable with no configuration by default. 21 + # 22 + # Which means that unless you explicitly meticulously override everything 23 + # generated, interactions between your ~/.zshrc and these files are likely 24 + # to be rather surprising. 25 + # 26 + # Note however, that you can disable loading of the generated /etc/zprofile 27 + # and /etc/zshrc (you can't disable loading of /etc/zshenv, but it is 28 + # designed to not set anything surprising) by setting `no_global_rcs` option 29 + # in ~/.zshenv: 30 + # 31 + # echo setopt no_global_rcs >> ~/.zshenv 32 + # 33 + # See "STARTUP/SHUTDOWN FILES" section of zsh(1) for more info. 34 + ''; 35 + 36 in 37 38 { ··· 87 88 promptInit = mkOption { 89 default = '' 90 + # Note that to manually override this in ~/.zshrc you should run `prompt off` 91 + # before setting your PS1 and etc. Otherwise this will likely to interact with 92 + # your ~/.zshrc configuration in unexpected ways as the default prompt sets 93 + # a lot of different prompt variables. 94 autoload -U promptinit && promptinit && prompt walters && setopt prompt_sp 95 ''; 96 description = '' ··· 122 ]; 123 example = [ "EXTENDED_HISTORY" "RM_STAR_WAIT" ]; 124 description = '' 125 + Configure zsh options. See 126 + <citerefentry><refentrytitle>zshoptions</refentrytitle><manvolnum>1</manvolnum></citerefentry>. 127 ''; 128 }; 129 ··· 170 . ${config.system.build.setEnvironment} 171 fi 172 173 + HELPDIR="${pkgs.zsh}/share/zsh/$ZSH_VERSION/help" 174 + 175 + # Tell zsh how to find installed completions. 176 + for p in ''${(z)NIX_PROFILES}; do 177 + fpath+=($p/share/zsh/site-functions $p/share/zsh/$ZSH_VERSION/functions $p/share/zsh/vendor-completions) 178 + done 179 + 180 + # Setup custom shell init stuff. 181 ${cfge.shellInit} 182 183 ${cfg.shellInit} ··· 192 '' 193 # /etc/zprofile: DO NOT EDIT -- this file has been generated automatically. 194 # This file is read for login shells. 195 + # 196 + ${zshStartupNotes} 197 198 # Only execute this file once per shell. 199 if [ -n "$__ETC_ZPROFILE_SOURCED" ]; then return; fi 200 __ETC_ZPROFILE_SOURCED=1 201 202 + # Setup custom login shell init stuff. 203 ${cfge.loginShellInit} 204 205 ${cfg.loginShellInit} ··· 214 '' 215 # /etc/zshrc: DO NOT EDIT -- this file has been generated automatically. 216 # This file is read for interactive shells. 217 + # 218 + ${zshStartupNotes} 219 220 # Only execute this file once per shell. 221 if [ -n "$__ETC_ZSHRC_SOURCED" -o -n "$NOSYSZSHRC" ]; then return; fi 222 __ETC_ZSHRC_SOURCED=1 223 224 + ${optionalString (cfg.setOptions != []) '' 225 + # Set zsh options. 226 + setopt ${concatStringsSep " " cfg.setOptions} 227 + ''} 228 229 + # Setup command line history. 230 + # Don't export these, otherwise other shells (bash) will try to use same HISTFILE. 231 SAVEHIST=${toString cfg.histSize} 232 HISTSIZE=${toString cfg.histSize} 233 HISTFILE=${cfg.histFile} 234 235 + # Configure sane keyboard defaults. 236 + . /etc/zinputrc 237 238 + ${optionalString cfg.enableGlobalCompInit '' 239 + # Enable autocompletion. 240 + autoload -U compinit && compinit 241 + ''} 242 243 + # Setup custom interactive shell init stuff. 244 ${cfge.interactiveShellInit} 245 246 ${cfg.interactiveShellInit} 247 248 + # Setup aliases. 249 ${zshAliases} 250 251 + # Setup prompt. 252 ${cfg.promptInit} 253 254 + # Disable some features to support TRAMP. 255 if [ "$TERM" = dumb ]; then 256 unsetopt zle prompt_cr prompt_subst 257 unset RPS1 RPROMPT