aboutsummaryrefslogtreecommitdiff
path: root/src/nix/repl.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/nix/repl.cc')
-rw-r--r--src/nix/repl.cc20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/nix/repl.cc b/src/nix/repl.cc
index 731337004..5c0d44c68 100644
--- a/src/nix/repl.cc
+++ b/src/nix/repl.cc
@@ -384,13 +384,12 @@ StorePath NixRepl::getDerivationPath(Value & v) {
auto drvInfo = getDerivation(*state, v, false);
if (!drvInfo)
throw Error("expression does not evaluate to a derivation, so I can't build it");
- Path drvPathRaw = drvInfo->queryDrvPath();
- if (drvPathRaw == "")
- throw Error("expression did not evaluate to a valid derivation (no drv path)");
- StorePath drvPath = state->store->parseStorePath(drvPathRaw);
- if (!state->store->isValidPath(drvPath))
- throw Error("expression did not evaluate to a valid derivation (invalid drv path)");
- return drvPath;
+ auto drvPath = drvInfo->queryDrvPath();
+ if (!drvPath)
+ throw Error("expression did not evaluate to a valid derivation (no 'drvPath' attribute)");
+ if (!state->store->isValidPath(*drvPath))
+ throw Error("expression evaluated to invalid derivation '%s'", state->store->printStorePath(*drvPath));
+ return *drvPath;
}
@@ -780,8 +779,11 @@ std::ostream & NixRepl::printValue(std::ostream & str, Value & v, unsigned int m
str << "«derivation ";
Bindings::iterator i = v.attrs->find(state->sDrvPath);
PathSet context;
- Path drvPath = i != v.attrs->end() ? state->coerceToPath(*i->pos, *i->value, context) : "???";
- str << drvPath << "»";
+ if (i != v.attrs->end())
+ str << state->store->printStorePath(state->coerceToStorePath(*i->pos, *i->value, context));
+ else
+ str << "???";
+ str << "»";
}
else if (maxDepth > 0) {