-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nix-store: implement --query --unsubstitutable #7526
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -276,7 +276,7 @@ static void opQuery(Strings opFlags, Strings opArgs) | |||||
enum QueryType | ||||||
{ qDefault, qOutputs, qRequisites, qReferences, qReferrers | ||||||
, qReferrersClosure, qDeriver, qBinding, qHash, qSize | ||||||
, qTree, qGraph, qGraphML, qResolve, qRoots }; | ||||||
, qTree, qGraph, qGraphML, qResolve, qRoots, qUnsubstitutable }; | ||||||
QueryType query = qDefault; | ||||||
bool useOutput = false; | ||||||
bool includeOutputs = false; | ||||||
|
@@ -300,6 +300,7 @@ static void opQuery(Strings opFlags, Strings opArgs) | |||||
} | ||||||
else if (i == "--hash") query = qHash; | ||||||
else if (i == "--size") query = qSize; | ||||||
else if (i == "--unsubstitutable" || i == "-U") query = qUnsubstitutable; | ||||||
else if (i == "--tree") query = qTree; | ||||||
else if (i == "--graph") query = qGraph; | ||||||
else if (i == "--graphml") query = qGraphML; | ||||||
|
@@ -364,6 +365,39 @@ static void opQuery(Strings opFlags, Strings opArgs) | |||||
} | ||||||
break; | ||||||
|
||||||
case qUnsubstitutable: { | ||||||
if (opArgs.empty()) throw UsageError("no paths passed"); | ||||||
|
||||||
StorePathSet storePaths; | ||||||
for (auto const & str : opArgs) { | ||||||
storePaths.emplace(store->followLinksToStorePath(str)); | ||||||
} | ||||||
nrdxp marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
StringSet pathsS; | ||||||
// query each configured substituter | ||||||
for (auto & sub : getDefaultSubstituters()) { | ||||||
if (sub->storeDir != store->storeDir) continue; | ||||||
if (!sub->wantMassQuery) continue; | ||||||
|
||||||
auto paths = sub->queryValidPaths(StorePathSet(storePaths.begin(), storePaths.end())); | ||||||
for (auto & path : paths) { | ||||||
pathsS.emplace(store->printStorePath(path)); | ||||||
} | ||||||
} | ||||||
|
||||||
StorePathSet substitutablePaths; | ||||||
for (auto & str : pathsS) { | ||||||
substitutablePaths.emplace(store->followLinksToStorePath(str)); | ||||||
} | ||||||
|
||||||
for ( auto & path : storePaths) { | ||||||
if (substitutablePaths.find(path) == substitutablePaths.end()) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does not short-circuit There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In what way? On an But since we're fine with C++20 now, you can also use |
||||||
std::cout << '\n' << store->printStorePath(path); | ||||||
} | ||||||
std::cout << std::endl; | ||||||
break; | ||||||
} | ||||||
|
||||||
case qBinding: | ||||||
for (auto & i : opArgs) { | ||||||
auto path = useDeriver(store->followLinksToStorePath(i)); | ||||||
|
@@ -680,7 +714,6 @@ static void opExport(Strings opFlags, Strings opArgs) | |||||
sink.flush(); | ||||||
} | ||||||
|
||||||
|
||||||
static void opImport(Strings opFlags, Strings opArgs) | ||||||
{ | ||||||
for (auto & i : opFlags) | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indentation here and below is wrong (should be 4 characters per level).