Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
Ericson2314 authored Jan 27, 2023
1 parent eca5eac commit f57d7f4
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/libcmd/installables.cc
Original file line number Diff line number Diff line change
Expand Up @@ -621,23 +621,23 @@ DerivedPathsWithInfo InstallableFlake::toDerivedPaths()
std::string_view s = state->forceString(v, noPos, fmt("while evaluating the flake output attribute '%s'", attrPath));
if (context.size() != 1)
throw Error(
"flake output attribute '%s' evaluates to the string '%s' which does not denote exactly one store",
"flake output attribute '%s' evaluates a string '%s' which which has multiple entries in its context. It should only have one entry",
attrPath, s);
return {{
.path = std::visit(overloaded {
[&](NixStringContextElem::Opaque & o) -> DerivedPath {
auto sExpected = state->store->printStorePath(o.path);
if (s != sExpected)
throw Error(
"flake output attribute '%s' evaluates to the string '%s' which should be '%s' but is not",
"flake output attribute '%s' evaluates to the path string '%s', but its context has the different path '%s'",
attrPath, s, sExpected);
return DerivedPath::Opaque {
.path = std::move(o.path),
};
},
[&](NixStringContextElem::DrvDeep & o) -> DerivedPath {
throw Error(
"flake output attribute '%s' evaluates to the string '%s' which unsupported String Context",
"flake output attribute '%s' evaluates to the string '%s' whose context context refers to a complete source and binary closure. This is not supported at this time",
attrPath, s);
},
[&](NixStringContextElem::Built & o) -> DerivedPath {
Expand All @@ -646,13 +646,14 @@ DerivedPathsWithInfo InstallableFlake::toDerivedPaths()
if (i == drv.outputs.end())
throw Error("derivation '%s' does not have output '%s'", state->store->printStorePath(o.drvPath), o.output);
auto optOutputPath = i->second.path(*state->store, drv.name, o.output);
// This is testing for the case of CA derivations
auto sExpected = optOutputPath
? state->store->printStorePath(*optOutputPath)
: downstreamPlaceholder(*state->store, o.drvPath, o.output);
if (s != sExpected)
throw Error(
"flake output attribute '%s' evaluates to the string '%s' which should be '%s' but is not",
attrPath, s, sExpected);
"flake output attribute '%s' evaluates to a string '%s' whose context has '%s', but the string is not the right placeholder for this derivation output. It should be '%s'",
attrPath, s, o.to_string(*state.store), sExpected);
return DerivedPath::Built {
.drvPath = std::move(o.drvPath),
.outputs = OutputsSpec::Names { std::move(o.output) },
Expand Down

0 comments on commit f57d7f4

Please sign in to comment.