Skip to content

Commit

Permalink
Fix the ‘--prebuilt-only’ flag
Browse files Browse the repository at this point in the history
  • Loading branch information
edolstra committed Dec 3, 2012
1 parent 4bb4d54 commit d62fc71
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/nix-env/nix-env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}


Expand Down Expand Up @@ -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 {
Expand All @@ -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;
Expand Down

0 comments on commit d62fc71

Please sign in to comment.