[Nix-dev] Accessing files in derivations.

Layus layus.on at gmail.com
Tue Apr 19 22:53:13 CEST 2016


On 19/04/16 18:51, Vladimír Čunát wrote:
> On 04/19/2016 04:01 PM, Layus wrote:
>> That operator would ensure that the path exists in the derivation, but
>> also look up through the outputs to find one containing that file.
> Unfortunately, during evaluation you can't access the results of builds
> to check whether some path exists. (Well, technically you can, but we
> avoid it, as it has nasty consequences.)
>
> --Vladimir
But you could make it lazy enough to compute the actual path at build time.
Making it some kind of an implicit derivations maybe ?

foo = "${bar => /bin/test}"

would be a new value of the nix language, something like an anonymous 
derivation, or a lambda derivation.
This is a bit bold of course, because nix operators like string 
concatenation would need to be updated.

That being said, "${bar => /bin/test}" is mostly used in strings which 
are in turned into files, so only string concatenation needs to be handled.

The real issue with this scheme is that using package path interpolation 
in genericBuild phases leads to "meta" derivations.
That is, derivations describing an output path that is itself a derivation.
The first derivations inspects the ouptuts to find the paths, the second 
one actually builds the package.
Someone smells overengineering ? :-D

A simpler way to implement this is to add ${bar => /bin/test} as a valid 
operator within derivations, together with string concatenation.
This would be quite simple to do, but I fear some might not want to 
modify the derivation language, to the one and only nix standard.

Regards,
-- Layus.

PS: I cannot resist this hacked nix-pills snippet :

nix-repl> :l <nixpkgs>
nix-repl> d = derivation { name = "myname"; builder = "${coreutils => /bin/true} arg moreargs"; system = builtins.currentSystem; }
nix-repl> :b d

$ pp-aterm -i /nix/store/...-this-is-the-future.drv
Derive(
   [("out", "/nix/store/...-this-is-the-future", "", "")]
, []
, []
, "x86_64-linux"
, concat([lookup(["/nix/store/...-coreutils-8.21-dev", 
"/nix/store/...-coreutils-8.21", "/nix/store/...-coreutils-8.21-lib"]), 
"arg moreargs"])
, []
, ["... skipped ..."]
)




More information about the nix-dev mailing list