aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nix-store/nix-store.cc18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc
index 94956df66..96c3f7d7e 100644
--- a/src/nix-store/nix-store.cc
+++ b/src/nix-store/nix-store.cc
@@ -283,7 +283,7 @@ static void opQuery(Strings opFlags, Strings opArgs)
{
enum QueryType
{ qOutputs, qRequisites, qReferences, qReferrers
- , qReferrersClosure, qDeriver, qBinding, qHash, qSize
+ , qReferrersClosure, qDeriver, qValidDerivers, qBinding, qHash, qSize
, qTree, qGraph, qGraphML, qResolve, qRoots };
std::optional<QueryType> query;
bool useOutput = false;
@@ -299,6 +299,7 @@ static void opQuery(Strings opFlags, Strings opArgs)
else if (i == "--referrers" || i == "--referers") query = qReferrers;
else if (i == "--referrers-closure" || i == "--referers-closure") query = qReferrersClosure;
else if (i == "--deriver" || i == "-d") query = qDeriver;
+ else if (i == "--valid-derivers") query = qValidDerivers;
else if (i == "--binding" || i == "-b") {
if (opArgs.size() == 0)
throw UsageError("expected binding name");
@@ -372,6 +373,21 @@ static void opQuery(Strings opFlags, Strings opArgs)
}
break;
+ case qValidDerivers: {
+ StorePathSet result;
+ for (auto & i : opArgs) {
+ auto derivers = store->queryValidDerivers(store->followLinksToStorePath(i));
+ for (const auto &i: derivers) {
+ result.insert(i);
+ }
+ }
+ auto sorted = store->topoSortPaths(result);
+ for (StorePaths::reverse_iterator i = sorted.rbegin();
+ i != sorted.rend(); ++i)
+ cout << fmt("%s\n", store->printStorePath(*i));
+ break;
+ }
+
case qBinding:
for (auto & i : opArgs) {
auto path = useDeriver(store->followLinksToStorePath(i));