1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-17 16:02:43 +01:00

Merge pull request #10951 from obsidiansystems/load-just-one-config

Small global config refactors
This commit is contained in:
John Ericson 2024-06-24 12:38:04 -04:00 committed by GitHub
commit fda4c78921
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 130 additions and 98 deletions

View file

@ -3,6 +3,7 @@
# include "hook-instance.hh"
#endif
#include "processes.hh"
#include "config-global.hh"
#include "worker.hh"
#include "builtins.hh"
#include "builtins/buildenv.hh"

View file

@ -1,5 +1,6 @@
#include "filetransfer.hh"
#include "globals.hh"
#include "config-global.hh"
#include "store-api.hh"
#include "s3.hh"
#include "compression.hh"

View file

@ -1,4 +1,5 @@
#include "globals.hh"
#include "config-global.hh"
#include "current-process.hh"
#include "archive.hh"
#include "args.hh"
@ -123,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 &) { }
};
@ -136,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++) {
@ -145,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");
}
}
@ -437,7 +438,7 @@ void initLibStore(bool loadConfig) {
initLibUtil();
if (loadConfig)
loadConfFile();
loadConfFile(globalConfig);
preloadNSS();

View file

@ -1284,7 +1284,13 @@ extern Settings settings;
*/
void initPlugins();
void loadConfFile();
/**
* Load the configuration (from `nix.conf`, `NIX_CONFIG`, etc.) into the
* given configuration object.
*
* Usually called with `globalConfig`.
*/
void loadConfFile(AbstractConfig & config);
// Used by the Settings constructor
std::vector<Path> getUserConfigFiles();

View file

@ -1,4 +1,5 @@
#include "globals.hh"
#include "config-global.hh"
#include "hook-instance.hh"
#include "file-system.hh"
#include "child.hh"