[Nix-dev] readFile applied to a path with a variable

Bryan Gardiner bog at khumba.net
Fri Oct 16 16:54:39 CEST 2015


Not on Nix right now but I believe this also works:

    readFile (./foo + name + /bar)

- Bryan

On Fri, 16 Oct 2015 11:36:22 +0100
Thomas Hunger <tehunger at gmail.com> wrote:

> Do you need toPath?
> 
> lib.readFile "./foo/${name}/bar"
> 
> seems to work for me.
> 
> On 16 October 2015 at 11:10, Bas van Dijk <v.dijk.bas at gmail.com> wrote:
> 
> > Hello,
> >
> > In a Nix expression I would like to read a file where the file path is
> > based on a variable. So I would like to do something like this:
> >
> >   with builtins;
> >   readFile (toPath ("./foo/" + name + "/bar"))
> >
> > Unfortunately this doesn't work since toPath expects a string which
> > represents an absolute path.
> >
> > Is there any other way to do this?
> >
> > Cheers,
> >
> > Bas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 801 bytes
Desc: OpenPGP digital signature
Url : http://lists.science.uu.nl/pipermail/nix-dev/attachments/20151016/3ef0910c/attachment-0001.bin 


More information about the nix-dev mailing list