[Nix-dev] Evaluation time vs build time

Linus Heckemann acc at sphalerite.org
Wed May 31 21:07:28 CEST 2017


On 31/05/17 18:01, Judson Lester wrote:
> All,
> 
> Please take this with a grain of salt. I'm trying to clarify my
> understanding of Nix, and I've started to develop a kind of precept that
> I don't know that I've seen documented anywhere. It may well be a
> sophomore misunderstanding, and if such I don't want it to be taken up
> as gospel. I think the most succinct way to put it would be:
> 
> nix expressions cannot 'makedepend'
> 
> In other words, values in a nix expression can't be computed from the
> sources used to build an application.
> 
> This is because (and here I'm sketchier) nix-build (upon which `nix-env
> --install` /et al/ are based) evaluates the expressions, and calls to
> 'derivation' that are executed, as a side effect, "queue up" builds.
> Once a derivation is actually produced (iow, when the evaluation
> completes), the queue of derivation builds are run. Since the
> expression's evaluation is complete before the derivation builds happen,
> the sources aren't available at evaluation time.
> 
> One of the consequences of this are the family of *2nix tools that
> exist: per-language library dependency manifests (like a Gemfile or
> package.json) wouldn't be available if the corresponding builder
> function just said "gitfetch this repo and build from it", so setting
> those packages up requires the extra step of getting the appropriate
> manifest files, running a simple tool on them, and pointing the
> expression to the tool's results.
> 
> Another, more profound consequence, is that the set of expressions is in
> some sense "complete" - they fully describe where to get and how to
> build packages, where a solution that admitted "makedepend" would blur
> that line and allow code to determine at packaging time what to include
> in the store.
> 
> My question is, basically, is that true? Do I understand this correctly?
> Even if I do, I'm sure there's details an nuances that could be expanded on.

As far as I understand it, it's mostly true — I believe it *is* actually
possible, just strongly discouraged and absolutely not accepted in
nixpkgs because (iiuc) of the mess of dependencies it can create.

However, I don't fully understand all the ins and outs of this and may
be wrong.



More information about the nix-dev mailing list