diff --git a/home/config/nil/home.nix b/home/config/nil/home.nix index 84d5ae9..6cc1c2c 100644 --- a/home/config/nil/home.nix +++ b/home/config/nil/home.nix @@ -299,6 +299,29 @@ in { } } ] + + hooks: { + command_not_found: { + |cmd_name| ( + try { + let pkgs = ( + `${config.programs.nix-index.package}/bin/nix-locate` + --top-level --type x --type s --no-group --whole-name --at-root --minimal + $"/bin/($cmd_name)" + ) + + if ($pkgs | is-empty) { + null + } else { + $pkgs | split row "\n" + | each {|pkg| $" nixpkgs#($pkg)\n"} + | prepend $"($cmd_name) is provided by:\n" + | append "\n" | str join + } + } + ) + } + } }; ''; };