How to find the package name for executable

As a quick-and-dirty method, I will often just use readlink -e $(which $APP) to see what program I’m calling; the path in the Nix store will generally tell you the package name. For example, on my system:

$ readlink -e $(which free)
/nix/store/yrnnk11a7wafwhx2nzl4xa1l89av3h3d-procps-3.3.16/bin/free
$ 

And, indeed, free in this case is provided by pkgs.procps.

This method can get a little wonky for packages with different outputs (bin, lib, etc.), and occasionally the path doesn’t match the attribute name exactly (utillinux, I’m looking at you), but 95% of the time you can tell the package just from the Nix store path.