forked from lix-project/lix
treewide: consistently mark overridden settings as such
Only overridden settings are sent to the daemon, and we're going to do the same
for the build hook to. It needs to be ensured that overridden settings are in
fact consistently marked as such, so that they actually get sent.
Change-Id: I7cd58d925702f86cf2c35ad121eb191ceb62a355
This commit is contained in:
parent
f6077314fa
commit
4dbbd721eb
|
@ -831,12 +831,12 @@ static void opServe(Strings opFlags, Strings opArgs)
|
||||||
// FIXME: changing options here doesn't work if we're
|
// FIXME: changing options here doesn't work if we're
|
||||||
// building through the daemon.
|
// building through the daemon.
|
||||||
verbosity = lvlError;
|
verbosity = lvlError;
|
||||||
settings.keepLog = false;
|
settings.keepLog.override(false);
|
||||||
settings.useSubstitutes = false;
|
settings.useSubstitutes.override(false);
|
||||||
settings.maxSilentTime = readInt(in);
|
settings.maxSilentTime.override(readInt(in));
|
||||||
settings.buildTimeout = readInt(in);
|
settings.buildTimeout.override(readInt(in));
|
||||||
if (GET_PROTOCOL_MINOR(clientVersion) >= 2)
|
if (GET_PROTOCOL_MINOR(clientVersion) >= 2)
|
||||||
settings.maxLogSize = readNum<unsigned long>(in);
|
settings.maxLogSize.override(readNum<unsigned long>(in));
|
||||||
if (GET_PROTOCOL_MINOR(clientVersion) >= 3) {
|
if (GET_PROTOCOL_MINOR(clientVersion) >= 3) {
|
||||||
auto nrRepeats = readInt(in);
|
auto nrRepeats = readInt(in);
|
||||||
if (nrRepeats != 0) {
|
if (nrRepeats != 0) {
|
||||||
|
@ -850,10 +850,10 @@ static void opServe(Strings opFlags, Strings opArgs)
|
||||||
// asked for.
|
// asked for.
|
||||||
readInt(in);
|
readInt(in);
|
||||||
|
|
||||||
settings.runDiffHook = true;
|
settings.runDiffHook.override(true);
|
||||||
}
|
}
|
||||||
if (GET_PROTOCOL_MINOR(clientVersion) >= 7) {
|
if (GET_PROTOCOL_MINOR(clientVersion) >= 7) {
|
||||||
settings.keepFailed = (bool) readInt(in);
|
settings.keepFailed.override((bool) readInt(in));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -137,7 +137,7 @@ MixEvalArgs::MixEvalArgs()
|
||||||
.description = "Allow access to mutable paths and repositories.",
|
.description = "Allow access to mutable paths and repositories.",
|
||||||
.category = category,
|
.category = category,
|
||||||
.handler = {[&]() {
|
.handler = {[&]() {
|
||||||
evalSettings.pureEval = false;
|
evalSettings.pureEval.override(false);
|
||||||
}},
|
}},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -212,7 +212,7 @@ void SourceExprCommand::completeInstallable(AddCompletions & completions, std::s
|
||||||
if (file) {
|
if (file) {
|
||||||
completions.setType(AddCompletions::Type::Attrs);
|
completions.setType(AddCompletions::Type::Attrs);
|
||||||
|
|
||||||
evalSettings.pureEval = false;
|
evalSettings.pureEval.override(false);
|
||||||
auto state = getEvalState();
|
auto state = getEvalState();
|
||||||
Expr & e = state->parseExprFromFile(
|
Expr & e = state->parseExprFromFile(
|
||||||
resolveExprPath(state->checkSourcePath(lookupFileArg(*state, *file)))
|
resolveExprPath(state->checkSourcePath(lookupFileArg(*state, *file)))
|
||||||
|
@ -435,7 +435,7 @@ Installables SourceExprCommand::parseInstallables(
|
||||||
throw UsageError("'--file' and '--expr' are exclusive");
|
throw UsageError("'--file' and '--expr' are exclusive");
|
||||||
|
|
||||||
// FIXME: backward compatibility hack
|
// FIXME: backward compatibility hack
|
||||||
if (file) evalSettings.pureEval = false;
|
if (file) evalSettings.pureEval.override(false);
|
||||||
|
|
||||||
auto state = getEvalState();
|
auto state = getEvalState();
|
||||||
auto vFile = state->allocValue();
|
auto vFile = state->allocValue();
|
||||||
|
|
|
@ -817,10 +817,10 @@ ProcessLineResult NixRepl::processLine(std::string line)
|
||||||
else if (command == ":te" || command == ":trace-enable") {
|
else if (command == ":te" || command == ":trace-enable") {
|
||||||
if (arg == "false" || (arg == "" && loggerSettings.showTrace)) {
|
if (arg == "false" || (arg == "" && loggerSettings.showTrace)) {
|
||||||
std::cout << "not showing error traces\n";
|
std::cout << "not showing error traces\n";
|
||||||
loggerSettings.showTrace = false;
|
loggerSettings.showTrace.override(false);
|
||||||
} else if (arg == "true" || (arg == "" && !loggerSettings.showTrace)) {
|
} else if (arg == "true" || (arg == "" && !loggerSettings.showTrace)) {
|
||||||
std::cout << "showing error traces\n";
|
std::cout << "showing error traces\n";
|
||||||
loggerSettings.showTrace = true;
|
loggerSettings.showTrace.override(true);
|
||||||
} else {
|
} else {
|
||||||
throw Error("unexpected argument '%s' to %s", arg, command);
|
throw Error("unexpected argument '%s' to %s", arg, command);
|
||||||
};
|
};
|
||||||
|
|
|
@ -47,7 +47,7 @@ static Strings parseNixPath(const std::string & s)
|
||||||
EvalSettings::EvalSettings()
|
EvalSettings::EvalSettings()
|
||||||
{
|
{
|
||||||
auto var = getEnv("NIX_PATH");
|
auto var = getEnv("NIX_PATH");
|
||||||
if (var) nixPath = parseNixPath(*var);
|
if (var) nixPath.setDefault(parseNixPath(*var));
|
||||||
}
|
}
|
||||||
|
|
||||||
Strings EvalSettings::getDefaultNixPath()
|
Strings EvalSettings::getDefaultNixPath()
|
||||||
|
|
|
@ -196,20 +196,20 @@ LegacyArgs::LegacyArgs(const std::string & programName,
|
||||||
.longName = "keep-failed",
|
.longName = "keep-failed",
|
||||||
.shortName ='K',
|
.shortName ='K',
|
||||||
.description = "Keep temporary directories of failed builds.",
|
.description = "Keep temporary directories of failed builds.",
|
||||||
.handler = {&(bool&) settings.keepFailed, true},
|
.handler = {[&]() { settings.keepFailed.override(true); }},
|
||||||
});
|
});
|
||||||
|
|
||||||
addFlag({
|
addFlag({
|
||||||
.longName = "keep-going",
|
.longName = "keep-going",
|
||||||
.shortName ='k',
|
.shortName ='k',
|
||||||
.description = "Keep going after a build fails.",
|
.description = "Keep going after a build fails.",
|
||||||
.handler = {&(bool&) settings.keepGoing, true},
|
.handler = {[&]() { settings.keepGoing.override(true); }},
|
||||||
});
|
});
|
||||||
|
|
||||||
addFlag({
|
addFlag({
|
||||||
.longName = "fallback",
|
.longName = "fallback",
|
||||||
.description = "Build from source if substitution fails.",
|
.description = "Build from source if substitution fails.",
|
||||||
.handler = {&(bool&) settings.tryFallback, true},
|
.handler = {[&]() { settings.tryFallback.override(true); }},
|
||||||
});
|
});
|
||||||
|
|
||||||
auto intSettingAlias = [&](char shortName, const std::string & longName,
|
auto intSettingAlias = [&](char shortName, const std::string & longName,
|
||||||
|
@ -247,7 +247,7 @@ LegacyArgs::LegacyArgs(const std::string & programName,
|
||||||
.longName = "store",
|
.longName = "store",
|
||||||
.description = "The URL of the Nix store to use.",
|
.description = "The URL of the Nix store to use.",
|
||||||
.labels = {"store-uri"},
|
.labels = {"store-uri"},
|
||||||
.handler = {&(std::string&) settings.storeUri},
|
.handler = {[&](std::string storeUri) { settings.storeUri.override(storeUri); }},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,11 +13,11 @@ void builtinFetchurl(const BasicDerivation & drv, const std::string & netrcData,
|
||||||
this to be stored in a file. It would be nice if we could just
|
this to be stored in a file. It would be nice if we could just
|
||||||
pass a pointer to the data. */
|
pass a pointer to the data. */
|
||||||
if (netrcData != "") {
|
if (netrcData != "") {
|
||||||
settings.netrcFile = "netrc";
|
settings.netrcFile.override("netrc");
|
||||||
writeFile(settings.netrcFile, netrcData, 0600);
|
writeFile(settings.netrcFile, netrcData, 0600);
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.caFile = "ca-certificates.crt";
|
settings.caFile.override("ca-certificates.crt");
|
||||||
writeFile(settings.caFile, caFileData, 0600);
|
writeFile(settings.caFile, caFileData, 0600);
|
||||||
|
|
||||||
auto getAttr = [&](const std::string & name) {
|
auto getAttr = [&](const std::string & name) {
|
||||||
|
|
|
@ -195,15 +195,15 @@ struct ClientSettings
|
||||||
|
|
||||||
void apply(TrustedFlag trusted)
|
void apply(TrustedFlag trusted)
|
||||||
{
|
{
|
||||||
settings.keepFailed = keepFailed;
|
settings.keepFailed.override(keepFailed);
|
||||||
settings.keepGoing = keepGoing;
|
settings.keepGoing.override(keepGoing);
|
||||||
settings.tryFallback = tryFallback;
|
settings.tryFallback.override(tryFallback);
|
||||||
nix::verbosity = verbosity;
|
nix::verbosity = verbosity;
|
||||||
settings.maxBuildJobs.assign(maxBuildJobs);
|
settings.maxBuildJobs.override(maxBuildJobs);
|
||||||
settings.maxSilentTime = maxSilentTime;
|
settings.maxSilentTime.override(maxSilentTime);
|
||||||
settings.verboseBuild = verboseBuild;
|
settings.verboseBuild = verboseBuild;
|
||||||
settings.buildCores = buildCores;
|
settings.buildCores.override(buildCores);
|
||||||
settings.useSubstitutes = useSubstitutes;
|
settings.useSubstitutes.override(useSubstitutes);
|
||||||
|
|
||||||
for (auto & i : overrides) {
|
for (auto & i : overrides) {
|
||||||
auto & name(i.first);
|
auto & name(i.first);
|
||||||
|
@ -225,12 +225,13 @@ struct ClientSettings
|
||||||
else
|
else
|
||||||
warn("ignoring untrusted substituter '%s', you are not a trusted user.\n"
|
warn("ignoring untrusted substituter '%s', you are not a trusted user.\n"
|
||||||
"Run `man nix.conf` for more information on the `substituters` configuration option.", s);
|
"Run `man nix.conf` for more information on the `substituters` configuration option.", s);
|
||||||
res = subs;
|
res.override(subs);
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (name == "ssh-auth-sock") // obsolete
|
if (name == "ssh-auth-sock" // obsolete
|
||||||
|
|| name == "store") // the daemon *is* the store
|
||||||
;
|
;
|
||||||
else if (name == experimentalFeatureSettings.experimentalFeatures.name) {
|
else if (name == experimentalFeatureSettings.experimentalFeatures.name) {
|
||||||
// We don’t want to forward the experimental features to
|
// We don’t want to forward the experimental features to
|
||||||
|
|
|
@ -69,12 +69,12 @@ Settings::Settings()
|
||||||
, nixManDir(canonPath(NIX_MAN_DIR))
|
, nixManDir(canonPath(NIX_MAN_DIR))
|
||||||
, nixDaemonSocketFile(canonPath(getEnvNonEmpty("NIX_DAEMON_SOCKET_PATH").value_or(nixStateDir + DEFAULT_SOCKET_PATH)))
|
, nixDaemonSocketFile(canonPath(getEnvNonEmpty("NIX_DAEMON_SOCKET_PATH").value_or(nixStateDir + DEFAULT_SOCKET_PATH)))
|
||||||
{
|
{
|
||||||
buildUsersGroup = getuid() == 0 ? "nixbld" : "";
|
buildUsersGroup.setDefault(getuid() == 0 ? "nixbld" : "");
|
||||||
allowSymlinkedStore = getEnv("NIX_IGNORE_SYMLINK_STORE") == "1";
|
allowSymlinkedStore.setDefault(getEnv("NIX_IGNORE_SYMLINK_STORE") == "1");
|
||||||
|
|
||||||
auto sslOverride = getEnv("NIX_SSL_CERT_FILE").value_or(getEnv("SSL_CERT_FILE").value_or(""));
|
auto sslOverride = getEnv("NIX_SSL_CERT_FILE").value_or(getEnv("SSL_CERT_FILE").value_or(""));
|
||||||
if (sslOverride != "")
|
if (sslOverride != "")
|
||||||
caFile = sslOverride;
|
caFile.setDefault(sslOverride);
|
||||||
|
|
||||||
/* Backwards compatibility. */
|
/* Backwards compatibility. */
|
||||||
auto s = getEnv("NIX_REMOTE_SYSTEMS");
|
auto s = getEnv("NIX_REMOTE_SYSTEMS");
|
||||||
|
@ -82,17 +82,17 @@ Settings::Settings()
|
||||||
Strings ss;
|
Strings ss;
|
||||||
for (auto & p : tokenizeString<Strings>(*s, ":"))
|
for (auto & p : tokenizeString<Strings>(*s, ":"))
|
||||||
ss.push_back("@" + p);
|
ss.push_back("@" + p);
|
||||||
builders = concatStringsSep(" ", ss);
|
builders.setDefault(concatStringsSep(" ", ss));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__linux__) && defined(SANDBOX_SHELL)
|
#if defined(__linux__) && defined(SANDBOX_SHELL)
|
||||||
sandboxPaths = tokenizeString<StringSet>("/bin/sh=" SANDBOX_SHELL);
|
sandboxPaths.setDefault(tokenizeString<StringSet>("/bin/sh=" SANDBOX_SHELL));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* chroot-like behavior from Apple's sandbox */
|
/* chroot-like behavior from Apple's sandbox */
|
||||||
#if __APPLE__
|
#if __APPLE__
|
||||||
sandboxPaths = tokenizeString<StringSet>("/System/Library/Frameworks /System/Library/PrivateFrameworks /bin/sh /bin/bash /private/tmp /private/var/tmp /usr/lib");
|
sandboxPaths.setDefault(tokenizeString<StringSet>("/System/Library/Frameworks /System/Library/PrivateFrameworks /bin/sh /bin/bash /private/tmp /private/var/tmp /usr/lib"));
|
||||||
allowedImpureHostPrefixes = tokenizeString<StringSet>("/System/Library /usr/lib /dev /bin/sh");
|
allowedImpureHostPrefixes.setDefault(tokenizeString<StringSet>("/System/Library /usr/lib /dev /bin/sh"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Set the build hook location
|
/* Set the build hook location
|
||||||
|
@ -118,10 +118,10 @@ Settings::Settings()
|
||||||
if (!pathExists(nixExePath)) {
|
if (!pathExists(nixExePath)) {
|
||||||
nixExePath = getSelfExe().value_or("nix");
|
nixExePath = getSelfExe().value_or("nix");
|
||||||
}
|
}
|
||||||
buildHook = {
|
buildHook.setDefault(Strings {
|
||||||
nixExePath,
|
nixExePath,
|
||||||
"__build-remote",
|
"__build-remote",
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadConfFile()
|
void loadConfFile()
|
||||||
|
|
|
@ -139,6 +139,7 @@ void RemoteStore::setOptions(Connection & conn)
|
||||||
overrides.erase(loggerSettings.showTrace.name);
|
overrides.erase(loggerSettings.showTrace.name);
|
||||||
overrides.erase(experimentalFeatureSettings.experimentalFeatures.name);
|
overrides.erase(experimentalFeatureSettings.experimentalFeatures.name);
|
||||||
overrides.erase(settings.pluginFiles.name);
|
overrides.erase(settings.pluginFiles.name);
|
||||||
|
overrides.erase(settings.storeUri.name); // the daemon *is* the store
|
||||||
conn.to << overrides.size();
|
conn.to << overrides.size();
|
||||||
for (auto & i : overrides)
|
for (auto & i : overrides)
|
||||||
conn.to << i.first << i.second.value;
|
conn.to << i.first << i.second.value;
|
||||||
|
|
|
@ -65,6 +65,7 @@ void BaseSetting<T>::appendOrSet(T newValue, bool append, const ApplyConfigOptio
|
||||||
"using default `appendOrSet` implementation with an appendable type");
|
"using default `appendOrSet` implementation with an appendable type");
|
||||||
assert(!append);
|
assert(!append);
|
||||||
|
|
||||||
|
overridden = true;
|
||||||
value = std::move(newValue);
|
value = std::move(newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,6 +86,13 @@ void BaseSetting<T>::set(const std::string & str, bool append, const ApplyConfig
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void BaseSetting<T>::override(const T & v)
|
||||||
|
{
|
||||||
|
overridden = true;
|
||||||
|
value = v;
|
||||||
|
}
|
||||||
|
|
||||||
template<> void BaseSetting<bool>::convertToArg(Args & args, const std::string & category);
|
template<> void BaseSetting<bool>::convertToArg(Args & args, const std::string & category);
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -95,7 +103,7 @@ void BaseSetting<T>::convertToArg(Args & args, const std::string & category)
|
||||||
.description = fmt("Set the `%s` setting.", name),
|
.description = fmt("Set the `%s` setting.", name),
|
||||||
.category = category,
|
.category = category,
|
||||||
.labels = {"value"},
|
.labels = {"value"},
|
||||||
.handler = {[this](std::string s) { overridden = true; set(s); }},
|
.handler = {[this](std::string s) { set(s); }},
|
||||||
.experimentalFeature = experimentalFeature,
|
.experimentalFeature = experimentalFeature,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -105,7 +113,7 @@ void BaseSetting<T>::convertToArg(Args & args, const std::string & category)
|
||||||
.description = fmt("Append to the `%s` setting.", name),
|
.description = fmt("Append to the `%s` setting.", name),
|
||||||
.category = category,
|
.category = category,
|
||||||
.labels = {"value"},
|
.labels = {"value"},
|
||||||
.handler = {[this](std::string s) { overridden = true; set(s, true); }},
|
.handler = {[this](std::string s) { set(s, true); }},
|
||||||
.experimentalFeature = experimentalFeature,
|
.experimentalFeature = experimentalFeature,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,6 @@ bool Config::set(const std::string & name, const std::string & value, const Appl
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
i->second.setting->set(value, append, options);
|
i->second.setting->set(value, append, options);
|
||||||
i->second.setting->overridden = true;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +45,6 @@ void Config::addSetting(AbstractSetting * setting)
|
||||||
|
|
||||||
if (auto i = unknownSettings.find(setting->name); i != unknownSettings.end()) {
|
if (auto i = unknownSettings.find(setting->name); i != unknownSettings.end()) {
|
||||||
setting->set(std::move(i->second));
|
setting->set(std::move(i->second));
|
||||||
setting->overridden = true;
|
|
||||||
unknownSettings.erase(i);
|
unknownSettings.erase(i);
|
||||||
set = true;
|
set = true;
|
||||||
}
|
}
|
||||||
|
@ -58,7 +56,6 @@ void Config::addSetting(AbstractSetting * setting)
|
||||||
alias, setting->name);
|
alias, setting->name);
|
||||||
else {
|
else {
|
||||||
setting->set(std::move(i->second));
|
setting->set(std::move(i->second));
|
||||||
setting->overridden = true;
|
|
||||||
unknownSettings.erase(i);
|
unknownSettings.erase(i);
|
||||||
set = true;
|
set = true;
|
||||||
}
|
}
|
||||||
|
@ -80,7 +77,7 @@ void AbstractConfig::reapplyUnknownSettings()
|
||||||
{
|
{
|
||||||
auto unknownSettings2 = std::move(unknownSettings);
|
auto unknownSettings2 = std::move(unknownSettings);
|
||||||
unknownSettings = {};
|
unknownSettings = {};
|
||||||
for (auto & s : unknownSettings2)
|
for (auto & s : unknownSettings2)
|
||||||
set(s.first, s.second);
|
set(s.first, s.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -218,6 +218,7 @@ protected:
|
||||||
virtual void convertToArg(Args & args, const std::string & category);
|
virtual void convertToArg(Args & args, const std::string & category);
|
||||||
|
|
||||||
bool isOverridden() const;
|
bool isOverridden() const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -267,16 +268,12 @@ public:
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
operator const T &() const { return value; }
|
operator const T &() const { return value; }
|
||||||
operator T &() { return value; }
|
|
||||||
const T & get() const { return value; }
|
const T & get() const { return value; }
|
||||||
template<typename U>
|
template<typename U>
|
||||||
bool operator ==(const U & v2) const { return value == v2; }
|
bool operator ==(const U & v2) const { return value == v2; }
|
||||||
template<typename U>
|
template<typename U>
|
||||||
bool operator !=(const U & v2) const { return value != v2; }
|
bool operator !=(const U & v2) const { return value != v2; }
|
||||||
template<typename U>
|
template<typename U>
|
||||||
void operator =(const U & v) { assign(v); }
|
|
||||||
virtual void assign(const T & v) { value = v; }
|
|
||||||
template<typename U>
|
|
||||||
void setDefault(const U & v) { if (!overridden) value = v; }
|
void setDefault(const U & v) { if (!overridden) value = v; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -287,6 +284,8 @@ public:
|
||||||
*/
|
*/
|
||||||
void set(const std::string & str, bool append = false, const ApplyConfigOptions & options = {}) override final;
|
void set(const std::string & str, bool append = false, const ApplyConfigOptions & options = {}) override final;
|
||||||
|
|
||||||
|
void override(const T & v);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* C++ trick; This is template-specialized to compile-time indicate whether
|
* C++ trick; This is template-specialized to compile-time indicate whether
|
||||||
* the type is appendable.
|
* the type is appendable.
|
||||||
|
@ -299,12 +298,6 @@ public:
|
||||||
*/
|
*/
|
||||||
bool isAppendable() override final;
|
bool isAppendable() override final;
|
||||||
|
|
||||||
virtual void override(const T & v)
|
|
||||||
{
|
|
||||||
overridden = true;
|
|
||||||
value = v;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string to_string() const override;
|
std::string to_string() const override;
|
||||||
|
|
||||||
void convertToArg(Args & args, const std::string & category) override;
|
void convertToArg(Args & args, const std::string & category) override;
|
||||||
|
@ -349,8 +342,6 @@ public:
|
||||||
: Setting(options, def, name, description, aliases, documentDefault, std::move(experimentalFeature), true)
|
: Setting(options, def, name, description, aliases, documentDefault, std::move(experimentalFeature), true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator =(const T & v) { this->assign(v); }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -375,8 +366,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
T parse(const std::string & str, const ApplyConfigOptions & options) const override;
|
T parse(const std::string & str, const ApplyConfigOptions & options) const override;
|
||||||
|
|
||||||
void operator =(const T & v) { this->assign(v); }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,7 @@ public:
|
||||||
|
|
||||||
void run(nix::ref<nix::Store> store) override
|
void run(nix::ref<nix::Store> store) override
|
||||||
{
|
{
|
||||||
settings.tarballTtl = 0;
|
settings.tarballTtl.override(0);
|
||||||
auto updateAll = lockFlags.inputUpdates.empty();
|
auto updateAll = lockFlags.inputUpdates.empty();
|
||||||
|
|
||||||
lockFlags.recreateLockFile = updateAll;
|
lockFlags.recreateLockFile = updateAll;
|
||||||
|
@ -158,7 +158,7 @@ struct CmdFlakeLock : FlakeCommand
|
||||||
|
|
||||||
void run(nix::ref<nix::Store> store) override
|
void run(nix::ref<nix::Store> store) override
|
||||||
{
|
{
|
||||||
settings.tarballTtl = 0;
|
settings.tarballTtl.override(0);
|
||||||
|
|
||||||
lockFlags.writeLockFile = true;
|
lockFlags.writeLockFile = true;
|
||||||
lockFlags.applyNixConfig = true;
|
lockFlags.applyNixConfig = true;
|
||||||
|
|
|
@ -247,8 +247,8 @@ static void showHelp(std::vector<std::string> subcommand, NixArgs & toplevel)
|
||||||
{
|
{
|
||||||
auto mdName = subcommand.empty() ? "nix" : fmt("nix3-%s", concatStringsSep("-", subcommand));
|
auto mdName = subcommand.empty() ? "nix" : fmt("nix3-%s", concatStringsSep("-", subcommand));
|
||||||
|
|
||||||
evalSettings.restrictEval = false;
|
evalSettings.restrictEval.override(false);
|
||||||
evalSettings.pureEval = false;
|
evalSettings.pureEval.override(false);
|
||||||
EvalState state({}, openStore("dummy://"));
|
EvalState state({}, openStore("dummy://"));
|
||||||
|
|
||||||
auto vGenerateManpage = state.allocValue();
|
auto vGenerateManpage = state.allocValue();
|
||||||
|
@ -389,7 +389,7 @@ void mainWrapped(int argc, char * * argv)
|
||||||
if (legacy) return legacy(argc, argv);
|
if (legacy) return legacy(argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
evalSettings.pureEval = true;
|
evalSettings.pureEval.setDefault(true);
|
||||||
|
|
||||||
setLogFormat(LogFormat::bar);
|
setLogFormat(LogFormat::bar);
|
||||||
settings.verboseBuild = false;
|
settings.verboseBuild = false;
|
||||||
|
@ -408,11 +408,11 @@ void mainWrapped(int argc, char * * argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc == 2 && std::string(argv[1]) == "__dump-language") {
|
if (argc == 2 && std::string(argv[1]) == "__dump-language") {
|
||||||
experimentalFeatureSettings.experimentalFeatures = ExperimentalFeatures{}
|
experimentalFeatureSettings.experimentalFeatures.override(ExperimentalFeatures{}
|
||||||
| Xp::Flakes
|
| Xp::Flakes
|
||||||
| Xp::FetchClosure
|
| Xp::FetchClosure
|
||||||
| Xp::DynamicDerivations;
|
| Xp::DynamicDerivations);
|
||||||
evalSettings.pureEval = false;
|
evalSettings.pureEval.override(false);
|
||||||
EvalState state({}, openStore("dummy://"));
|
EvalState state({}, openStore("dummy://"));
|
||||||
auto res = nlohmann::json::object();
|
auto res = nlohmann::json::object();
|
||||||
res["builtins"] = ({
|
res["builtins"] = ({
|
||||||
|
@ -513,24 +513,20 @@ void mainWrapped(int argc, char * * argv)
|
||||||
|
|
||||||
if (!args.useNet) {
|
if (!args.useNet) {
|
||||||
// FIXME: should check for command line overrides only.
|
// FIXME: should check for command line overrides only.
|
||||||
if (!settings.useSubstitutes.overridden)
|
settings.useSubstitutes.setDefault(false);
|
||||||
settings.useSubstitutes = false;
|
settings.tarballTtl.setDefault(std::numeric_limits<unsigned int>::max());
|
||||||
if (!settings.tarballTtl.overridden)
|
fileTransferSettings.tries.setDefault(0);
|
||||||
settings.tarballTtl = std::numeric_limits<unsigned int>::max();
|
fileTransferSettings.connectTimeout.setDefault(1);
|
||||||
if (!fileTransferSettings.tries.overridden)
|
|
||||||
fileTransferSettings.tries = 0;
|
|
||||||
if (!fileTransferSettings.connectTimeout.overridden)
|
|
||||||
fileTransferSettings.connectTimeout = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.refresh) {
|
if (args.refresh) {
|
||||||
settings.tarballTtl = 0;
|
settings.tarballTtl.override(0);
|
||||||
settings.ttlNegativeNarInfoCache = 0;
|
settings.ttlNegativeNarInfoCache.override(0);
|
||||||
settings.ttlPositiveNarInfoCache = 0;
|
settings.ttlPositiveNarInfoCache.override(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.command->second->forceImpureByDefault() && !evalSettings.pureEval.overridden) {
|
if (args.command->second->forceImpureByDefault()) {
|
||||||
evalSettings.pureEval = false;
|
evalSettings.pureEval.setDefault(false);
|
||||||
}
|
}
|
||||||
args.command->second->run();
|
args.command->second->run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace nix {
|
||||||
struct CmdRepl : RawInstallablesCommand
|
struct CmdRepl : RawInstallablesCommand
|
||||||
{
|
{
|
||||||
CmdRepl() {
|
CmdRepl() {
|
||||||
evalSettings.pureEval = false;
|
evalSettings.pureEval.override(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -72,7 +72,7 @@ struct CmdUpgradeNix : MixDryRun, EvalCommand
|
||||||
|
|
||||||
void run(ref<Store> store) override
|
void run(ref<Store> store) override
|
||||||
{
|
{
|
||||||
evalSettings.pureEval = true;
|
evalSettings.pureEval.override(true);
|
||||||
|
|
||||||
if (profileDir == "") {
|
if (profileDir == "") {
|
||||||
profileDir = getProfileDir(store);
|
profileDir = getProfileDir(store);
|
||||||
|
|
|
@ -24,20 +24,20 @@ using nix::settings;
|
||||||
|
|
||||||
class Environment : public ::testing::Environment {
|
class Environment : public ::testing::Environment {
|
||||||
public:
|
public:
|
||||||
void SetUp() override { settings.thisSystem = "TEST_ARCH-TEST_OS"; }
|
void SetUp() override { settings.thisSystem.override("TEST_ARCH-TEST_OS"); }
|
||||||
};
|
};
|
||||||
|
|
||||||
testing::Environment* const foo_env =
|
testing::Environment* const foo_env =
|
||||||
testing::AddGlobalTestEnvironment(new Environment);
|
testing::AddGlobalTestEnvironment(new Environment);
|
||||||
|
|
||||||
TEST(machines, getMachinesWithEmptyBuilders) {
|
TEST(machines, getMachinesWithEmptyBuilders) {
|
||||||
settings.builders = "";
|
settings.builders.override("");
|
||||||
Machines actual = getMachines();
|
Machines actual = getMachines();
|
||||||
ASSERT_THAT(actual, SizeIs(0));
|
ASSERT_THAT(actual, SizeIs(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(machines, getMachinesUriOnly) {
|
TEST(machines, getMachinesUriOnly) {
|
||||||
settings.builders = "nix@scratchy.labs.cs.uu.nl";
|
settings.builders.override("nix@scratchy.labs.cs.uu.nl");
|
||||||
Machines actual = getMachines();
|
Machines actual = getMachines();
|
||||||
ASSERT_THAT(actual, SizeIs(1));
|
ASSERT_THAT(actual, SizeIs(1));
|
||||||
EXPECT_THAT(actual[0], Field(&Machine::storeUri, Eq("ssh://nix@scratchy.labs.cs.uu.nl")));
|
EXPECT_THAT(actual[0], Field(&Machine::storeUri, Eq("ssh://nix@scratchy.labs.cs.uu.nl")));
|
||||||
|
@ -51,7 +51,7 @@ TEST(machines, getMachinesUriOnly) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(machines, getMachinesDefaults) {
|
TEST(machines, getMachinesDefaults) {
|
||||||
settings.builders = "nix@scratchy.labs.cs.uu.nl - - - - - - -";
|
settings.builders.override("nix@scratchy.labs.cs.uu.nl - - - - - - -");
|
||||||
Machines actual = getMachines();
|
Machines actual = getMachines();
|
||||||
ASSERT_THAT(actual, SizeIs(1));
|
ASSERT_THAT(actual, SizeIs(1));
|
||||||
EXPECT_THAT(actual[0], Field(&Machine::storeUri, Eq("ssh://nix@scratchy.labs.cs.uu.nl")));
|
EXPECT_THAT(actual[0], Field(&Machine::storeUri, Eq("ssh://nix@scratchy.labs.cs.uu.nl")));
|
||||||
|
@ -65,7 +65,7 @@ TEST(machines, getMachinesDefaults) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(machines, getMachinesWithNewLineSeparator) {
|
TEST(machines, getMachinesWithNewLineSeparator) {
|
||||||
settings.builders = "nix@scratchy.labs.cs.uu.nl\nnix@itchy.labs.cs.uu.nl";
|
settings.builders.override("nix@scratchy.labs.cs.uu.nl\nnix@itchy.labs.cs.uu.nl");
|
||||||
Machines actual = getMachines();
|
Machines actual = getMachines();
|
||||||
ASSERT_THAT(actual, SizeIs(2));
|
ASSERT_THAT(actual, SizeIs(2));
|
||||||
EXPECT_THAT(actual, Contains(Field(&Machine::storeUri, EndsWith("nix@scratchy.labs.cs.uu.nl"))));
|
EXPECT_THAT(actual, Contains(Field(&Machine::storeUri, EndsWith("nix@scratchy.labs.cs.uu.nl"))));
|
||||||
|
@ -73,7 +73,7 @@ TEST(machines, getMachinesWithNewLineSeparator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(machines, getMachinesWithSemicolonSeparator) {
|
TEST(machines, getMachinesWithSemicolonSeparator) {
|
||||||
settings.builders = "nix@scratchy.labs.cs.uu.nl ; nix@itchy.labs.cs.uu.nl";
|
settings.builders.override("nix@scratchy.labs.cs.uu.nl ; nix@itchy.labs.cs.uu.nl");
|
||||||
Machines actual = getMachines();
|
Machines actual = getMachines();
|
||||||
EXPECT_THAT(actual, SizeIs(2));
|
EXPECT_THAT(actual, SizeIs(2));
|
||||||
EXPECT_THAT(actual, Contains(Field(&Machine::storeUri, EndsWith("nix@scratchy.labs.cs.uu.nl"))));
|
EXPECT_THAT(actual, Contains(Field(&Machine::storeUri, EndsWith("nix@scratchy.labs.cs.uu.nl"))));
|
||||||
|
@ -81,9 +81,9 @@ TEST(machines, getMachinesWithSemicolonSeparator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(machines, getMachinesWithCorrectCompleteSingleBuilder) {
|
TEST(machines, getMachinesWithCorrectCompleteSingleBuilder) {
|
||||||
settings.builders = "nix@scratchy.labs.cs.uu.nl i686-linux "
|
settings.builders.override("nix@scratchy.labs.cs.uu.nl i686-linux "
|
||||||
"/home/nix/.ssh/id_scratchy_auto 8 3 kvm "
|
"/home/nix/.ssh/id_scratchy_auto 8 3 kvm "
|
||||||
"benchmark SSH+HOST+PUBLIC+KEY+BASE64+ENCODED==";
|
"benchmark SSH+HOST+PUBLIC+KEY+BASE64+ENCODED==");
|
||||||
Machines actual = getMachines();
|
Machines actual = getMachines();
|
||||||
ASSERT_THAT(actual, SizeIs(1));
|
ASSERT_THAT(actual, SizeIs(1));
|
||||||
EXPECT_THAT(actual[0], Field(&Machine::storeUri, EndsWith("nix@scratchy.labs.cs.uu.nl")));
|
EXPECT_THAT(actual[0], Field(&Machine::storeUri, EndsWith("nix@scratchy.labs.cs.uu.nl")));
|
||||||
|
@ -98,10 +98,10 @@ TEST(machines, getMachinesWithCorrectCompleteSingleBuilder) {
|
||||||
|
|
||||||
TEST(machines,
|
TEST(machines,
|
||||||
getMachinesWithCorrectCompleteSingleBuilderWithTabColumnDelimiter) {
|
getMachinesWithCorrectCompleteSingleBuilderWithTabColumnDelimiter) {
|
||||||
settings.builders =
|
settings.builders.override(
|
||||||
"nix@scratchy.labs.cs.uu.nl\ti686-linux\t/home/nix/.ssh/"
|
"nix@scratchy.labs.cs.uu.nl\ti686-linux\t/home/nix/.ssh/"
|
||||||
"id_scratchy_auto\t8\t3\tkvm\tbenchmark\tSSH+HOST+PUBLIC+"
|
"id_scratchy_auto\t8\t3\tkvm\tbenchmark\tSSH+HOST+PUBLIC+"
|
||||||
"KEY+BASE64+ENCODED==";
|
"KEY+BASE64+ENCODED==");
|
||||||
Machines actual = getMachines();
|
Machines actual = getMachines();
|
||||||
ASSERT_THAT(actual, SizeIs(1));
|
ASSERT_THAT(actual, SizeIs(1));
|
||||||
EXPECT_THAT(actual[0], Field(&Machine::storeUri, EndsWith("nix@scratchy.labs.cs.uu.nl")));
|
EXPECT_THAT(actual[0], Field(&Machine::storeUri, EndsWith("nix@scratchy.labs.cs.uu.nl")));
|
||||||
|
@ -115,9 +115,9 @@ TEST(machines,
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(machines, getMachinesWithMultiOptions) {
|
TEST(machines, getMachinesWithMultiOptions) {
|
||||||
settings.builders = "nix@scratchy.labs.cs.uu.nl Arch1,Arch2 - - - "
|
settings.builders.override("nix@scratchy.labs.cs.uu.nl Arch1,Arch2 - - - "
|
||||||
"SupportedFeature1,SupportedFeature2 "
|
"SupportedFeature1,SupportedFeature2 "
|
||||||
"MandatoryFeature1,MandatoryFeature2";
|
"MandatoryFeature1,MandatoryFeature2");
|
||||||
Machines actual = getMachines();
|
Machines actual = getMachines();
|
||||||
ASSERT_THAT(actual, SizeIs(1));
|
ASSERT_THAT(actual, SizeIs(1));
|
||||||
EXPECT_THAT(actual[0], Field(&Machine::storeUri, EndsWith("nix@scratchy.labs.cs.uu.nl")));
|
EXPECT_THAT(actual[0], Field(&Machine::storeUri, EndsWith("nix@scratchy.labs.cs.uu.nl")));
|
||||||
|
@ -127,15 +127,15 @@ TEST(machines, getMachinesWithMultiOptions) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(machines, getMachinesWithIncorrectFormat) {
|
TEST(machines, getMachinesWithIncorrectFormat) {
|
||||||
settings.builders = "nix@scratchy.labs.cs.uu.nl - - eight";
|
settings.builders.override("nix@scratchy.labs.cs.uu.nl - - eight");
|
||||||
EXPECT_THROW(getMachines(), FormatError);
|
EXPECT_THROW(getMachines(), FormatError);
|
||||||
settings.builders = "nix@scratchy.labs.cs.uu.nl - - -1";
|
settings.builders.override("nix@scratchy.labs.cs.uu.nl - - -1");
|
||||||
EXPECT_THROW(getMachines(), FormatError);
|
EXPECT_THROW(getMachines(), FormatError);
|
||||||
settings.builders = "nix@scratchy.labs.cs.uu.nl - - 8 three";
|
settings.builders.override("nix@scratchy.labs.cs.uu.nl - - 8 three");
|
||||||
EXPECT_THROW(getMachines(), FormatError);
|
EXPECT_THROW(getMachines(), FormatError);
|
||||||
settings.builders = "nix@scratchy.labs.cs.uu.nl - - 8 -3";
|
settings.builders.override("nix@scratchy.labs.cs.uu.nl - - 8 -3");
|
||||||
EXPECT_THROW(getMachines(), UsageError);
|
EXPECT_THROW(getMachines(), UsageError);
|
||||||
settings.builders = "nix@scratchy.labs.cs.uu.nl - - 8 3 - - BAD_BASE64";
|
settings.builders.override("nix@scratchy.labs.cs.uu.nl - - 8 3 - - BAD_BASE64");
|
||||||
EXPECT_THROW(getMachines(), FormatError);
|
EXPECT_THROW(getMachines(), FormatError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ TEST(machines, getMachinesWithCorrectFileReference) {
|
||||||
auto path = nix::getUnitTestDataPath("machines.valid");
|
auto path = nix::getUnitTestDataPath("machines.valid");
|
||||||
ASSERT_TRUE(pathExists(path));
|
ASSERT_TRUE(pathExists(path));
|
||||||
|
|
||||||
settings.builders = std::string("@") + path;
|
settings.builders.override(std::string("@") + path);
|
||||||
Machines actual = getMachines();
|
Machines actual = getMachines();
|
||||||
ASSERT_THAT(actual, SizeIs(3));
|
ASSERT_THAT(actual, SizeIs(3));
|
||||||
EXPECT_THAT(actual, Contains(Field(&Machine::storeUri, EndsWith("nix@scratchy.labs.cs.uu.nl"))));
|
EXPECT_THAT(actual, Contains(Field(&Machine::storeUri, EndsWith("nix@scratchy.labs.cs.uu.nl"))));
|
||||||
|
@ -155,18 +155,18 @@ TEST(machines, getMachinesWithCorrectFileReferenceToEmptyFile) {
|
||||||
auto path = "/dev/null";
|
auto path = "/dev/null";
|
||||||
ASSERT_TRUE(pathExists(path));
|
ASSERT_TRUE(pathExists(path));
|
||||||
|
|
||||||
settings.builders = std::string("@") + path;
|
settings.builders.override(std::string("@") + path);
|
||||||
Machines actual = getMachines();
|
Machines actual = getMachines();
|
||||||
ASSERT_THAT(actual, SizeIs(0));
|
ASSERT_THAT(actual, SizeIs(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(machines, getMachinesWithIncorrectFileReference) {
|
TEST(machines, getMachinesWithIncorrectFileReference) {
|
||||||
settings.builders = std::string("@") + absPath("/not/a/file");
|
settings.builders.override(std::string("@") + absPath("/not/a/file"));
|
||||||
Machines actual = getMachines();
|
Machines actual = getMachines();
|
||||||
ASSERT_THAT(actual, SizeIs(0));
|
ASSERT_THAT(actual, SizeIs(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(machines, getMachinesWithCorrectFileReferenceToIncorrectFile) {
|
TEST(machines, getMachinesWithCorrectFileReferenceToIncorrectFile) {
|
||||||
settings.builders = std::string("@") + nix::getUnitTestDataPath("machines.bad_format");
|
settings.builders.override(std::string("@") + nix::getUnitTestDataPath("machines.bad_format"));
|
||||||
EXPECT_THROW(getMachines(), FormatError);
|
EXPECT_THROW(getMachines(), FormatError);
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ namespace nix {
|
||||||
std::map<std::string, Config::SettingInfo> settings;
|
std::map<std::string, Config::SettingInfo> settings;
|
||||||
Setting<std::string> setting{&config, value, "name-of-the-setting", "description"};
|
Setting<std::string> setting{&config, value, "name-of-the-setting", "description"};
|
||||||
|
|
||||||
setting.assign("value");
|
setting.override("value");
|
||||||
|
|
||||||
config.getSettings(settings, /* overriddenOnly = */ false);
|
config.getSettings(settings, /* overriddenOnly = */ false);
|
||||||
const auto iter = settings.find("name-of-the-setting");
|
const auto iter = settings.find("name-of-the-setting");
|
||||||
|
@ -131,7 +131,7 @@ namespace nix {
|
||||||
{
|
{
|
||||||
std::map<std::string, Config::SettingInfo> settings;
|
std::map<std::string, Config::SettingInfo> settings;
|
||||||
|
|
||||||
setting.set("foo");
|
setting.setDefault("foo");
|
||||||
ASSERT_EQ(setting.get(), "foo");
|
ASSERT_EQ(setting.get(), "foo");
|
||||||
config.getSettings(settings, /* overriddenOnly = */ true);
|
config.getSettings(settings, /* overriddenOnly = */ true);
|
||||||
ASSERT_TRUE(settings.empty());
|
ASSERT_TRUE(settings.empty());
|
||||||
|
@ -170,7 +170,7 @@ namespace nix {
|
||||||
"name-of-the-setting",
|
"name-of-the-setting",
|
||||||
"description",
|
"description",
|
||||||
};
|
};
|
||||||
setting.assign("value");
|
setting.override("value");
|
||||||
|
|
||||||
ASSERT_EQ(config.toJSON(),
|
ASSERT_EQ(config.toJSON(),
|
||||||
R"#({
|
R"#({
|
||||||
|
@ -197,7 +197,7 @@ namespace nix {
|
||||||
true,
|
true,
|
||||||
Xp::Flakes,
|
Xp::Flakes,
|
||||||
};
|
};
|
||||||
setting.assign("value");
|
setting.override("value");
|
||||||
|
|
||||||
ASSERT_EQ(config.toJSON(),
|
ASSERT_EQ(config.toJSON(),
|
||||||
R"#({
|
R"#({
|
||||||
|
|
Loading…
Reference in a new issue