Nix has several search commands, it's just none of them do quite what people want (e.g. "nix search" with flakes and "nix-query" without flakes search by name and description, "nix-locate" can search by contents but the interface is a bit obtuse)
For those who want a local search for executables, and don't mind running nix-index:
#!/bin/sh
results="$(nix-locate -1 --regex --top-level "^/bin/${1}\$")"
for item in $results; do
nix search "nixpkgs#${item%.*}"
done
will search for a specific executable and give you (hopefully) reasonable output. If you don't have flakes enabled, you can just print the result of the command-substitution directly, but you won't get the short description.
For those who want a local search for executables, and don't mind running nix-index:
will search for a specific executable and give you (hopefully) reasonable output. If you don't have flakes enabled, you can just print the result of the command-substitution directly, but you won't get the short description.