aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/primops.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2018-01-12 17:31:08 +0100
committerEelco Dolstra <edolstra@gmail.com>2018-01-12 17:31:08 +0100
commit74f75c855837bce7f48491e9ce8ac03794e5b40d (patch)
treeedf3ff8bfd9ebd4bf038a78dc7991ebe3f1b28e2 /src/libexpr/primops.cc
parent435ccc798077e6291fd34fd1720c6abcf3521557 (diff)
import, builtins.readFile: Handle diverted stores
Fixes #1791
Diffstat (limited to 'src/libexpr/primops.cc')
-rw-r--r--src/libexpr/primops.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index 602971427..98fe2199e 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -84,10 +84,10 @@ static void prim_scopedImport(EvalState & state, const Pos & pos, Value * * args
% path % e.path % pos);
}
- path = state.checkSourcePath(path);
+ Path realPath = state.checkSourcePath(state.toRealPath(path, context));
if (state.store->isStorePath(path) && state.store->isValidPath(path) && isDerivation(path)) {
- Derivation drv = readDerivation(path);
+ Derivation drv = readDerivation(realPath);
Value & w = *state.allocValue();
state.mkAttrs(w, 3 + drv.outputs.size());
Value * v2 = state.allocAttr(w, state.sDrvPath);
@@ -114,7 +114,7 @@ static void prim_scopedImport(EvalState & state, const Pos & pos, Value * * args
} else {
state.forceAttrs(*args[0]);
if (args[0]->attrs->empty())
- state.evalFile(path, v);
+ state.evalFile(realPath, v);
else {
Env * env = &state.allocEnv(args[0]->attrs->size());
env->up = &state.baseEnv;
@@ -127,8 +127,8 @@ static void prim_scopedImport(EvalState & state, const Pos & pos, Value * * args
env->values[displ++] = attr.value;
}
- printTalkative("evaluating file '%1%'", path);
- Expr * e = state.parseExprFromFile(resolveExprPath(path), staticEnv);
+ printTalkative("evaluating file '%1%'", realPath);
+ Expr * e = state.parseExprFromFile(resolveExprPath(realPath), staticEnv);
e->eval(state, *env, v);
}
@@ -863,7 +863,7 @@ static void prim_readFile(EvalState & state, const Pos & pos, Value * * args, Va
throw EvalError(format("cannot read '%1%', since path '%2%' is not valid, at %3%")
% path % e.path % pos);
}
- string s = readFile(state.checkSourcePath(path));
+ string s = readFile(state.checkSourcePath(state.toRealPath(path, context)));
if (s.find((char) 0) != string::npos)
throw Error(format("the contents of the file '%1%' cannot be represented as a Nix string") % path);
mkString(v, s.c_str());