Print derivation paths

Also be more consistent with quotes around attribute paths
This commit is contained in:
Rebecca Turner 2023-09-01 13:09:01 -07:00
parent 49221493e2
commit 9404ce36e4
Signed by: rbt
SSH key fingerprint: SHA256:HU9KTlGeHEBIp12MT4UHG0uc//NRNoJMWfzVGX3igu4

View file

@ -400,8 +400,16 @@ struct CmdFlakeCheck : FlakeCommand
auto packageInfo = getDerivation(*state, v, false); auto packageInfo = getDerivation(*state, v, false);
if (!packageInfo) if (!packageInfo)
throw Error("flake attribute '%s' is not a derivation", attrPath); throw Error("flake attribute '%s' is not a derivation", attrPath);
else {
// FIXME: check meta attributes // FIXME: check meta attributes
return packageInfo->queryDrvPath(); auto storePath = packageInfo->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);
@ -430,7 +438,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));
@ -454,7 +462,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));
@ -466,8 +474,6 @@ 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,
fmt("checking Hydra job %s", attrPath));
state->forceAttrs(v, pos, ""); state->forceAttrs(v, pos, "");
if (state->isDerivation(v)) if (state->isDerivation(v))
@ -542,7 +548,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");