From ff58711bda11e4f79fed80e209fd91cff3ff62ef Mon Sep 17 00:00:00 2001 From: Spencer Whitt Date: Tue, 24 Nov 2015 18:04:17 -0500 Subject: zsh module: add enableCompletion option --- nixos/modules/programs/zsh/zsh.nix | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'nixos/modules/programs/zsh/zsh.nix') diff --git a/nixos/modules/programs/zsh/zsh.nix b/nixos/modules/programs/zsh/zsh.nix index 74dd6af0bdde..9f7596a21e72 100644 --- a/nixos/modules/programs/zsh/zsh.nix +++ b/nixos/modules/programs/zsh/zsh.nix @@ -25,7 +25,7 @@ in enable = mkOption { default = false; description = '' - Whenever to configure Zsh as an interactive shell. + Whether to configure zsh as an interactive shell. ''; type = types.bool; }; @@ -73,6 +73,14 @@ in type = types.lines; }; + enableCompletion = mkOption { + default = true; + description = '' + Enable zsh completion for all interactive zsh shells. + ''; + type = types.bool; + }; + }; }; @@ -101,6 +109,13 @@ in export 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) + done + + ${if cfg.enableCompletion then "autoload -U compinit && compinit" else ""} ''; }; @@ -161,7 +176,8 @@ in environment.etc."zinputrc".source = ./zinputrc; - environment.systemPackages = [ pkgs.zsh ]; + environment.systemPackages = [ pkgs.zsh ] + ++ optional cfg.enableCompletion pkgs.nix-zsh-completions; #users.defaultUserShell = mkDefault "/run/current-system/sw/bin/zsh"; -- cgit 1.4.1