TLDR
-
WTF (exuse my frustration boiling over) is the difference between
buildInputs
andpackages
in the context ofmkShell
? -
Is there any truth to the fairy tale that Claude told me (see below)?
-
Where can I find the authoritative answer, and how could I have found it myself in a reasonable amount of time?
The gory details
The difference between buildInputs
and packages
has never been clear to me. It’s 2025, so I asked Claude sonnet 3.5. The fundamental part of its response was [WARNING: THE FOLLOWING WAS GENERATED BY AN AI, DON’T BELIEVE A WORD OF IT WITHOUT CHECKING AN AUTHORITATIVE SOURCE]
buildInputs packages are available during both build and runtime. They get added to $PATH but also have additional integration:
- Their binary directories are added to $PATH
- Their library directories are added to $LD_LIBRARY_PATH
- Their include directories are added to compiler include paths
- Their pkg-config files are made available
- Other standard Unix paths (man pages, etc.) are properly linked
packages are simpler - they just get added to $PATH during runtime. They don’t get the deeper system integration that buildInputs provides.
Which sounds clear, nice and authoritative, and gives me a feeling that I might, finally be able to understand the difference between the two. But how do I know any of this is true?
First, I try a little experiment and it suggests that Claude might be lying: I do not have lolcat
installed on my system. I activate a shell defined in a flake in which lolcat
is in packages
but not buildInputs
, so ‘man pages etc.’ is something that should be missing according to the above description, but the man pages work fine. But man pages are not really deep integration like library paths, pkg-config etc. Ok, but I really can’t be bothered to come up with more involved experiments … if all else fails, read the manual!
This is what the current version of the Nixpkgs Reference Manual has to say on packages
in mkShell
- packages (default: ). Add executable packages to the nix-shell environment.
Hmm, ok, that might agree with what Claude told me, but it might not.
This is what the same manual has to say about buildInputs
in mkShell
that is to say, absolutely nothing. Ok, ok, I’m being facetious, buildInputs
isn’t specific to mkShell
so I should look elsewhere for its documentation.
Now, with ‘most’ things, if I type something like “<technology name> <specific thing>” into any semi-decent search engine, I tend to get the manual entry for that thing somewhere in the first few hits. Sadly, this is rarely the case with Nix-related searches. After having CTRL-F/Gd through a bazillion irrelevant occurrences of buildInputs
in the aforementioned (almost infinitely long) single-page manual and other similar tiresome failures to find what I want, I give up.
And here I am, yet again: I was doing something, I had a doubt about some Nix details, searched for information, found some kind of dubious answer, looked for an authoritative answer, miserably failed to find it, and half an hour of my life has been wasted on this yet again, without making any progress whatsoever.