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.cc28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc
index 7aa6276e3..f06f23dad 100644
--- a/src/nix-env/nix-env.cc
+++ b/src/nix-env/nix-env.cc
@@ -211,9 +211,12 @@ static int comparePriorities(EvalState & state,
static bool isPrebuilt(EvalState & state, const DrvInfo & elem)
{
+ assert(false);
+#if 0
return
store->isValidPath(elem.queryOutPath(state)) ||
store->hasSubstitutes(elem.queryOutPath(state));
+#endif
}
@@ -929,6 +932,22 @@ static void opQuery(Globals & globals,
installed.insert(i->queryOutPath(globals.state));
}
+
+ /* Query which paths have substitutes. */
+ PathSet validPaths, substitutablePaths;
+ if (printStatus) {
+ PathSet paths;
+ foreach (vector<DrvInfo>::iterator, i, elems2)
+ try {
+ paths.insert(i->queryOutPath(globals.state));
+ } catch (AssertionError & e) {
+ printMsg(lvlTalkative, format("skipping derivation named `%1%' which gives an assertion failure") % i->name);
+ i->setFailed();
+ }
+ validPaths = store->queryValidPaths(paths);
+ substitutablePaths = store->querySubstitutablePaths(paths);
+ }
+
/* Print the desired columns, or XML output. */
Table table;
@@ -938,6 +957,8 @@ static void opQuery(Globals & globals,
foreach (vector<DrvInfo>::iterator, i, elems2) {
try {
+ if (i->hasFailed()) continue;
+
startNest(nest, lvlDebug, format("outputting query result `%1%'") % i->attrPath);
if (globals.prebuiltOnly && !isPrebuilt(globals.state, *i)) continue;
@@ -949,9 +970,10 @@ static void opQuery(Globals & globals,
XMLAttrs attrs;
if (printStatus) {
- bool hasSubs = store->hasSubstitutes(i->queryOutPath(globals.state));
- bool isInstalled = installed.find(i->queryOutPath(globals.state)) != installed.end();
- bool isValid = store->isValidPath(i->queryOutPath(globals.state));
+ Path outPath = i->queryOutPath(globals.state);
+ bool hasSubs = substitutablePaths.find(outPath) != substitutablePaths.end();
+ bool isInstalled = installed.find(outPath) != installed.end();
+ bool isValid = validPaths.find(outPath) != validPaths.end();
if (xmlOutput) {
attrs["installed"] = isInstalled ? "1" : "0";
attrs["valid"] = isValid ? "1" : "0";