Rewrite builtin derivation environment

Also add a test.

Fixes #1803.
Closes #1805.
This commit is contained in:
Eelco Dolstra 2018-01-19 14:53:34 +01:00
parent 2896bb6826
commit 3c4c30eadd
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
3 changed files with 25 additions and 1 deletions

View file

@ -2933,8 +2933,13 @@ void DerivationGoal::runChild()
if (drv->isBuiltin()) { if (drv->isBuiltin()) {
try { try {
logger = makeJSONLogger(*logger); logger = makeJSONLogger(*logger);
BasicDerivation drv2(*drv);
for (auto & e : drv2.env)
e.second = rewriteStrings(e.second, inputRewrites);
if (drv->builder == "builtin:fetchurl") if (drv->builder == "builtin:fetchurl")
builtinFetchurl(*drv, netrcData); builtinFetchurl(drv2, netrcData);
else else
throw Error(format("unsupported builtin function '%1%'") % string(drv->builder, 8)); throw Error(format("unsupported builtin function '%1%'") % string(drv->builder, 8));
_exit(0); _exit(0);

View file

@ -9,4 +9,9 @@ with import ./config.nix;
date +%s.%N > $out/date date +%s.%N > $out/date
''; '';
}; };
fetchurl = import <nix/fetchurl.nix> {
url = "file://" + toString ./lang/eval-okay-xml.out;
sha256 = "426fefcd2430e986551db13fcc2b1e45eeec17e68ffeb6ff155be2f8aaf5407e";
};
} }

View file

@ -16,3 +16,17 @@ nix-build dependencies.nix --no-out-link --repeat 3
(! nix-build check.nix -A nondeterministic --no-out-link --repeat 1 2> $TEST_ROOT/log) (! nix-build check.nix -A nondeterministic --no-out-link --repeat 1 2> $TEST_ROOT/log)
grep 'differs from previous round' $TEST_ROOT/log grep 'differs from previous round' $TEST_ROOT/log
path=$(nix-build check.nix -A fetchurl --no-out-link)
chmod +w $path
echo foo > $path
chmod -w $path
nix-build check.nix -A fetchurl --no-out-link --check
# Note: "check" doesn't repair anything, it just compares to the hash stored in the database.
[[ $(cat $path) = foo ]]
nix-build check.nix -A fetchurl --no-out-link --repair
[[ $(cat $path) != foo ]]