summary refs log tree commit diff
path: root/nixos/modules/programs
diff options
context:
space:
mode:
authorSpencer Whitt <me@swhitt.me>2015-11-24 18:04:17 -0500
committerSpencer Whitt <me@swhitt.me>2015-11-25 10:32:58 -0500
commitff58711bda11e4f79fed80e209fd91cff3ff62ef (patch)
tree9e4731d07cf13e65fbdbf9cbbeeabbe9dd5051e3 /nixos/modules/programs
parent0b0e51ce6f48662e75775a3ca52837c9a152d6b3 (diff)
downloadnixlib-ff58711bda11e4f79fed80e209fd91cff3ff62ef.tar
nixlib-ff58711bda11e4f79fed80e209fd91cff3ff62ef.tar.gz
nixlib-ff58711bda11e4f79fed80e209fd91cff3ff62ef.tar.bz2
nixlib-ff58711bda11e4f79fed80e209fd91cff3ff62ef.tar.lz
nixlib-ff58711bda11e4f79fed80e209fd91cff3ff62ef.tar.xz
nixlib-ff58711bda11e4f79fed80e209fd91cff3ff62ef.tar.zst
nixlib-ff58711bda11e4f79fed80e209fd91cff3ff62ef.zip
zsh module: add enableCompletion option
Diffstat (limited to 'nixos/modules/programs')
-rw-r--r--nixos/modules/programs/zsh/zsh.nix20
1 files changed, 18 insertions, 2 deletions
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";