[Nix-dev] Re: Re: Re: ${out}

Yury G. Kudryashov urkud+nix at ya.ru
Sun Apr 11 20:20:38 CEST 2010


Jeff Johnson wrote:

> OK. Let me make sure I understand your solution by attempting
> to restate alternatively.
> 
> AFAICT, there are two evaluations of ${out} during nix-build,
> one in nix-instantiate, the other in nix-store.
Currently only nix-instantiate evaluates something. nix-store runs builder 
with environment settings read from .drv file.
> 
> By "escaping", you are (in my words) forcing a single lazy evealuation.
If you write "\${out}" it will result in '${out}' in the derivation file. My 
proposal was to let nix-store magically replace this ${out} with 
/nix/store/path while realising.

The problem (as was explained before) is that nix cannot evaluate ${out} 
during instantiation, because out depends on all attributes, and we'll have 
an infinite recursion. Currently we can use something like 
preConfigure="configureFlags=--with-libs=\${out}/lib". This will result in 
preConfigure="configureFlags=--with-libs=${out}/lib" in the .drv file, and 
will assign "--with-libs=/nix/store/path/lib" to configureFlags in 
preConfigure phase. I thought how to make it possible to use just 
configureFlags="\${out}/lib".

> A single (rather than two) evaluations of ${out} seems reasonable. Whether
> this is done through escaping or some other means is perhaps more syntax
> and aesthetics ...
${out} is evaluated once.
> 
> But from what little I know of how Nix "works", there's likely a whole
> class of path issues like this, not just ${out} <-> /nix/store/path/...
> evaluations.
> 
> E.g. let's assume that there's _BOTH_ /nix/store and /xiu/store that exist
> as path prefixes, and one wants nix instances to be able to be moved
> between /nix/store <-> /xiu/store with the same nix-hash value attached.
It is impossible. Packages in /nix/store have many /nix/store/* paths 
hardcoded. Probably, it is possible to make .drv files portable, but the 
transformation from .nix to .drv is cheap.

> From what little I know of how nix-hash without --flat "works", there
> would seem to be many issues with replacing a leading "/nix/store/path/"
> prefix with a variable like "\${out}" by delaying/escaping/postponing
> the evaluation (no matter how that is accomplished, \${out} is just one
> way).
I do not propose to replace /nix/store/path with \${out}.
> Is that the type of solution you are proposing using "\${out}" in
> nix-instantiate?
> 
> If yes, will the escaping generalize to the class of "/nix/store" <->
> "/xiu/store" prefixes with the freedom to move nix-hash instances between
> both prefixes?
> 
> And I apologize if I've totally misunderstood the \${out} issue. I'm
> pretty new to Nix, still trying to get my head around functional
> programming.
> 
> 73 de Jeff





More information about the nix-dev mailing list