aboutsummaryrefslogtreecommitdiff
path: root/src/nix-env/nix-env.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-12-03 21:01:41 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-12-03 21:01:41 +0100
commitd62fc71b851295b4c5692ec5fa362a06172e66ae (patch)
tree32fb195e8c584f3c32bb372e160f01fea9dc2356 /src/nix-env/nix-env.cc
parent4bb4d5479a8a2c2ed04bd65312ce1bfb6d2c0b13 (diff)
Fix the ‘--prebuilt-only’ flag
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;