Vladimír Čunát <[email protected]> writes: > On 06/22/2014 02:55 PM, Florian Friesdorf wrote: >> Any thoughts? > > I *did* mean using the library function substituteAll. (It's not only a > bash function in stdenv's setup.) It uses practically the syntax you > propose. See qt4 for example.
qt4 uses pkgs.substituteAll to read a source file, perform substitution
on it and write a target file. It returns the path to the target file.
This works and I get a file with variables substituted, e.g.:
/nix/store/x32hziqm127agl1ipr6sfs7p9j8zdvpm-preamble.pl
Now I try to read this file:
testScriptPreamble = { debug, full, pythonstr }:
let debug_ = if debug then "true" else "";
full_ = if full then "true" else "";
in readFile (pkgs.substituteAll { src = ./python/preamble.pl;
inherit debug_ full_ pythonstr; });
and get:
% nix-build python.nix -A virtualenvPython27Full
error: string `/nix/store/x32hziqm127agl1ipr6sfs7p9j8zdvpm-preamble.pl' cannot
refer to other paths, at /home/cfl/dev/nixos/nixpkgs/nixos/tests/python.nix:26:8
Current full experiment:
https://github.com/chaoflow/nixpkgs/blob/5f2341e96cd48c6d75ca9abf7447cc4b04f04611/nixos/tests/python.nix#L26
Is there a way to get this work with pkgs.substituteAll?
I'm thinking of something like:
testScriptPreamble = { debug, full, pythonstr }:
let attrs = {
debug_ = if debug then "true" else "";
full_ = if full then "true" else "";
inherit pythonstr;
};
in pkgs.lib.substitute attrs (readFile ./python/preamble.pl);
--
Florian Friesdorf <[email protected]>
GPG FPR: 7A13 5EEE 1421 9FC2 108D BAAF 38F8 99A3 0C45 F083
Jabber/XMPP: [email protected]
IRC: chaoflow on freenode,ircnet,blafasel,OFTC
pgpaZWpxUqqtc.pgp
Description: PGP signature
_______________________________________________ nix-dev mailing list [email protected] http://lists.science.uu.nl/mailman/listinfo/nix-dev
