1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-11 13:06:01 +01:00

Merge pull request #134 from DeterminateSystems/nix-flake-check-dont-build

nix flake check: Skip substitutable derivations
This commit is contained in:
Eelco Dolstra 2025-07-09 19:07:52 +00:00 committed by GitHub
commit 668088b876
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -833,8 +833,31 @@ struct CmdFlakeCheck : FlakeCommand
if (build && !drvPaths.empty()) {
Activity act(*logger, lvlInfo, actUnknown,
fmt("running %d flake checks", drvPaths.size()));
store->buildPaths(drvPaths);
auto missing = store->queryMissing(drvPaths);
/* This command doesn't need to actually substitute
derivation outputs if they're missing but
substitutable. So filter out derivations that are
substitutable or already built. */
std::vector<DerivedPath> toBuild;
for (auto & path : drvPaths) {
std::visit(overloaded {
[&](const DerivedPath::Built & bfd) {
auto drvPathP = std::get_if<DerivedPath::Opaque>(&*bfd.drvPath);
if (!drvPathP || missing.willBuild.contains(drvPathP->path))
toBuild.push_back(path);
},
[&](const DerivedPath::Opaque & bo) {
if (!missing.willSubstitute.contains(bo.path))
toBuild.push_back(path);
},
}, path.raw());
}
store->buildPaths(toBuild);
}
if (hasErrors)
throw Error("some errors were encountered during the evaluation");