lix/src/nix/show-config.cc
Eelco Dolstra 737ed88f35
Modularize config settings
Allow global config settings to be defined in multiple Config
classes. For example, this means that libutil can have settings and
evaluator settings can be moved out of libstore. The Config classes
are registered in a new GlobalConfig class to which config files
etc. are applied.

Relevant to https://github.com/NixOS/nix/issues/2009 in that it
removes the need for ad hoc handling of useCaseHack, which was the
underlying cause of that issue.
2018-05-30 13:28:01 +02:00

41 lines
897 B
C++

#include "command.hh"
#include "common-args.hh"
#include "shared.hh"
#include "store-api.hh"
#include "json.hh"
using namespace nix;
struct CmdShowConfig : Command, MixJSON
{
CmdShowConfig()
{
}
std::string name() override
{
return "show-config";
}
std::string description() override
{
return "show the Nix configuration";
}
void run() override
{
if (json) {
// FIXME: use appropriate JSON types (bool, ints, etc).
JSONObject jsonObj(std::cout);
globalConfig.toJSON(jsonObj);
} else {
std::map<std::string, Config::SettingInfo> settings;
globalConfig.getSettings(settings);
for (auto & s : settings)
std::cout << s.first + " = " + s.second.value + "\n";
}
}
};
static RegisterCommand r1(make_ref<CmdShowConfig>());