1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-28 05:21:16 +02:00
This commit is contained in:
Eelco Dolstra 2022-01-10 16:55:28 +01:00
commit f39d94a55b
5 changed files with 43 additions and 2 deletions

View file

@ -1470,7 +1470,11 @@ static void prim_readFile(EvalState & state, const Pos & pos, Value * * args, Va
string s = readFile(path);
if (s.find((char) 0) != string::npos)
throw Error("the contents of the file '%1%' cannot be represented as a Nix string", path);
v.mkString(s);
auto refs = state.store->isInStore(path) ?
state.store->queryPathInfo(state.store->toStorePath(path).first)->references :
StorePathSet{};
auto context = state.store->printStorePathSet(refs);
v.mkString(s, context);
}
static RegisterPrimOp primop_readFile({