How to package shell plugins hermetically?

Currently, I am building derivations for some shell plugins that are not available in nixpkgs, e.g. goto. To isolate the result hermetically, I would like to either execute the script with a custom path that links the dependencies or to replace every program invocation by the absolute path to that program.

For standalone scripts, one could use wrapProgram. But since the plugin is not executed in a subshell but sourced instead, wrapProgram is not applicable in this case. Do you know any solutions to the ideas I mentioned above?

Looking at nixpkgs, e.g. the zsh-autosuggestions plugin, I found that some shell plugins are not isolated at all. Is this intended?