mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 05:56:15 +02:00
Use $<attr>Path instead of $<attr> for passAsFile
This commit is contained in:
parent
a70d275f3d
commit
bd91064150
3 changed files with 13 additions and 7 deletions
|
@ -254,11 +254,17 @@ big = "a very long string";
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
then when the builder runs, the environment variable
|
then when the builder runs, the environment variable
|
||||||
<envar>big</envar> will contain the absolute path to a temporary
|
<envar>bigPath</envar> will contain the absolute path to a
|
||||||
file containing <literal>a very long string</literal>. This is
|
temporary file containing <literal>a very long
|
||||||
useful when you need to pass large strings to a builder, since
|
string</literal>. That is, for any attribute
|
||||||
most operating systems impose a limit on the size of the
|
<replaceable>x</replaceable> listed in
|
||||||
environment (typically, a few hundred kilobyte).</para></listitem>
|
<varname>passAsFile</varname>, Nix will pass an environment
|
||||||
|
variable <envar><replaceable>x</replaceable>Path</envar> holding
|
||||||
|
the path of the file containing the value of attribute
|
||||||
|
<replaceable>x</replaceable>. This is useful when you need to pass
|
||||||
|
large strings to a builder, since most operating systems impose a
|
||||||
|
limit on the size of the environment (typically, a few hundred
|
||||||
|
kilobyte).</para></listitem>
|
||||||
|
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
|
|
@ -1662,7 +1662,7 @@ void DerivationGoal::startBuilder()
|
||||||
} else {
|
} else {
|
||||||
Path p = tmpDir + "/.attr-" + int2String(fileNr++);
|
Path p = tmpDir + "/.attr-" + int2String(fileNr++);
|
||||||
writeFile(p, i.second);
|
writeFile(p, i.second);
|
||||||
env[i.first] = p;
|
env[i.first + "Path"] = p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ mkDerivation {
|
||||||
passAsFile = [ \"foo\" ];
|
passAsFile = [ \"foo\" ];
|
||||||
foo = [ \"xyzzy\" ];
|
foo = [ \"xyzzy\" ];
|
||||||
builder = builtins.toFile \"builder.sh\" ''
|
builder = builtins.toFile \"builder.sh\" ''
|
||||||
[ \"\$(cat \$foo)\" = xyzzy ]
|
[ \"\$(cat \$fooPath)\" = xyzzy ]
|
||||||
touch \$out
|
touch \$out
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue