What is the point of using `nix-shell` with a function?

Now that you mention nix-build, would you share where nix-build and nix-shell is implemented in hnix? I think I found their source in NixOS/nix repo in nix-build.cc (see thread) but it eluded me there.