Referring to another derivation

Is it possible to refer to the outPath of a dependency (a custom derivation), in another derivation?

Say, package foo depends on abc, and when being built, foo, refers to ABC_BIN_DIR which is normally under /usr/local/bin but now with nix it’s somewhere in the nix store, and therefore one would like to set the ABC_BIN_DIR env var accordingly, say with $abc.outPath in the buildPhase or before. Is this a common practice or is there a better way?

I’m not an expert yet in Nix, but looks fine to me. Actually, most of the tine just writing ${abc} should be enough, it’s only required to specify the output when you have several outputs and if you don’t want to use the default one which usually contains the binaries (glibc is the exception).
I guess it’s also common to use wrapProgram to easily change programs that don’t have such environment variable.

Thanks for the help! What is the exception you are referring to, with glibc?

You can read more in this paragraph.

Ah ok, thanks for the link!