aboutsummaryrefslogtreecommitdiff
path: root/src/nix-env/nix-env.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/nix-env/nix-env.cc')
-rw-r--r--src/nix-env/nix-env.cc19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc
index dda725606..b57e54c75 100644
--- a/src/nix-env/nix-env.cc
+++ b/src/nix-env/nix-env.cc
@@ -212,14 +212,14 @@ static int comparePriorities(EvalState & state,
}
+// FIXME: this function is rather slow since it checks a single path
+// at a time.
static bool isPrebuilt(EvalState & state, const DrvInfo & elem)
{
- assert(false);
-#if 0
- return
- store->isValidPath(elem.queryOutPath(state)) ||
- store->hasSubstitutes(elem.queryOutPath(state));
-#endif
+ Path path = elem.queryOutPath(state);
+ if (store->isValidPath(path)) return true;
+ PathSet ps = store->querySubstitutablePaths(singleton<PathSet>(path));
+ return ps.find(path) != ps.end();
}
@@ -938,7 +938,7 @@ static void opQuery(Globals & globals,
/* Query which paths have substitutes. */
PathSet validPaths, substitutablePaths;
- if (printStatus) {
+ if (printStatus || globals.prebuiltOnly) {
PathSet paths;
foreach (vector<DrvInfo>::iterator, i, elems2)
try {
@@ -964,7 +964,10 @@ static void opQuery(Globals & globals,
startNest(nest, lvlDebug, format("outputting query result `%1%'") % i->attrPath);
- if (globals.prebuiltOnly && !isPrebuilt(globals.state, *i)) continue;
+ if (globals.prebuiltOnly &&
+ validPaths.find(i->queryOutPath(globals.state)) == validPaths.end() &&
+ substitutablePaths.find(i->queryOutPath(globals.state)) == substitutablePaths.end())
+ continue;
/* For table output. */
Strings columns;