diff options
author | Yacine Hmito <yacine.hmito@gmail.com> | 2017-05-09 17:07:18 +0200 |
---|---|---|
committer | Yacine Hmito <yacine.hmito@gmail.com> | 2017-07-06 22:43:05 +0200 |
commit | 1f70f3801b7173ddb2890fbe39f57d6dae3e6611 (patch) | |
tree | 37f02a6342892b24f3e749404ef8748cb7ff36e6 /nixos/modules/programs/zsh/zsh.nix | |
parent | 05aa2a58db2de248cc2ef516b21fa319ca72613e (diff) | |
download | nixpkgs-1f70f3801b7173ddb2890fbe39f57d6dae3e6611.tar nixpkgs-1f70f3801b7173ddb2890fbe39f57d6dae3e6611.tar.gz nixpkgs-1f70f3801b7173ddb2890fbe39f57d6dae3e6611.tar.bz2 nixpkgs-1f70f3801b7173ddb2890fbe39f57d6dae3e6611.tar.lz nixpkgs-1f70f3801b7173ddb2890fbe39f57d6dae3e6611.tar.xz nixpkgs-1f70f3801b7173ddb2890fbe39f57d6dae3e6611.tar.zst nixpkgs-1f70f3801b7173ddb2890fbe39f57d6dae3e6611.zip |
Make zshrc more predictable
Originially, `programs.zsh` sets default values for some initialisation scripts. Nix resolves the case of multiple values by concatenating them all. It is however impossible to predict where the default script will be inserted; but we never want the default value to override the user-specified ones. Now, it doesn't set default values; almost everything is hardcoded at the begining of the file.
Diffstat (limited to 'nixos/modules/programs/zsh/zsh.nix')
-rw-r--r-- | nixos/modules/programs/zsh/zsh.nix | 71 |
1 files changed, 32 insertions, 39 deletions
diff --git a/nixos/modules/programs/zsh/zsh.nix b/nixos/modules/programs/zsh/zsh.nix index b276bf9bb73..a055291282c 100644 --- a/nixos/modules/programs/zsh/zsh.nix +++ b/nixos/modules/programs/zsh/zsh.nix @@ -97,45 +97,6 @@ in config = mkIf cfg.enable { - programs.zsh = { - - shellInit = '' - . ${config.system.build.setEnvironment} - - ${cfge.shellInit} - ''; - - loginShellInit = cfge.loginShellInit; - - interactiveShellInit = '' - # history defaults - SAVEHIST=2000 - HISTSIZE=2000 - HISTFILE=$HOME/.zsh_history - - setopt HIST_IGNORE_DUPS SHARE_HISTORY HIST_FCNTL_LOCK - - # Tell zsh how to find installed completions - for p in ''${(z)NIX_PROFILES}; do - fpath+=($p/share/zsh/site-functions $p/share/zsh/$ZSH_VERSION/functions $p/share/zsh/vendor-completions) - done - - ${if cfg.enableCompletion then "autoload -U compinit && compinit" else ""} - - ${optionalString (cfg.enableAutosuggestions) - "source ${pkgs.zsh-autosuggestions}/share/zsh-autosuggestions/zsh-autosuggestions.zsh" - } - - ${zshAliases} - ${cfg.promptInit} - - ${cfge.interactiveShellInit} - - HELPDIR="${pkgs.zsh}/share/zsh/$ZSH_VERSION/help" - ''; - - }; - environment.etc."zshenv".text = '' # /etc/zshenv: DO NOT EDIT -- this file has been generated automatically. @@ -146,6 +107,10 @@ in if [ -n "$__ETC_ZSHENV_SOURCED" ]; then return; fi export __ETC_ZSHENV_SOURCED=1 + . ${config.system.build.setEnvironment} + + ${cfge.shellInit} + ${cfg.shellInit} # Read system-wide modifications. @@ -163,6 +128,8 @@ in if [ -n "$__ETC_ZPROFILE_SOURCED" ]; then return; fi __ETC_ZPROFILE_SOURCED=1 + ${cfge.loginShellInit} + ${cfg.loginShellInit} # Read system-wide modifications. @@ -182,8 +149,34 @@ in . /etc/zinputrc + # history defaults + SAVEHIST=2000 + HISTSIZE=2000 + HISTFILE=$HOME/.zsh_history + + setopt HIST_IGNORE_DUPS SHARE_HISTORY HIST_FCNTL_LOCK + + HELPDIR="${pkgs.zsh}/share/zsh/$ZSH_VERSION/help" + + ${optionalString cfg.enableCompletion "autoload -U compinit && compinit"} + + ${optionalString (cfg.enableAutosuggestions) + "source ${pkgs.zsh-autosuggestions}/share/zsh-autosuggestions/zsh-autosuggestions.zsh" + } + + ${zshAliases} + + ${cfge.interactiveShellInit} + ${cfg.interactiveShellInit} + ${cfg.promptInit} + + # Tell zsh how to find installed completions + for p in ''${(z)NIX_PROFILES}; do + fpath+=($p/share/zsh/site-functions $p/share/zsh/$ZSH_VERSION/functions $p/share/zsh/vendor-completions) + done + # Read system-wide modifications. if test -f /etc/zshrc.local; then . /etc/zshrc.local |