Merge pull request #2501 from mayflower/xdg_config_dirs
config: use all of XDG_CONFIG_DIRS
This commit is contained in:
commit
fb35aaa422
3 changed files with 17 additions and 1 deletions
|
@ -78,7 +78,11 @@ void loadConfFile()
|
||||||
~/.nix/nix.conf or the command line. */
|
~/.nix/nix.conf or the command line. */
|
||||||
globalConfig.resetOverriden();
|
globalConfig.resetOverriden();
|
||||||
|
|
||||||
globalConfig.applyConfigFile(getConfigDir() + "/nix/nix.conf");
|
auto dirs = getConfigDirs();
|
||||||
|
// Iterate over them in reverse so that the ones appearing first in the path take priority
|
||||||
|
for (auto dir = dirs.rbegin(); dir != dirs.rend(); dir++) {
|
||||||
|
globalConfig.applyConfigFile(*dir + "/nix/nix.conf");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int Settings::getDefaultCores()
|
unsigned int Settings::getDefaultCores()
|
||||||
|
|
|
@ -496,6 +496,15 @@ Path getConfigDir()
|
||||||
return configDir;
|
return configDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<Path> getConfigDirs()
|
||||||
|
{
|
||||||
|
Path configHome = getConfigDir();
|
||||||
|
string configDirs = getEnv("XDG_CONFIG_DIRS");
|
||||||
|
std::vector<Path> result = tokenizeString<std::vector<string>>(configDirs, ":");
|
||||||
|
result.insert(result.begin(), configHome);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Path getDataDir()
|
Path getDataDir()
|
||||||
{
|
{
|
||||||
|
|
|
@ -131,6 +131,9 @@ Path getCacheDir();
|
||||||
/* Return $XDG_CONFIG_HOME or $HOME/.config. */
|
/* Return $XDG_CONFIG_HOME or $HOME/.config. */
|
||||||
Path getConfigDir();
|
Path getConfigDir();
|
||||||
|
|
||||||
|
/* Return the directories to search for user configuration files */
|
||||||
|
std::vector<Path> getConfigDirs();
|
||||||
|
|
||||||
/* Return $XDG_DATA_HOME or $HOME/.local/share. */
|
/* Return $XDG_DATA_HOME or $HOME/.local/share. */
|
||||||
Path getDataDir();
|
Path getDataDir();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue