Skip to content

Commit 668088b

Browse files
authored
Merge pull request #134 from DeterminateSystems/nix-flake-check-dont-build
nix flake check: Skip substitutable derivations
2 parents 0638370 + 5c95921 commit 668088b

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

src/nix/flake.cc

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,8 +833,31 @@ struct CmdFlakeCheck : FlakeCommand
833833
if (build && !drvPaths.empty()) {
834834
Activity act(*logger, lvlInfo, actUnknown,
835835
fmt("running %d flake checks", drvPaths.size()));
836-
store->buildPaths(drvPaths);
836+
837+
auto missing = store->queryMissing(drvPaths);
838+
839+
/* This command doesn't need to actually substitute
840+
derivation outputs if they're missing but
841+
substitutable. So filter out derivations that are
842+
substitutable or already built. */
843+
std::vector<DerivedPath> toBuild;
844+
for (auto & path : drvPaths) {
845+
std::visit(overloaded {
846+
[&](const DerivedPath::Built & bfd) {
847+
auto drvPathP = std::get_if<DerivedPath::Opaque>(&*bfd.drvPath);
848+
if (!drvPathP || missing.willBuild.contains(drvPathP->path))
849+
toBuild.push_back(path);
850+
},
851+
[&](const DerivedPath::Opaque & bo) {
852+
if (!missing.willSubstitute.contains(bo.path))
853+
toBuild.push_back(path);
854+
},
855+
}, path.raw());
856+
}
857+
858+
store->buildPaths(toBuild);
837859
}
860+
838861
if (hasErrors)
839862
throw Error("some errors were encountered during the evaluation");
840863

0 commit comments

Comments
 (0)