From c66865dff1747ecd55915ef8c549dc1a088ff168 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Fri, 4 Mar 2016 13:47:19 +0300 Subject: [PATCH] builtins.readFile: Propagate path context Co-authored-by: Shea Levy --- src/libexpr/primops.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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({