aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2022-01-10 16:55:28 +0100
committerEelco Dolstra <edolstra@gmail.com>2022-01-10 16:55:28 +0100
commitf39d94a55be7db1759e3fcd8aea24bfb0da7b8c2 (patch)
treefd6380a2b51e35dda3d8f1a5f18537c3935aa127 /src/libexpr
parent19fd6e585d8f4cad3e358361b6f983b0d7d3b8a9 (diff)
parent120ca245d13708743a59e83da12ec90902636236 (diff)
Merge branch 'readfile' of https://github.com/abbradar/nix
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/primops.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index d7382af6b..1d2a7d5d2 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -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({