mirror of
https://github.com/NixOS/nix
synced 2025-07-06 21:41:48 +02:00
Allow loading config files into other config objects
This gives us some hope of moving away from global variables.
This commit is contained in:
parent
b46e13840b
commit
cb0c868da4
2 changed files with 12 additions and 6 deletions
|
@ -124,12 +124,12 @@ Settings::Settings()
|
|||
};
|
||||
}
|
||||
|
||||
void loadConfFile()
|
||||
void loadConfFile(AbstractConfig & config)
|
||||
{
|
||||
auto applyConfigFile = [&](const Path & path) {
|
||||
try {
|
||||
std::string contents = readFile(path);
|
||||
globalConfig.applyConfig(contents, path);
|
||||
config.applyConfig(contents, path);
|
||||
} catch (SystemError &) { }
|
||||
};
|
||||
|
||||
|
@ -137,7 +137,7 @@ void loadConfFile()
|
|||
|
||||
/* We only want to send overrides to the daemon, i.e. stuff from
|
||||
~/.nix/nix.conf or the command line. */
|
||||
globalConfig.resetOverridden();
|
||||
config.resetOverridden();
|
||||
|
||||
auto files = settings.nixUserConfFiles;
|
||||
for (auto file = files.rbegin(); file != files.rend(); file++) {
|
||||
|
@ -146,7 +146,7 @@ void loadConfFile()
|
|||
|
||||
auto nixConfEnv = getEnv("NIX_CONFIG");
|
||||
if (nixConfEnv.has_value()) {
|
||||
globalConfig.applyConfig(nixConfEnv.value(), "NIX_CONFIG");
|
||||
config.applyConfig(nixConfEnv.value(), "NIX_CONFIG");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -438,7 +438,7 @@ void initLibStore(bool loadConfig) {
|
|||
initLibUtil();
|
||||
|
||||
if (loadConfig)
|
||||
loadConfFile();
|
||||
loadConfFile(globalConfig);
|
||||
|
||||
preloadNSS();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue