January 1, 0001 ~ 1 min read

buildInputs vs nativeBuildInputs


I always forget the different between the type of build inputs in a nix derivation.

Here is my explanation.

buildInputs: are for libraries loaded during execution.

nativeBuildInputs: are compilation libraries

Sometimes the libraries of nativeBuildInputs are not populated correctly by pkg-config. If I ever find a solution to this I will post it here. The only working solution I have is:

LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath nativeBuildInputs;

UPDATE: 2024-07-22

From https://nixos.org/manual/nixpkgs/unstable/#ssec-stdenv-dependencies-overview:

"Add dependencies to nativeBuildInputs if they are executed during the build:

Add dependencies to buildInputs if they will end up copied or linked into the final output or otherwise used at runtime:

Update: 2024-07-25

Another nice explanation


Sebastian BolaƱos

Hi, I'm Sebastian. I'm a software developer from Costa Rica. You can follow me on Twitter. I enjoy working on distributed systems.