programs and libraries used by the new derivation at run-time
whereas nativeBuildInputs contains
programs and libraries used at build-time that, if they are a compiler or similar tool, produce code to run at run-time—i.e. tools used to build the new derivation
So does it matter? Worked with Nix expressions using both, and never experienced any issues, but I’m wondering if there is a “right way” or if there’s a situation where one of them could backfire?
In general though, nativeBuildInputs is useful for cross-compilation as commands from those derivations will be available on the buildPlatform and execute at build time. Whereas buildInputs will likely be the architecture of the hostPlatform, so the derivation can link against those inputs (and be used at run-time).
There’s some cases like python where you may need to list them both as a nativeBuildInputs and as a buildInput, if the package needs to run python during build and will link against it.
Thanks, and there’s a lot to unpack. What follows are mostly just notes so that it will make sense to me later.
Looking at the source of mkShell that you linked, it will call mkDerivation in the end.
As you stated that nix-shell treats both buildInputs and nativeBuildInputs the same (does this apply to other *Inputs as well?), I went ahead and poked around in NixOS/nix to find the source of nix-shell. Am I on the right track looking at nix-build.cc? My C knowledge is next to nothing, but the line below tells me that I’m probably am.
// nix-build.cc, line 89
auto myName = runEnv ? "nix-shell" : "nix-build";
Couldn’t figure out yet how and where *Inputs end up though.