diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2017-04-20T12·58+0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2017-04-20T12·58+0200 |
commit | f05d5f89ff4ec52ed2f6d576b2b2323b5292f815 (patch) | |
tree | 86912765d3dbe77b0e810ad3169dc364015fa71a /src/libutil/config.cc | |
parent | 562585e901d9e5f2ef62be11c2e74badcacb1f50 (diff) |
Read per-user settings from ~/.config/nix/nix.conf
Diffstat (limited to 'src/libutil/config.cc')
-rw-r--r-- | src/libutil/config.cc | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/libutil/config.cc b/src/libutil/config.cc index e7a810cec4d2..bf137299718f 100644 --- a/src/libutil/config.cc +++ b/src/libutil/config.cc @@ -9,6 +9,7 @@ void Config::set(const std::string & name, const std::string & value) if (i == _settings.end()) throw UsageError("unknown setting '%s'", name); i->second.setting->set(value); + i->second.setting->overriden = true; } void Config::addSetting(AbstractSetting * setting) @@ -22,6 +23,7 @@ void Config::addSetting(AbstractSetting * setting) auto i = initials.find(setting->name); if (i != initials.end()) { setting->set(i->second); + setting->overriden = true; initials.erase(i); set = true; } @@ -34,6 +36,7 @@ void Config::addSetting(AbstractSetting * setting) alias, setting->name); else { setting->set(i->second); + setting->overriden = true; initials.erase(i); set = true; } @@ -47,11 +50,11 @@ void Config::warnUnknownSettings() warn("unknown setting '%s'", i.first); } -StringMap Config::getSettings() +StringMap Config::getSettings(bool overridenOnly) { StringMap res; for (auto & opt : _settings) - if (!opt.second.isAlias) + if (!opt.second.isAlias && (!overridenOnly || opt.second.setting->overriden)) res.emplace(opt.first, opt.second.setting->to_string()); return res; } @@ -94,6 +97,12 @@ void Config::applyConfigFile(const Path & path, bool fatal) } catch (SysError &) { } } +void Config::resetOverriden() +{ + for (auto & s : _settings) + s.second.setting->overriden = false; +} + AbstractSetting::AbstractSetting( const std::string & name, const std::string & description, |