From 887bb5fa5a5a7b8b91d371de1a5c8280f9505744 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 23 Jul 2015 14:19:49 +0200 Subject: [PATCH] --version: Print some config info Such as whether Nix is built with signed binary cache support, and the location of the configuration file. --- src/libmain/shared.cc | 14 ++++++++++++++ src/nix-env/nix-env.cc | 8 +++++++- src/nix-store/nix-store.cc | 8 +++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc index 575fa339a..a6e8f352a 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 c5c7d2ccc..04f101616 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 039fbe4cb..d541b7b7d 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")