From 5cbb618bb034ff24c85cdebd3860a50b366b1f11 Mon Sep 17 00:00:00 2001 From: Michael Bishop Date: Wed, 4 Mar 2020 22:22:20 -0400 Subject: [PATCH] log all ifd --- src/libexpr/eval.hh | 5 ++++- src/libexpr/primops.cc | 19 +++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh index e3eaed6d3be5..594ca455a271 100644 --- a/src/libexpr/eval.hh +++ b/src/libexpr/eval.hh @@ -308,7 +308,7 @@ public: /* Print statistics. */ void printStats(); - void realiseContext(const PathSet & context); + void realiseContext(const PathSet & context, const Pos &pos, const string & reason); private: @@ -428,6 +428,9 @@ struct EvalSettings : Config Setting useEvalCache{this, true, "eval-cache", "Whether to use the flake evaluation cache."}; + + Setting logAllIFD{this, false, "log-all-ifd", + "Emit log messages for all imports from derivation at the 'info' log level"}; }; extern EvalSettings evalSettings; diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index 647b66ef660c..7a27c2a79b6f 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -33,7 +33,7 @@ namespace nix { InvalidPathError::InvalidPathError(const Path & path) : EvalError("path '%s' is not valid", path), path(path) {} -void EvalState::realiseContext(const PathSet & context) +void EvalState::realiseContext(const PathSet & context, const Pos &pos, const string & reason) { std::vector drvs; @@ -44,6 +44,9 @@ void EvalState::realiseContext(const PathSet & context) throw InvalidPathError(store->printStorePath(ctx)); if (!outputName.empty() && ctx.isDerivation()) { drvs.push_back({ctx, {outputName}}); + if (evalSettings.logAllIFD) { + printInfo("%1% importing from derivation %2% via %3%", pos, decoded.first, reason); + } } } @@ -114,7 +117,7 @@ static void import(EvalState & state, const Pos & pos, Value & vPath, Value * vS Path path = state.coerceToPath(pos, vPath, context); try { - state.realiseContext(context); + state.realiseContext(context, pos, "scopedImport"); } catch (InvalidPathError & e) { throw EvalError({ .msg = hintfmt("cannot import '%1%', since path '%2%' is not valid", path, e.path), @@ -284,7 +287,7 @@ void prim_importNative(EvalState & state, const Pos & pos, Value * * args, Value Path path = state.coerceToPath(pos, *args[0], context); try { - state.realiseContext(context); + state.realiseContext(context, pos, "importNative"); } catch (InvalidPathError & e) { throw EvalError({ .msg = hintfmt( @@ -338,7 +341,7 @@ void prim_exec(EvalState & state, const Pos & pos, Value * * args, Value & v) commandArgs.emplace_back(state.coerceToString(pos, *elems[i], context, false, false)); } try { - state.realiseContext(context); + state.realiseContext(context, pos, "exec"); } catch (InvalidPathError & e) { throw EvalError({ .msg = hintfmt("cannot execute '%1%', since path '%2%' is not valid", @@ -1294,7 +1297,7 @@ static void prim_pathExists(EvalState & state, const Pos & pos, Value * * args, PathSet context; Path path = state.coerceToPath(pos, *args[0], context); try { - state.realiseContext(context); + state.realiseContext(context, pos, "pathExists"); } catch (InvalidPathError & e) { throw EvalError({ .msg = hintfmt( @@ -1371,7 +1374,7 @@ static void prim_readFile(EvalState & state, const Pos & pos, Value * * args, Va PathSet context; Path path = state.coerceToPath(pos, *args[0], context); try { - state.realiseContext(context); + state.realiseContext(context, pos, "readFile"); } catch (InvalidPathError & e) { throw EvalError({ .msg = hintfmt("cannot read '%1%', since path '%2%' is not valid", path, e.path), @@ -1422,7 +1425,7 @@ static void prim_findFile(EvalState & state, const Pos & pos, Value * * args, Va string path = state.coerceToString(pos, *i->value, context, false, false); try { - state.realiseContext(context); + state.realiseContext(context, pos, "findFile"); } catch (InvalidPathError & e) { throw EvalError({ .msg = hintfmt("cannot find '%1%', since path '%2%' is not valid", path, e.path), @@ -1478,7 +1481,7 @@ static void prim_readDir(EvalState & state, const Pos & pos, Value * * args, Val PathSet ctx; Path path = state.coerceToPath(pos, *args[0], ctx); try { - state.realiseContext(ctx); + state.realiseContext(ctx, pos, "readDir"); } catch (InvalidPathError & e) { throw EvalError({ .msg = hintfmt("cannot read '%1%', since path '%2%' is not valid", path, e.path),