Read per-user settings from ~/.config/nix/nix.conf

This commit is contained in:
Eelco Dolstra 2017-04-20 14:58:16 +02:00
parent 562585e901
commit f05d5f89ff
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
8 changed files with 70 additions and 24 deletions

View file

@ -53,19 +53,19 @@ Settings::Settings()
void Settings::loadConfFile()
{
applyConfigFile(nixConfDir + "/nix.conf");
/* We only want to send overrides to the daemon, i.e. stuff from
~/.nix/nix.conf or the command line. */
resetOverriden();
applyConfigFile(getConfigDir() + "/nix/nix.conf");
}
void Settings::set(const string & name, const string & value)
{
overrides[name] = value;
Config::set(name, value);
}
StringMap Settings::getOverrides()
{
return overrides;
}
unsigned int Settings::getDefaultCores()
{
return std::max(1U, std::thread::hardware_concurrency());

View file

@ -15,8 +15,6 @@ extern bool useCaseHack; // FIXME
class Settings : public Config {
StringMap overrides;
unsigned int getDefaultCores();
public:
@ -27,8 +25,6 @@ public:
void set(const string & name, const string & value);
StringMap getOverrides();
Path nixPrefix;
/* The directory where we store sources and derived files. */

View file

@ -166,7 +166,7 @@ void RemoteStore::setOptions(Connection & conn)
<< settings.useSubstitutes;
if (GET_PROTOCOL_MINOR(conn.daemonVersion) >= 12) {
StringMap overrides = settings.getOverrides();
auto overrides = settings.getSettings(true);
conn.to << overrides.size();
for (auto & i : overrides)
conn.to << i.first << i.second;