Print derivation paths

Also be more consistent with quotes around attribute paths

(cherry picked from commit 9404ce36e4edd1df12892089bdab1ceb7d4d7a97)
Change-Id: Iaa80073b4a07a6ffef106a3c12ecd02b4f6f67aa
This commit is contained in:
eldritch horrors 2024-03-07 03:20:21 +01:00 committed by jade
parent 2020998cfd
commit f2c32738ad

View file

@ -359,8 +359,16 @@ struct CmdFlakeCheck : FlakeCommand
auto drvInfo = getDerivation(*state, v, false); auto drvInfo = getDerivation(*state, v, false);
if (!drvInfo) if (!drvInfo)
throw Error("flake attribute '%s' is not a derivation", attrPath); throw Error("flake attribute '%s' is not a derivation", attrPath);
// FIXME: check meta attributes else {
return drvInfo->queryDrvPath(); // FIXME: check meta attributes
auto storePath = drvInfo->queryDrvPath();
if (storePath) {
logger->log(lvlInfo,
fmt("derivation evaluated to %s",
store->printStorePath(storePath.value())));
}
return storePath;
}
} catch (Error & e) { } catch (Error & e) {
e.addTrace(resolve(pos), hintfmt("while checking the derivation '%s'", attrPath)); e.addTrace(resolve(pos), hintfmt("while checking the derivation '%s'", attrPath));
reportError(e); reportError(e);
@ -389,7 +397,7 @@ struct CmdFlakeCheck : FlakeCommand
auto checkOverlay = [&](const std::string & attrPath, Value & v, const PosIdx pos) { auto checkOverlay = [&](const std::string & attrPath, Value & v, const PosIdx pos) {
try { try {
Activity act(*logger, lvlInfo, actUnknown, Activity act(*logger, lvlInfo, actUnknown,
fmt("checking overlay %s", attrPath)); fmt("checking overlay '%s'", attrPath));
state->forceValue(v, pos); state->forceValue(v, pos);
if (!v.isLambda()) { if (!v.isLambda()) {
throw Error("overlay is not a function, but %s instead", showType(v)); throw Error("overlay is not a function, but %s instead", showType(v));
@ -413,7 +421,7 @@ struct CmdFlakeCheck : FlakeCommand
auto checkModule = [&](const std::string & attrPath, Value & v, const PosIdx pos) { auto checkModule = [&](const std::string & attrPath, Value & v, const PosIdx pos) {
try { try {
Activity act(*logger, lvlInfo, actUnknown, Activity act(*logger, lvlInfo, actUnknown,
fmt("checking NixOS module %s", attrPath)); fmt("checking NixOS module '%s'", attrPath));
state->forceValue(v, pos); state->forceValue(v, pos);
} catch (Error & e) { } catch (Error & e) {
e.addTrace(resolve(pos), hintfmt("while checking the NixOS module '%s'", attrPath)); e.addTrace(resolve(pos), hintfmt("while checking the NixOS module '%s'", attrPath));
@ -426,7 +434,7 @@ struct CmdFlakeCheck : FlakeCommand
checkHydraJobs = [&](const std::string & attrPath, Value & v, const PosIdx pos) { checkHydraJobs = [&](const std::string & attrPath, Value & v, const PosIdx pos) {
try { try {
Activity act(*logger, lvlInfo, actUnknown, Activity act(*logger, lvlInfo, actUnknown,
fmt("checking Hydra job %s", attrPath)); fmt("checking Hydra job '%s'", attrPath));
state->forceAttrs(v, pos, ""); state->forceAttrs(v, pos, "");
if (state->isDerivation(v)) if (state->isDerivation(v))
@ -501,7 +509,7 @@ struct CmdFlakeCheck : FlakeCommand
auto checkBundler = [&](const std::string & attrPath, Value & v, const PosIdx pos) { auto checkBundler = [&](const std::string & attrPath, Value & v, const PosIdx pos) {
try { try {
Activity act(*logger, lvlInfo, actUnknown, Activity act(*logger, lvlInfo, actUnknown,
fmt("checking bundler %s", attrPath)); fmt("checking bundler '%s'", attrPath));
state->forceValue(v, pos); state->forceValue(v, pos);
if (!v.isLambda()) if (!v.isLambda())
throw Error("bundler must be a function"); throw Error("bundler must be a function");