about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2010-11-17T14·31+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2010-11-17T14·31+0000
commitbdf089f46362b8c9defefa0a14e3198582e12818 (patch)
tree08ca2824d09cee5b00cbf9b9fc9294f326120598 /src
parent06699d4219019182d9e45ebc613ae1a1df23f257 (diff)
* Before a build, show the disk space that the downloaded store paths
  will approximately require.

Diffstat (limited to 'src')
-rw-r--r--src/libmain/shared.cc13
-rw-r--r--src/libstore/local-store.cc1
-rw-r--r--src/libstore/misc.cc5
-rw-r--r--src/libstore/misc.hh2
-rw-r--r--src/libstore/remote-store.cc4
-rw-r--r--src/libstore/store-api.hh1
-rw-r--r--src/libstore/worker-protocol.hh2
-rw-r--r--src/nix-worker/nix-worker.cc2
8 files changed, 18 insertions, 12 deletions
diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc
index d7879f035607..7c2d9203063e 100644
--- a/src/libmain/shared.cc
+++ b/src/libmain/shared.cc
@@ -54,25 +54,26 @@ void printGCWarning()
 
 void printMissing(const PathSet & paths)
 {
-    unsigned long long downloadSize;
+    unsigned long long downloadSize, narSize;
     PathSet willBuild, willSubstitute, unknown;
-    queryMissing(paths, willBuild, willSubstitute, unknown, downloadSize);
+    queryMissing(paths, willBuild, willSubstitute, unknown, downloadSize, narSize);
 
     if (!willBuild.empty()) {
-        printMsg(lvlInfo, format("the following derivations will be built:"));
+        printMsg(lvlInfo, format("these 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)));
+        printMsg(lvlInfo, format("these paths will be downloaded/copied (%.2f MiB download, %.2f MiB unpacked):")
+            % (downloadSize / (1024.0 * 1024.0))
+            % (narSize / (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%:")
+        printMsg(lvlInfo, format("don't know how to build these paths%1%:")
             % (readOnlyMode ? " (may be caused by read-only store access)" : ""));
         foreach (PathSet::iterator, i, unknown)
             printMsg(lvlInfo, format("  %1%") % *i);
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index 201e4bae124a..37bbbfdad886 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -839,6 +839,7 @@ bool LocalStore::querySubstitutablePathInfo(const Path & substituter,
         info.references.insert(p);
     }
     info.downloadSize = getIntLine<long long>(run.from);
+    info.narSize = getIntLine<long long>(run.from);
     
     return true;
 }
diff --git a/src/libstore/misc.cc b/src/libstore/misc.cc
index d52dd6346c7a..01d6a97ae6fb 100644
--- a/src/libstore/misc.cc
+++ b/src/libstore/misc.cc
@@ -48,9 +48,9 @@ Path findOutput(const Derivation & drv, string id)
 
 void queryMissing(const PathSet & targets,
     PathSet & willBuild, PathSet & willSubstitute, PathSet & unknown,
-    unsigned long long & downloadSize)
+    unsigned long long & downloadSize, unsigned long long & narSize)
 {
-    downloadSize = 0;
+    downloadSize = narSize = 0;
     
     PathSet todo(targets.begin(), targets.end()), done;
 
@@ -88,6 +88,7 @@ void queryMissing(const PathSet & targets,
             if (store->querySubstitutablePathInfo(p, info)) {
                 willSubstitute.insert(p);
                 downloadSize += info.downloadSize;
+                narSize += info.narSize;
                 todo.insert(info.references.begin(), info.references.end());
             } else
                 unknown.insert(p);
diff --git a/src/libstore/misc.hh b/src/libstore/misc.hh
index 0bc9a2ee0d9c..abef6237e7f6 100644
--- a/src/libstore/misc.hh
+++ b/src/libstore/misc.hh
@@ -31,7 +31,7 @@ Path findOutput(const Derivation & drv, string id);
    will be substituted. */
 void queryMissing(const PathSet & targets,
     PathSet & willBuild, PathSet & willSubstitute, PathSet & unknown,
-    unsigned long long & downloadSize);
+    unsigned long long & downloadSize, unsigned long long & narSize);
 
 
 }
diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc
index 08969a623d14..26093a5d3abc 100644
--- a/src/libstore/remote-store.cc
+++ b/src/libstore/remote-store.cc
@@ -191,9 +191,8 @@ void RemoteStore::setOptions()
         writeInt(logType, to);
         writeInt(printBuildTrace, to);
     }
-    if (GET_PROTOCOL_MINOR(daemonVersion) >= 6) {
+    if (GET_PROTOCOL_MINOR(daemonVersion) >= 6)
         writeInt(buildCores, to);
-    }
     processStderr();
 }
 
@@ -243,6 +242,7 @@ bool RemoteStore::querySubstitutablePathInfo(const Path & path,
     if (info.deriver != "") assertStorePath(info.deriver);
     info.references = readStorePaths(from);
     info.downloadSize = readLongLong(from);
+    info.narSize = GET_PROTOCOL_MINOR(daemonVersion) >= 7 ? readLongLong(from) : 0;
     return true;
 }
 
diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh
index b0071da83b1b..40ac887140d7 100644
--- a/src/libstore/store-api.hh
+++ b/src/libstore/store-api.hh
@@ -87,6 +87,7 @@ struct SubstitutablePathInfo
     Path deriver;
     PathSet references;
     unsigned long long downloadSize; /* 0 = unknown or inapplicable */
+    unsigned long long narSize; /* 0 = unknown */
 };
 
 
diff --git a/src/libstore/worker-protocol.hh b/src/libstore/worker-protocol.hh
index 2764f82c2ce0..d77049bc7188 100644
--- a/src/libstore/worker-protocol.hh
+++ b/src/libstore/worker-protocol.hh
@@ -8,7 +8,7 @@ namespace nix {
 #define WORKER_MAGIC_1 0x6e697863
 #define WORKER_MAGIC_2 0x6478696f
 
-#define PROTOCOL_VERSION 0x106
+#define PROTOCOL_VERSION 0x107
 #define GET_PROTOCOL_MAJOR(x) ((x) & 0xff00)
 #define GET_PROTOCOL_MINOR(x) ((x) & 0x00ff)
 
diff --git a/src/nix-worker/nix-worker.cc b/src/nix-worker/nix-worker.cc
index dbcd90be1b2e..081b5b2fd9f4 100644
--- a/src/nix-worker/nix-worker.cc
+++ b/src/nix-worker/nix-worker.cc
@@ -521,6 +521,8 @@ static void performOp(unsigned int clientVersion,
             writeString(info.deriver, to);
             writeStringSet(info.references, to);
             writeLongLong(info.downloadSize, to);
+            if (GET_PROTOCOL_MINOR(clientVersion) >= 7)
+                writeLongLong(info.narSize, to);
         }
         break;
     }