[Nix-dev] Evaluation time vs build time

Judson Lester nyarly at gmail.com
Wed May 31 19:01:12 CEST 2017


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.

Judson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.science.uu.nl/pipermail/nix-dev/attachments/20170531/3db1f981/attachment.html>


More information about the nix-dev mailing list