about summary refs log tree commit diff
path: root/src/libmain
diff options
context:
space:
mode:
Diffstat (limited to 'src/libmain')
-rw-r--r--src/libmain/shared.cc29
-rw-r--r--src/libmain/shared.hh2
2 files changed, 31 insertions, 0 deletions
diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc
index 5a8f600e8d36..fd16dece7d44 100644
--- a/src/libmain/shared.cc
+++ b/src/libmain/shared.cc
@@ -4,6 +4,7 @@
 #include "globals.hh"
 #include "store-api.hh"
 #include "util.hh"
+#include "misc.hh"
 
 #include <iostream>
 #include <cctype>
@@ -49,6 +50,34 @@ void printGCWarning()
 }
 
 
+void printMissing(const PathSet & paths)
+{
+    unsigned long long downloadSize;
+    PathSet willBuild, willSubstitute, unknown;
+    queryMissing(paths, willBuild, willSubstitute, unknown, downloadSize);
+
+    if (!willBuild.empty()) {
+        printMsg(lvlInfo, format("the following derivations will be built:"));
+        foreach (PathSet::iterator, i, willBuild)
+            printMsg(lvlInfo, format("  %1%") % *i);
+    }
+
+    if (!willSubstitute.empty()) {
+        printMsg(lvlInfo, format("the following paths will be downloaded/copied (%.2f MiB):") %
+            (downloadSize / (1024.0 * 1024.0)));
+        foreach (PathSet::iterator, i, willSubstitute)
+            printMsg(lvlInfo, format("  %1%") % *i);
+    }
+
+    if (!unknown.empty()) {
+        printMsg(lvlInfo, format("don't know how to build the following paths%1%:")
+            % (readOnlyMode ? " (may be caused by read-only store access)" : ""));
+        foreach (PathSet::iterator, i, unknown)
+            printMsg(lvlInfo, format("  %1%") % *i);
+    }
+}
+
+
 static void setLogType(string lt)
 {
     if (lt == "pretty") logType = ltPretty;
diff --git a/src/libmain/shared.hh b/src/libmain/shared.hh
index 95d80bacdae1..c432dc5f7b56 100644
--- a/src/libmain/shared.hh
+++ b/src/libmain/shared.hh
@@ -26,6 +26,8 @@ namespace nix {
 Path makeRootName(const Path & gcRoot, int & counter);
 void printGCWarning();
 
+void printMissing(const PathSet & paths);
+
 unsigned long long getIntArg(const string & opt,
     Strings::iterator & i, const Strings::iterator & end);