String interpolation x lib.{getExe,getExe'} for binary paths

Throughout nixpkgs, it may be found many instances of both "${<drv>}/bin/<bin-name>" and either lib.getExe <drv> or lib.getExe' <drv> "<bin-name>".

Are there any advantages or disadvantages of using one over the the other?

getExe/getExe' ensures the correct output is chosen, which you can see by checking its impl

2 Likes

i was wondering if anyone has done any profiling of lib.getExe used throughout nixpkgs and seen what sort of impact it has on evaluation time

The lib.getExe function classes are a small abstraction for doing roughly ${<drv>}/bin/<bin-name>. But it also handles cases where the binaries are filtered out into the bin derivation output, instead of out. It makes it so that the underlying package can split derivation outputs mostly as they see fit, without having to worry too much about implementation details in the nixos modules.

The implementation isn’t particularly interesting as it mostly consists of sanity checks and warnings, but here is a link if you’d like to have a look:

3 Likes

Thanks for the answers.