forked from lix-project/lix
raito
b8cb7abcf0
Here's my guide so far:
$ rg '((?!(recursive).*) Nix
(?!(daemon|store|expression|Rocks!|Packages|language|derivation|archive|account|user|sandbox|flake).*))'
-g '!doc/' --pcre2
All items from this query have been tackled. For the documentation side:
that's for lix-project/lix#162.
Additionally, all remaining references to github.com/NixOS/nix which
were not relevant were also replaced.
Fixes: lix-project/lix#148.
Fixes: lix-project/lix#162.
Change-Id: Ib3451fae5cb8ab8cd9ac9e4e4551284ee6794545
Signed-off-by: Raito Bezarius <raito@lix.systems>
81 lines
2 KiB
C++
81 lines
2 KiB
C++
#include "command.hh"
|
|
#include "common-args.hh"
|
|
#include "shared.hh"
|
|
#include "store-api.hh"
|
|
|
|
#include <nlohmann/json.hpp>
|
|
|
|
using namespace nix;
|
|
|
|
struct CmdConfig : virtual NixMultiCommand
|
|
{
|
|
CmdConfig() : MultiCommand(RegisterCommand::getCommandsFor({"config"}))
|
|
{ }
|
|
|
|
std::string description() override
|
|
{
|
|
return "manipulate the Lix configuration";
|
|
}
|
|
|
|
Category category() override { return catUtility; }
|
|
|
|
void run() override
|
|
{
|
|
if (!command)
|
|
throw UsageError("'nix config' requires a sub-command.");
|
|
command->second->run();
|
|
}
|
|
};
|
|
|
|
struct CmdConfigShow : Command, MixJSON
|
|
{
|
|
std::optional<std::string> name;
|
|
|
|
CmdConfigShow() {
|
|
expectArgs({
|
|
.label = {"name"},
|
|
.optional = true,
|
|
.handler = {&name},
|
|
});
|
|
}
|
|
|
|
std::string description() override
|
|
{
|
|
return "show the Lix configuration or the value of a specific setting";
|
|
}
|
|
|
|
Category category() override { return catUtility; }
|
|
|
|
void run() override
|
|
{
|
|
if (name) {
|
|
if (json) {
|
|
throw UsageError("'--json' is not supported when specifying a setting name");
|
|
}
|
|
|
|
std::map<std::string, Config::SettingInfo> settings;
|
|
globalConfig.getSettings(settings);
|
|
auto setting = settings.find(*name);
|
|
|
|
if (setting == settings.end()) {
|
|
throw Error("could not find setting '%1%'", *name);
|
|
} else {
|
|
const auto & value = setting->second.value;
|
|
logger->cout("%s", value);
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
if (json) {
|
|
// FIXME: use appropriate JSON types (bool, ints, etc).
|
|
logger->cout("%s", globalConfig.toJSON().dump());
|
|
} else {
|
|
logger->cout("%s", globalConfig.toKeyValue());
|
|
}
|
|
}
|
|
};
|
|
|
|
static auto rCmdConfig = registerCommand<CmdConfig>("config");
|
|
static auto rShowConfig = registerCommand2<CmdConfigShow>({"config", "show"});
|