From 2020998cfd0474cc8068040a2aac1a7943d5de9b Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Thu, 7 Mar 2024 03:08:07 +0100 Subject: [PATCH 1/4] Log what `nix flake check` does There's still room for improvement, but this produces much more informative output with `-v`: ``` $ nix flake check -v evaluating flake... checking flake output 'checks'... checking derivation checks.aarch64-darwin.ghcid-ng-tests... checking derivation checks.aarch64-darwin.ghcid-ng-clippy... checking derivation checks.aarch64-darwin.ghcid-ng-doc... checking derivation checks.aarch64-darwin.ghcid-ng-fmt... checking derivation checks.aarch64-darwin.ghcid-ng-audit... checking flake output 'packages'... checking derivation packages.aarch64-darwin.ghcid-ng... checking derivation packages.aarch64-darwin.ghcid-ng-tests... checking derivation packages.aarch64-darwin.default... checking flake output 'apps'... checking flake output 'devShells'... checking derivation devShells.aarch64-darwin.default... running flake checks... warning: The check omitted these incompatible systems: aarch64-linux, x86_64-darwin, x86_64-linux Use '--all-systems' to check all. ``` (cherry picked from commit 49221493e243c4d10e69e7465a21be53902e16a8) Change-Id: Ib1d58fe48cc82f4801a2ee5f91ba0d5a74907c0b --- src/nix/flake.cc | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/nix/flake.cc b/src/nix/flake.cc index 87dd4da1b..cbbd586ec 100644 --- a/src/nix/flake.cc +++ b/src/nix/flake.cc @@ -354,6 +354,8 @@ struct CmdFlakeCheck : FlakeCommand auto checkDerivation = [&](const std::string & attrPath, Value & v, const PosIdx pos) -> std::optional { 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); @@ -386,6 +388,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 +412,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 +425,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 +436,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 +451,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 +466,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 +500,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 +521,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 { From f2c32738ad0862bc6b1cf8d87fa7855ccf763ced Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Thu, 7 Mar 2024 03:20:21 +0100 Subject: [PATCH 2/4] Print derivation paths Also be more consistent with quotes around attribute paths (cherry picked from commit 9404ce36e4edd1df12892089bdab1ceb7d4d7a97) Change-Id: Iaa80073b4a07a6ffef106a3c12ecd02b4f6f67aa --- src/nix/flake.cc | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/nix/flake.cc b/src/nix/flake.cc index cbbd586ec..69e531681 100644 --- a/src/nix/flake.cc +++ b/src/nix/flake.cc @@ -359,8 +359,16 @@ struct CmdFlakeCheck : FlakeCommand 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); @@ -389,7 +397,7 @@ 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)); + fmt("checking overlay '%s'", attrPath)); state->forceValue(v, pos); if (!v.isLambda()) { 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) { try { Activity act(*logger, lvlInfo, actUnknown, - fmt("checking NixOS module %s", attrPath)); + 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)); @@ -426,7 +434,7 @@ 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)); + fmt("checking Hydra job '%s'", attrPath)); state->forceAttrs(v, pos, ""); if (state->isDerivation(v)) @@ -501,7 +509,7 @@ 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)); + fmt("checking bundler '%s'", attrPath)); state->forceValue(v, pos); if (!v.isLambda()) throw Error("bundler must be a function"); From 689a5f22f170c64e1fa1a2e2e999ec6ba64e976c Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Thu, 7 Mar 2024 03:21:23 +0100 Subject: [PATCH 3/4] Print how many checks are run (cherry picked from commit d75a5f427a385e56c821fdf49a70a150fe7fe6fd) Change-Id: I778edad1928adf90a69d0bbe8dd36623181b20d4 --- src/nix/flake.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/nix/flake.cc b/src/nix/flake.cc index 69e531681..0da9b1ce9 100644 --- a/src/nix/flake.cc +++ b/src/nix/flake.cc @@ -742,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) From bb7e7711b4510ea6ef66056f3651476b9c442ca8 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Thu, 7 Mar 2024 03:30:05 +0100 Subject: [PATCH 4/4] Add release notes (cherry picked from commit 561a56cd13b4f12e3dfb6c5e3f42e5d8add04ecc) === Modified the release notes' synopsis to make it match its contents, probably a copy-paste. Co-authored-by: Raito Bezarius Change-Id: I03bbff940b93e7df4b6c2fe9159c49a59ed47b55 --- .../rl-next/nix-flake-check-logs-actions.md | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 doc/manual/rl-next/nix-flake-check-logs-actions.md diff --git a/doc/manual/rl-next/nix-flake-check-logs-actions.md b/doc/manual/rl-next/nix-flake-check-logs-actions.md new file mode 100644 index 000000000..01ec56a3a --- /dev/null +++ b/doc/manual/rl-next/nix-flake-check-logs-actions.md @@ -0,0 +1,33 @@ +--- +synopsis: "`nix flake check` logs the checks" +issues: 8882 +prs: 8893 +--- + +`nix flake check` now logs the checks it runs and the derivations it evaluates: + +``` +$ nix flake check -v +evaluating flake... +checking flake output 'checks'... +checking derivation 'checks.aarch64-darwin.ghciwatch-tests'... +derivation evaluated to /nix/store/nh7dlvsrhds4cxl91mvgj4h5cbq6skmq-ghciwatch-test-0.3.0.drv +checking derivation 'checks.aarch64-darwin.ghciwatch-clippy'... +derivation evaluated to /nix/store/9cb5a6wmp6kf6hidqw9wphidvb8bshym-ghciwatch-clippy-0.3.0.drv +checking derivation 'checks.aarch64-darwin.ghciwatch-doc'... +derivation evaluated to /nix/store/8brdd3jbawfszpbs7vdpsrhy80as1il8-ghciwatch-doc-0.3.0.drv +checking derivation 'checks.aarch64-darwin.ghciwatch-fmt'... +derivation evaluated to /nix/store/wjhs0l1njl5pyji53xlmfjrlya0wmz8p-ghciwatch-fmt-0.3.0.drv +checking derivation 'checks.aarch64-darwin.ghciwatch-audit'... +derivation evaluated to /nix/store/z0mps8dyj2ds7c0fn0819y5h5611033z-ghciwatch-audit-0.3.0.drv +checking flake output 'packages'... +checking derivation 'packages.aarch64-darwin.default'... +derivation evaluated to /nix/store/41abbdyglw5x9vcsvd89xan3ydjf8d7r-ghciwatch-0.3.0.drv +checking flake output 'apps'... +checking flake output 'devShells'... +checking derivation 'devShells.aarch64-darwin.default'... +derivation evaluated to /nix/store/bc935gz7dylzmcpdb5cczr8gngv8pmdb-nix-shell.drv +running 5 flake checks... +warning: The check omitted these incompatible systems: aarch64-linux, x86_64-darwin, x86_64-linux +Use '--all-systems' to check all. +```