about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2015-07-23T12·19+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2015-07-23T12·38+0200
commit887bb5fa5a5a7b8b91d371de1a5c8280f9505744 (patch)
tree2486f49317aded421a8a33d692960651fff8a437 /src
parent1993b10d1169b04b83443a9ef5d4e3e38667afeb (diff)
--version: Print some config info
Such as whether Nix is built with signed binary cache support, and the
location of the configuration file.
Diffstat (limited to 'src')
-rw-r--r--src/libmain/shared.cc14
-rw-r--r--src/nix-env/nix-env.cc8
-rw-r--r--src/nix-store/nix-store.cc8
3 files changed, 28 insertions, 2 deletions
diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc
index 575fa339a86c..a6e8f352a0ab 100644
--- a/src/libmain/shared.cc
+++ b/src/libmain/shared.cc
@@ -243,6 +243,20 @@ void parseCmdLine(int argc, char * * argv,
 void printVersion(const string & programName)
 {
     std::cout << format("%1% (Nix) %2%") % programName % nixVersion << std::endl;
+    if (verbosity > lvlInfo) {
+        Strings cfg;
+#if HAVE_BOEHMGC
+        cfg.push_back("gc");
+#endif
+#if HAVE_SODIUM
+        cfg.push_back("signed-caches");
+#endif
+        std::cout << "Features: " << concatStringsSep(", ", cfg) << "\n";
+        std::cout << "Configuration file: " << settings.nixConfDir + "/nix.conf" << "\n";
+        std::cout << "Store directory: " << settings.nixStore << "\n";
+        std::cout << "State directory: " << settings.nixStateDir << "\n";
+        std::cout << "Database directory: " << settings.nixDBPath << "\n";
+    }
     throw Exit();
 }
 
diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc
index c5c7d2ccc713..04f1016167a9 100644
--- a/src/nix-env/nix-env.cc
+++ b/src/nix-env/nix-env.cc
@@ -1282,6 +1282,12 @@ static void opDeleteGenerations(Globals & globals, Strings opFlags, Strings opAr
 }
 
 
+static void opVersion(Globals & globals, Strings opFlags, Strings opArgs)
+{
+    printVersion("nix-env");
+}
+
+
 int main(int argc, char * * argv)
 {
     return handleExceptions(argv[0], [&]() {
@@ -1311,7 +1317,7 @@ int main(int argc, char * * argv)
             if (*arg == "--help")
                 showManPage("nix-env");
             else if (*arg == "--version")
-                printVersion("nix-env");
+                op = opVersion;
             else if (*arg == "--install" || *arg == "-i")
                 op = opInstall;
             else if (parseAutoArgs(arg, end, autoArgs_))
diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc
index 039fbe4cb1a3..d541b7b7d00a 100644
--- a/src/nix-store/nix-store.cc
+++ b/src/nix-store/nix-store.cc
@@ -1027,6 +1027,12 @@ static void opGenerateBinaryCacheKey(Strings opFlags, Strings opArgs)
 }
 
 
+static void opVersion(Strings opFlags, Strings opArgs)
+{
+    printVersion("nix-store");
+}
+
+
 /* Scan the arguments; find the operation, set global flags, put all
    other flags in a list, and put all other arguments in another
    list. */
@@ -1044,7 +1050,7 @@ int main(int argc, char * * argv)
             if (*arg == "--help")
                 showManPage("nix-store");
             else if (*arg == "--version")
-                printVersion("nix-store");
+                op = opVersion;
             else if (*arg == "--realise" || *arg == "--realize" || *arg == "-r")
                 op = opRealise;
             else if (*arg == "--add" || *arg == "-A")