You can install the nix-index
package, build the index and then use nix-locate
command:
[nix-shell:~]$ nix-locate '/bin/grep'
perl532Packages.grepmail.out 75,569 x /nix/store/i4krsr02b3yymqhzz9kbz066rkjkn5zl-perl5.32.1-grepmail-5.3111/bin/grepmail
perl530Packages.grepmail.out 75,569 x /nix/store/vc2iv0zi7kb0fr04gahyx142i30xi0g6-perl5.30.3-grepmail-5.3111/bin/grepmail
patchutils_0_3_3.out 0 s /nix/store/yfl83agm8396xw9hir1rwvdanz13h9w5-patchutils-0.3.3/bin/grepdiff
patchutils.out 0 s /nix/store/wk1yk22f0f6ai478axaqr0yvwy6q7xl5-patchutils-0.3.4/bin/grepdiff
(patchutils.out) 248,584 x /nix/store/6jysbyhc43sjvfiyh1bpvi1n3zbz212r-bootstrap-tools/bin/grep
ipinfo.out 4,293,096 x /nix/store/7p4g03bi15705ipbkrc7vhb42cvgc54f-ipinfo-2.0.1/bin/grepip
grepm.out 1,540 x /nix/store/mfhzjhz2f3mwbg1pq1diblqfdcmcffhs-grepm-0.6/bin/grepm
grepcidr.out 19,576 x /nix/store/7x10lzg5389flnjhfwh4xycqi835knfy-grepcidr-2.0/bin/grepcidr
gnugrep.out 271,716 x /nix/store/ba3bf20z5rmd9vgyzsgamvwvb3i1idfn-gnugrep-3.6/bin/grep
(unixtools.col.out) 27,660 x /nix/store/0h4ih2jvl9gv3dnmld2vq5iyyv41cy7v-text_cmds-99/bin/grep
The Nix Cheatsheet provides a helpful list of corresponding commands in Nix and Ubuntu.
Indexing takes some time (depends on network speed and also the size). It can be reduced by using --filter-prefix '/bin/'
when you're looking for utilities (8:10 -> 2:50 minutes in my case). Also interaction can be reduced by indexing right after invoking the shell:
$ nix-shell -p nix-index --command 'nix-index --version; time nix-index --show-trace --filter-prefix '/bin/'; return'
Nixpkgs Files Indexer 0.1.3
+ querying available packages
+ generating index: 55661 paths found :: 23483 paths not in binary cache :: 08533 paths in queue
Error: fetching the file listing for store path '/nix/store/siv7varixjdfjs17i3qfrvyc072rx55j-ia-writer-duospace-20180721' failed
Caused by: response to GET 'http://cache.nixos.org/siv7varixjdfjs17i3qfrvyc072rx55j.ls' failed to parse (response saved to /run/user/1000/file_listing.json.2)
Caused by: expected value at line 1 column 1
+ generating index: 66306 paths found :: 23630 paths not in binary cache :: 00000 paths in queue
+ wrote index of 2,742,453 bytes
real 2m50,553s
user 2m39,151s
sys 0m26,571s
[nix-shell:~]$ nix-locate /bin/grep
...
(irccloud.out) 0 s /nix/store/dv7klxqz8pmyml05nrs5f5ddd3hb9nsw-irccloud-0.13.0-usr-target/bin/grep
fpc.out 732 r /nix/store/4p5nx2csq7xmag9cbkmg54qzj6kxr71j-fpc-3.2.0/bin/grep.tdf
gnugrep.out 257,000 x /nix/store/z3q9q9549ci7kbdgyq99r6crnvrky6v3-gnugrep-3.7/bin/grep
grepm.out 1,596 x /nix/store/746bg318dq0wm1z23lllbg74ymdyac3r-grepm-0.6/bin/grepm
grepcidr.out 22,088 x /nix/store/sja30zvm5nw7ic7gwddc3h89rdgiyza4-grepcidr-2.0/bin/grepcidr
...
rpm -q
are also programming -- except they aren't. There's a clear delineation -- as stackoverflow.com/help/on-topic puts it -- around questions that are "unique to software development".