forked from lix-project/lix
Move applyConfigFile to lambda inside libstore
This commit is contained in:
parent
e4cbdd26e0
commit
d6898cd58b
|
@ -111,7 +111,14 @@ Settings::Settings()
|
||||||
|
|
||||||
void loadConfFile()
|
void loadConfFile()
|
||||||
{
|
{
|
||||||
globalConfig.applyConfigFile(settings.nixConfDir + "/nix.conf");
|
auto applyConfigFile = [&](const Path & path) {
|
||||||
|
try {
|
||||||
|
std::string contents = readFile(path);
|
||||||
|
globalConfig.applyConfig(contents, path);
|
||||||
|
} catch (SysError &) { }
|
||||||
|
};
|
||||||
|
|
||||||
|
applyConfigFile(settings.nixConfDir + "/nix.conf");
|
||||||
|
|
||||||
/* We only want to send overrides to the daemon, i.e. stuff from
|
/* We only want to send overrides to the daemon, i.e. stuff from
|
||||||
~/.nix/nix.conf or the command line. */
|
~/.nix/nix.conf or the command line. */
|
||||||
|
@ -119,7 +126,7 @@ void loadConfFile()
|
||||||
|
|
||||||
auto files = settings.nixUserConfFiles;
|
auto files = settings.nixUserConfFiles;
|
||||||
for (auto file = files.rbegin(); file != files.rend(); file++) {
|
for (auto file = files.rbegin(); file != files.rend(); file++) {
|
||||||
globalConfig.applyConfigFile(*file);
|
applyConfigFile(*file);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto nixConfEnv = getEnv("NIX_CONFIG");
|
auto nixConfEnv = getEnv("NIX_CONFIG");
|
||||||
|
|
|
@ -165,14 +165,6 @@ void AbstractConfig::applyConfig(const std::string & contents, const std::string
|
||||||
set(name, value);
|
set(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractConfig::applyConfigFile(const Path & path)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
std::string contents = readFile(path);
|
|
||||||
applyConfig(contents, path);
|
|
||||||
} catch (SysError &) { }
|
|
||||||
}
|
|
||||||
|
|
||||||
void Config::resetOverridden()
|
void Config::resetOverridden()
|
||||||
{
|
{
|
||||||
for (auto & s : _settings)
|
for (auto & s : _settings)
|
||||||
|
|
|
@ -82,12 +82,6 @@ public:
|
||||||
*/
|
*/
|
||||||
void applyConfig(const std::string & contents, const std::string & path = "<unknown>");
|
void applyConfig(const std::string & contents, const std::string & path = "<unknown>");
|
||||||
|
|
||||||
/**
|
|
||||||
* Applies a nix configuration file
|
|
||||||
* - path: the location of the config file to apply
|
|
||||||
*/
|
|
||||||
void applyConfigFile(const Path & path);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets the `overridden` flag of all Settings
|
* Resets the `overridden` flag of all Settings
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue