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?
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
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:
lib.getExe
and similar: nixpkgs/lib/meta.nix at 770e9947f466ce80c414702b0db27123dd985eb8 · NixOS/nixpkgs · GitHub
lib.getBin
and underlying stuff: nixpkgs/lib/attrsets.nix at 770e9947f466ce80c414702b0db27123dd985eb8 · NixOS/nixpkgs · GitHub
Thanks for the answers.