about summary refs log tree commit diff
path: root/third_party/nix
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/nix')
-rw-r--r--third_party/nix/src/libmain/common-args.cc21
-rw-r--r--third_party/nix/src/libmain/meson.build47
-rw-r--r--third_party/nix/src/libmain/shared.cc82
-rw-r--r--third_party/nix/src/libmain/shared.hh6
4 files changed, 58 insertions, 98 deletions
diff --git a/third_party/nix/src/libmain/common-args.cc b/third_party/nix/src/libmain/common-args.cc
index e4c7c6daf6a5..bbd73cc840fa 100644
--- a/third_party/nix/src/libmain/common-args.cc
+++ b/third_party/nix/src/libmain/common-args.cc
@@ -1,4 +1,5 @@
 #include "common-args.hh"
+#include <glog/logging.h>
 #include "globals.hh"
 
 namespace nix {
@@ -6,24 +7,6 @@ namespace nix {
 MixCommonArgs::MixCommonArgs(const string& programName)
     : programName(programName) {
   mkFlag()
-      .longName("verbose")
-      .shortName('v')
-      .description("increase verbosity level")
-      .handler([]() { verbosity = (Verbosity)(verbosity + 1); });
-
-  mkFlag()
-      .longName("quiet")
-      .description("decrease verbosity level")
-      .handler([]() {
-        verbosity =
-            verbosity > lvlError ? (Verbosity)(verbosity - 1) : lvlError;
-      });
-
-  mkFlag().longName("debug").description("enable debug output").handler([]() {
-    verbosity = lvlDebug;
-  });
-
-  mkFlag()
       .longName("option")
       .labels({"name", "value"})
       .description("set a Nix configuration option (overriding nix.conf)")
@@ -32,7 +15,7 @@ MixCommonArgs::MixCommonArgs(const string& programName)
         try {
           globalConfig.set(ss[0], ss[1]);
         } catch (UsageError& e) {
-          warn(e.what());
+          LOG(WARNING) << e.what();
         }
       });
 
diff --git a/third_party/nix/src/libmain/meson.build b/third_party/nix/src/libmain/meson.build
index ec510ee2e5b8..052430105957 100644
--- a/third_party/nix/src/libmain/meson.build
+++ b/third_party/nix/src/libmain/meson.build
@@ -1,12 +1,3 @@
-# Nix lib store build file
-#============================================================================
-
-
-
-
-# src files
-#============================================================================
-
 src_inc += include_directories('.')
 
 libmain_src = files(
@@ -18,51 +9,21 @@ libmain_headers = files(
     join_paths(meson.source_root(), 'src/libmain/common-args.hh'),
     join_paths(meson.source_root(), 'src/libmain/shared.hh'))
 
-
-
-
-# dependancies
-#============================================================================
-
 libmain_dep_list = [
+    glog_dep,
     pthread_dep,
     openssl_dep,
-    libsodium_dep]
-
-
-
-
-
-# Link args
-#============================================================================
+    libsodium_dep,
+]
 
 libmain_link_list = [
     libutil_lib,
-    libstore_lib
+    libstore_lib,
 ]
 
 libmain_link_args = []
-
-
-
-
-# compiler args
-#============================================================================
-
 libstore_cxx_args = []
 
-
-
-
-# targets
-#============================================================================
-
-
-
-
-# build
-#============================================================================
-
 libmain_lib = library(
     'nixmain',
     install : true,
diff --git a/third_party/nix/src/libmain/shared.cc b/third_party/nix/src/libmain/shared.cc
index 72b84e28e020..fee18c5f1a05 100644
--- a/third_party/nix/src/libmain/shared.cc
+++ b/third_party/nix/src/libmain/shared.cc
@@ -1,4 +1,5 @@
 #include "shared.hh"
+#include <glog/logging.h>
 #include <openssl/crypto.h>
 #include <signal.h>
 #include <sys/stat.h>
@@ -20,53 +21,66 @@ static bool gcWarning = true;
 
 void printGCWarning() {
   if (!gcWarning) return;
+
   static bool haveWarned = false;
-  warnOnce(haveWarned,
-           "you did not specify '--add-root'; "
-           "the result might be removed by the garbage collector");
+  if (!haveWarned) {
+    haveWarned = true;
+    LOG(WARNING) << "you did not specify '--add-root'; "
+                 << "the result might be removed by the garbage collector";
+  }
 }
 
-void printMissing(ref<Store> store, const PathSet& paths, Verbosity lvl) {
+void printMissing(ref<Store> store, const PathSet& paths) {
   unsigned long long downloadSize, narSize;
   PathSet willBuild, willSubstitute, unknown;
   store->queryMissing(paths, willBuild, willSubstitute, unknown, downloadSize,
                       narSize);
-  printMissing(store, willBuild, willSubstitute, unknown, downloadSize, narSize,
-               lvl);
+  printMissing(store, willBuild, willSubstitute, unknown, downloadSize,
+               narSize);
 }
 
 void printMissing(ref<Store> store, const PathSet& willBuild,
                   const PathSet& willSubstitute, const PathSet& unknown,
-                  unsigned long long downloadSize, unsigned long long narSize,
-                  Verbosity lvl) {
+                  unsigned long long downloadSize, unsigned long long narSize) {
   if (!willBuild.empty()) {
-    printMsg(lvl, "these derivations will be built:");
+    LOG(INFO) << "these derivations will be built:";
     Paths sorted = store->topoSortPaths(willBuild);
     reverse(sorted.begin(), sorted.end());
-    for (auto& i : sorted) printMsg(lvl, fmt("  %s", i));
+    for (auto& i : sorted) {
+      LOG(INFO) << "  " << i;
+    }
   }
 
   if (!willSubstitute.empty()) {
-    printMsg(lvl, fmt("these paths will be fetched (%.2f MiB download, %.2f "
-                      "MiB unpacked):",
-                      downloadSize / (1024.0 * 1024.0),
-                      narSize / (1024.0 * 1024.0)));
-    for (auto& i : willSubstitute) printMsg(lvl, fmt("  %s", i));
+    LOG(INFO) << "these paths will be fetched ("
+              << (downloadSize / (1024.0 * 1024.0)) << " MiB download, "
+              << (narSize / (1024.0 * 1024.0)) << "MiB unpacked):";
+
+    for (auto& i : willSubstitute) {
+      LOG(INFO) << i;
+    }
   }
 
   if (!unknown.empty()) {
-    printMsg(lvl, fmt("don't know how to build these paths%s:",
-                      (settings.readOnlyMode
-                           ? " (may be caused by read-only store access)"
-                           : "")));
-    for (auto& i : unknown) printMsg(lvl, fmt("  %s", i));
+    LOG(INFO) << "don't know how to build these paths"
+              << (settings.readOnlyMode
+                      ? " (may be caused by read-only store access)"
+                      : "")
+              << ":";
+
+    for (auto& i : unknown) {
+      LOG(INFO) << i;
+    }
   }
 }
 
 string getArg(const string& opt, Strings::iterator& i,
               const Strings::iterator& end) {
   ++i;
-  if (i == end) throw UsageError(format("'%1%' requires an argument") % opt);
+  if (i == end) {
+    throw UsageError(format("'%1%' requires an argument") % opt);
+  }
+
   return *i;
 }
 
@@ -236,7 +250,9 @@ void parseCmdLine(
 
 void printVersion(const string& programName) {
   std::cout << format("%1% (Nix) %2%") % programName % nixVersion << std::endl;
-  if (verbosity > lvlInfo) {
+
+  // TODO(tazjin): figure out what the fuck this is
+  /*if (verbosity > lvlInfo) {
     Strings cfg;
 #if HAVE_BOEHMGC
     cfg.push_back("gc");
@@ -249,7 +265,7 @@ void printVersion(const string& programName) {
               << "\n";
     std::cout << "Store directory: " << settings.nixStore << "\n";
     std::cout << "State directory: " << settings.nixStateDir << "\n";
-  }
+    } */
   throw Exit();
 }
 
@@ -278,20 +294,21 @@ int handleExceptions(const string& programName, std::function<void()> fun) {
   } catch (Exit& e) {
     return e.status;
   } catch (UsageError& e) {
-    printError(format(error + "%1%\nTry '%2% --help' for more information.") %
-               e.what() % programName);
+    LOG(INFO) << e.what();
+    LOG(INFO) << "Try '"
+              << " --help' for more information." << programName;
     return 1;
   } catch (BaseError& e) {
-    printError(format(error + "%1%%2%") %
-               (settings.showTrace ? e.prefix() : "") % e.msg());
-    if (e.prefix() != "" && !settings.showTrace)
-      printError("(use '--show-trace' to show detailed location information)");
+    LOG(ERROR) << error << (settings.showTrace ? e.prefix() : "") << e.msg();
+    if (e.prefix() != "" && !settings.showTrace) {
+      LOG(INFO) << "(use '--show-trace' to show detailed location information)";
+    }
     return e.status;
   } catch (std::bad_alloc& e) {
-    printError(error + "out of memory");
+    LOG(ERROR) << error << "out of memory";
     return 1;
   } catch (std::exception& e) {
-    printError(error + e.what());
+    LOG(ERROR) << error << e.what();
     return 1;
   }
 
@@ -342,9 +359,10 @@ string showBytes(unsigned long long bytes) {
 }
 
 PrintFreed::~PrintFreed() {
-  if (show)
+  if (show) {
     std::cout << format("%1% store paths deleted, %2% freed\n") %
                      results.paths.size() % showBytes(results.bytesFreed);
+  }
 }
 
 Exit::~Exit() {}
diff --git a/third_party/nix/src/libmain/shared.hh b/third_party/nix/src/libmain/shared.hh
index 8f895109d7c5..68d4c49cf6ff 100644
--- a/third_party/nix/src/libmain/shared.hh
+++ b/third_party/nix/src/libmain/shared.hh
@@ -38,13 +38,11 @@ void printGCWarning();
 
 class Store;
 
-void printMissing(ref<Store> store, const PathSet& paths,
-                  Verbosity lvl = lvlInfo);
+void printMissing(ref<Store> store, const PathSet& paths);
 
 void printMissing(ref<Store> store, const PathSet& willBuild,
                   const PathSet& willSubstitute, const PathSet& unknown,
-                  unsigned long long downloadSize, unsigned long long narSize,
-                  Verbosity lvl = lvlInfo);
+                  unsigned long long downloadSize, unsigned long long narSize);
 
 string getArg(const string& opt, Strings::iterator& i,
               const Strings::iterator& end);