summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authorSpencer Whitt <sw@swhitt.me>2015-01-12 03:45:48 -0500
committerSpencer Whitt <sw@swhitt.me>2015-01-12 03:45:48 -0500
commit6cba6dc61bb0530ad03419364c19b299c6c9c6d4 (patch)
treeab09c5758efe86c38d8f5bde0a9abc4435ea06f6 /nixos/modules
parent173f41cf0bc618f0b2c313b1915fee8d8a6d0ee2 (diff)
downloadnixlib-6cba6dc61bb0530ad03419364c19b299c6c9c6d4.tar
nixlib-6cba6dc61bb0530ad03419364c19b299c6c9c6d4.tar.gz
nixlib-6cba6dc61bb0530ad03419364c19b299c6c9c6d4.tar.bz2
nixlib-6cba6dc61bb0530ad03419364c19b299c6c9c6d4.tar.lz
nixlib-6cba6dc61bb0530ad03419364c19b299c6c9c6d4.tar.xz
nixlib-6cba6dc61bb0530ad03419364c19b299c6c9c6d4.tar.zst
nixlib-6cba6dc61bb0530ad03419364c19b299c6c9c6d4.zip
command-not-found: Add ZSH Support
Diffstat (limited to 'nixos/modules')
-rwxr-xr-xnixos/modules/module-list.nix2
-rw-r--r--nixos/modules/programs/command-not-found/command-not-found.nix (renamed from nixos/modules/programs/bash/command-not-found.nix)20
-rw-r--r--nixos/modules/programs/command-not-found/command-not-found.pl (renamed from nixos/modules/programs/bash/command-not-found.pl)0
3 files changed, 21 insertions, 1 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index 844fae536e95..c74ba7557e3d 100755
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -54,8 +54,8 @@
   ./misc/version.nix
   ./programs/atop.nix
   ./programs/bash/bash.nix
-  ./programs/bash/command-not-found.nix
   ./programs/blcr.nix
+  ./programs/command-not-found/command-not-found.nix
   ./programs/dconf.nix
   ./programs/environment.nix
   ./programs/info.nix
diff --git a/nixos/modules/programs/bash/command-not-found.nix b/nixos/modules/programs/command-not-found/command-not-found.nix
index 8c86d48b0808..bead2dcdcf90 100644
--- a/nixos/modules/programs/bash/command-not-found.nix
+++ b/nixos/modules/programs/command-not-found/command-not-found.nix
@@ -44,6 +44,26 @@ in
       }
     '';
 
+  programs.zsh.interactiveShellInit =
+    ''
+      # This function is called whenever a command is not found.
+      command_not_found_handler() {
+        local p=/run/current-system/sw/bin/command-not-found
+        if [ -x $p -a -f /nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite ]; then
+          # Run the helper program.
+          $p "$1"
+
+          # Retry the command if we just installed it.
+          if [ $? = 126 ]; then
+            "$@"
+          fi
+	else
+          # Indicate than there was an error so ZSH falls back to its default handler
+	  return 127
+        fi
+      }
+    '';
+
   environment.systemPackages = [ commandNotFound ];
 
   # TODO: tab completion for uninstalled commands! :-)
diff --git a/nixos/modules/programs/bash/command-not-found.pl b/nixos/modules/programs/command-not-found/command-not-found.pl
index 916649059d37..916649059d37 100644
--- a/nixos/modules/programs/bash/command-not-found.pl
+++ b/nixos/modules/programs/command-not-found/command-not-found.pl