aboutsummaryrefslogtreecommitdiff
path: root/src/libcmd
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2023-01-10 14:35:06 +0100
committerEelco Dolstra <edolstra@gmail.com>2023-01-10 14:35:06 +0100
commit8e923bf4c53233aba9e21c06b5da0d800da37e40 (patch)
treef8bea47a70b46982400e55255590d567bc334e36 /src/libcmd
parent5c97b5a3988c7dd28e617734c2eba669ee0c1288 (diff)
parent877e7a5ccf21279d9e027867e63181b2b9a6a15a (diff)
Merge remote-tracking branch 'origin/master' into fix-7417
Diffstat (limited to 'src/libcmd')
-rw-r--r--src/libcmd/installables.cc11
-rw-r--r--src/libcmd/repl.cc8
2 files changed, 8 insertions, 11 deletions
diff --git a/src/libcmd/installables.cc b/src/libcmd/installables.cc
index f4486bc2f..f5a436fbe 100644
--- a/src/libcmd/installables.cc
+++ b/src/libcmd/installables.cc
@@ -168,7 +168,7 @@ SourceExprCommand::SourceExprCommand(bool supportReadOnlyMode)
addFlag({
.longName = "derivation",
- .description = "Operate on the store derivation rather than its outputs.",
+ .description = "Operate on the [store derivation](../../glossary.md#gloss-store-derivation) rather than its outputs.",
.category = installablesCategory,
.handler = {&operateOn, OperateOn::Derivation},
});
@@ -563,7 +563,7 @@ ref<eval_cache::EvalCache> openEvalCache(
auto vFlake = state.allocValue();
flake::callFlake(state, *lockedFlake, *vFlake);
- state.forceAttrs(*vFlake, noPos);
+ state.forceAttrs(*vFlake, noPos, "while parsing cached flake data");
auto aOutputs = vFlake->attrs->get(state.symbols.create("outputs"));
assert(aOutputs);
@@ -627,7 +627,7 @@ DerivedPathsWithInfo InstallableFlake::toDerivedPaths()
else if (v.type() == nString) {
PathSet context;
- auto s = state->forceString(v, context);
+ auto s = state->forceString(v, context, noPos, fmt("while evaluating the flake output attribute '%s'", attrPath));
auto storePath = state->store->maybeParseStorePath(s);
if (storePath && context.count(std::string(s))) {
return {{
@@ -938,10 +938,7 @@ std::vector<std::pair<std::shared_ptr<Installable>, BuiltPathWithResult>> Instal
DrvOutput outputId { *outputHash, output };
auto realisation = store->queryRealisation(outputId);
if (!realisation)
- throw Error(
- "cannot operate on an output of the "
- "unbuilt derivation '%s'",
- outputId.to_string());
+ throw MissingRealisation(outputId);
outputs.insert_or_assign(output, realisation->outPath);
} else {
// If ca-derivations isn't enabled, assume that
diff --git a/src/libcmd/repl.cc b/src/libcmd/repl.cc
index 5400fcd69..71a7e079a 100644
--- a/src/libcmd/repl.cc
+++ b/src/libcmd/repl.cc
@@ -397,7 +397,7 @@ StringSet NixRepl::completePrefix(const std::string & prefix)
Expr * e = parseString(expr);
Value v;
e->eval(*state, *env, v);
- state->forceAttrs(v, noPos);
+ state->forceAttrs(v, noPos, "nevermind, it is ignored anyway");
for (auto & i : *v.attrs) {
std::string_view name = state->symbols[i.name];
@@ -590,7 +590,7 @@ bool NixRepl::processLine(std::string line)
const auto [path, line] = [&] () -> std::pair<Path, uint32_t> {
if (v.type() == nPath || v.type() == nString) {
PathSet context;
- auto path = state->coerceToPath(noPos, v, context);
+ auto path = state->coerceToPath(noPos, v, context, "while evaluating the filename to edit");
return {path, 0};
} else if (v.isLambda()) {
auto pos = state->positions[v.lambda.fun->pos];
@@ -834,7 +834,7 @@ void NixRepl::loadFiles()
void NixRepl::addAttrsToScope(Value & attrs)
{
- state->forceAttrs(attrs, [&]() { return attrs.determinePos(noPos); });
+ state->forceAttrs(attrs, [&]() { return attrs.determinePos(noPos); }, "while evaluating an attribute set to be merged in the global scope");
if (displ + attrs.attrs->size() >= envSize)
throw Error("environment full; cannot add more variables");
@@ -939,7 +939,7 @@ std::ostream & NixRepl::printValue(std::ostream & str, Value & v, unsigned int m
Bindings::iterator i = v.attrs->find(state->sDrvPath);
PathSet context;
if (i != v.attrs->end())
- str << state->store->printStorePath(state->coerceToStorePath(i->pos, *i->value, context));
+ str << state->store->printStorePath(state->coerceToStorePath(i->pos, *i->value, context, "while evaluating the drvPath of a derivation"));
else
str << "???";
str << "ยป";