aboutsummaryrefslogtreecommitdiff
path: root/src/nix-store/nix-store.cc
diff options
context:
space:
mode:
authorGuillaume Girol <symphorien+git@xlumurb.eu>2023-08-23 12:00:00 +0000
committerGuillaume Girol <symphorien+git@xlumurb.eu>2023-08-24 11:37:24 +0200
commit925a444b925590df90e19d3c0071936f87d2b43d (patch)
tree085a36dc6f2972ad5ac676d95231ec29b027a8ea /src/nix-store/nix-store.cc
parent6459a1c7ad1ad1a88fae42f9737e969c6ae89679 (diff)
add nix-store --query --valid-derivers command
notably useful when nix-store --query --deriver returns a non-existing path. Co-authored-by: Felix Uhl <iFreilicht@users.noreply.github.com>
Diffstat (limited to 'src/nix-store/nix-store.cc')
-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));