aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-03-07 18:48:17 -0700
committerGerrit Code Review <gerrit@lix>2024-03-07 18:48:17 -0700
commitd76125747f91fc719755e39c3771ddddb7aed92d (patch)
tree6f063d74aa3804603e86261727b150d16f83fc3e /src
parent232f4feacebb5c9ea7072238ae3e565c2c292b70 (diff)
parentbb7e7711b4510ea6ef66056f3651476b9c442ca8 (diff)
Merge changes I03bbff94,I778edad1,Iaa80073b,Ib1d58fe4 into main
* changes: Add release notes Print how many checks are run Print derivation paths Log what `nix flake check` does
Diffstat (limited to 'src')
-rw-r--r--src/nix/flake.cc33
1 files changed, 26 insertions, 7 deletions
diff --git a/src/nix/flake.cc b/src/nix/flake.cc
index 87dd4da1b..0da9b1ce9 100644
--- a/src/nix/flake.cc
+++ b/src/nix/flake.cc
@@ -354,11 +354,21 @@ struct CmdFlakeCheck : FlakeCommand
auto checkDerivation = [&](const std::string & attrPath, Value & v, const PosIdx pos) -> std::optional<StorePath> {
try {
+ Activity act(*logger, lvlInfo, actUnknown,
+ fmt("checking derivation %s", attrPath));
auto drvInfo = getDerivation(*state, v, false);
if (!drvInfo)
throw Error("flake attribute '%s' is not a derivation", attrPath);
- // FIXME: check meta attributes
- return drvInfo->queryDrvPath();
+ else {
+ // 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) {
e.addTrace(resolve(pos), hintfmt("while checking the derivation '%s'", attrPath));
reportError(e);
@@ -386,6 +396,8 @@ struct CmdFlakeCheck : FlakeCommand
auto checkOverlay = [&](const std::string & attrPath, Value & v, const PosIdx pos) {
try {
+ Activity act(*logger, lvlInfo, actUnknown,
+ fmt("checking overlay '%s'", attrPath));
state->forceValue(v, pos);
if (!v.isLambda()) {
throw Error("overlay is not a function, but %s instead", showType(v));
@@ -408,6 +420,8 @@ struct CmdFlakeCheck : FlakeCommand
auto checkModule = [&](const std::string & attrPath, Value & v, const PosIdx pos) {
try {
+ Activity act(*logger, lvlInfo, actUnknown,
+ fmt("checking NixOS module '%s'", attrPath));
state->forceValue(v, pos);
} catch (Error & e) {
e.addTrace(resolve(pos), hintfmt("while checking the NixOS module '%s'", attrPath));
@@ -419,6 +433,8 @@ struct CmdFlakeCheck : FlakeCommand
checkHydraJobs = [&](const std::string & attrPath, Value & v, const PosIdx pos) {
try {
+ Activity act(*logger, lvlInfo, actUnknown,
+ fmt("checking Hydra job '%s'", attrPath));
state->forceAttrs(v, pos, "");
if (state->isDerivation(v))
@@ -428,7 +444,7 @@ struct CmdFlakeCheck : FlakeCommand
state->forceAttrs(*attr.value, attr.pos, "");
auto attrPath2 = concatStrings(attrPath, ".", state->symbols[attr.name]);
if (state->isDerivation(*attr.value)) {
- Activity act(*logger, lvlChatty, actUnknown,
+ Activity act(*logger, lvlInfo, actUnknown,
fmt("checking Hydra job '%s'", attrPath2));
checkDerivation(attrPath2, *attr.value, attr.pos);
} else
@@ -443,7 +459,7 @@ struct CmdFlakeCheck : FlakeCommand
auto checkNixOSConfiguration = [&](const std::string & attrPath, Value & v, const PosIdx pos) {
try {
- Activity act(*logger, lvlChatty, actUnknown,
+ Activity act(*logger, lvlInfo, actUnknown,
fmt("checking NixOS configuration '%s'", attrPath));
Bindings & bindings(*state->allocBindings(0));
auto vToplevel = findAlongAttrPath(*state, "config.system.build.toplevel", bindings, v).first;
@@ -458,7 +474,7 @@ struct CmdFlakeCheck : FlakeCommand
auto checkTemplate = [&](const std::string & attrPath, Value & v, const PosIdx pos) {
try {
- Activity act(*logger, lvlChatty, actUnknown,
+ Activity act(*logger, lvlInfo, actUnknown,
fmt("checking template '%s'", attrPath));
state->forceAttrs(v, pos, "");
@@ -492,6 +508,8 @@ struct CmdFlakeCheck : FlakeCommand
auto checkBundler = [&](const std::string & attrPath, Value & v, const PosIdx pos) {
try {
+ Activity act(*logger, lvlInfo, actUnknown,
+ fmt("checking bundler '%s'", attrPath));
state->forceValue(v, pos);
if (!v.isLambda())
throw Error("bundler must be a function");
@@ -511,7 +529,7 @@ struct CmdFlakeCheck : FlakeCommand
enumerateOutputs(*state,
*vFlake,
[&](const std::string & name, Value & vOutput, const PosIdx pos) {
- Activity act(*logger, lvlChatty, actUnknown,
+ Activity act(*logger, lvlInfo, actUnknown,
fmt("checking flake output '%s'", name));
try {
@@ -724,7 +742,8 @@ struct CmdFlakeCheck : FlakeCommand
}
if (build && !drvPaths.empty()) {
- Activity act(*logger, lvlInfo, actUnknown, "running flake checks");
+ Activity act(*logger, lvlInfo, actUnknown,
+ fmt("running %d flake checks", drvPaths.size()));
store->buildPaths(drvPaths);
}
if (hasErrors)