d79415b17d1c730b87bcbf76e691e344c9cb4694

Author
SomeDer <48731521+SomeDer@users.noreply.github.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

command-not-found: add support for NixOS (#7701)

Diff

 1diff --git a/plugins/command-not-found/README.md b/plugins/command-not-found/README.md
 2index df62d1f075f35c97105990bba0e7c5627199d8c0..1cf4ba66e10b7fcc6a0da7331c9551f4dcd3f865 100644
 3--- a/plugins/command-not-found/README.md
 4+++ b/plugins/command-not-found/README.md
 5@@ -27,5 +27,6 @@ It works out of the box with the command-not-found packages for:
 6 - [Arch Linux](https://wiki.archlinux.org/index.php/Pkgfile#Command_not_found)
 7 - [macOS (Homebrew)](https://github.com/Homebrew/homebrew-command-not-found)
 8 - [Fedora](https://fedoraproject.org/wiki/Features/PackageKitCommandNotFound)
 9+- [NixOS](https://github.com/NixOS/nixpkgs/tree/master/nixos/modules/programs/command-not-found)
10 
11 You can add support for other platforms by submitting a Pull Request.
12diff --git a/plugins/command-not-found/command-not-found.plugin.zsh b/plugins/command-not-found/command-not-found.plugin.zsh
13index ba1262de62868e8ffce7c00741f6c97bf4a8a226..dd1186e443c25fb9ddedba292180dfa80d666421 100644
14--- a/plugins/command-not-found/command-not-found.plugin.zsh
15+++ b/plugins/command-not-found/command-not-found.plugin.zsh
16@@ -31,3 +31,10 @@ if type brew &> /dev/null; then
17     eval "$(brew command-not-found-init)";
18   fi
19 fi
20+
21+# NixOS command-not-found support
22+if [ -x /run/current-system/sw/bin/command-not-found ]; then
23+    command_not_found_handler () {
24+        /run/current-system/sw/bin/command-not-found $@
25+    }
26+fi