forked from lix-project/lix
Merge pull request #5702 from baloo/baloo/hide-non-reproducible-settings
reproducibility: hide non-reproducible settings from manual
This commit is contained in:
commit
6234e1c811
|
@ -8,17 +8,19 @@ concatStrings (map
|
||||||
let option = options.${name}; in
|
let option = options.${name}; in
|
||||||
" - `${name}` \n\n"
|
" - `${name}` \n\n"
|
||||||
+ concatStrings (map (s: " ${s}\n") (splitLines option.description)) + "\n\n"
|
+ concatStrings (map (s: " ${s}\n") (splitLines option.description)) + "\n\n"
|
||||||
+ " **Default:** " + (
|
+ (if option.documentDefault
|
||||||
if option.value == "" || option.value == []
|
then " **Default:** " + (
|
||||||
then "*empty*"
|
if option.value == "" || option.value == []
|
||||||
else if isBool option.value
|
then "*empty*"
|
||||||
then (if option.value then "`true`" else "`false`")
|
else if isBool option.value
|
||||||
else
|
then (if option.value then "`true`" else "`false`")
|
||||||
# n.b. a StringMap value type is specified as a string, but
|
else
|
||||||
# this shows the value type. The empty stringmap is "null" in
|
# n.b. a StringMap value type is specified as a string, but
|
||||||
# JSON, but that converts to "{ }" here.
|
# this shows the value type. The empty stringmap is "null" in
|
||||||
(if isAttrs option.value then "`\"\"`"
|
# JSON, but that converts to "{ }" here.
|
||||||
else "`" + toString option.value + "`")) + "\n\n"
|
(if isAttrs option.value then "`\"\"`"
|
||||||
|
else "`" + toString option.value + "`")) + "\n\n"
|
||||||
|
else " **Default:** *machine-specific*")
|
||||||
+ (if option.aliases != []
|
+ (if option.aliases != []
|
||||||
then " **Deprecated alias:** " + (concatStringsSep ", " (map (s: "`${s}`") option.aliases)) + "\n\n"
|
then " **Deprecated alias:** " + (concatStringsSep ", " (map (s: "`${s}`") option.aliases)) + "\n\n"
|
||||||
else "")
|
else "")
|
||||||
|
|
|
@ -21,7 +21,7 @@ struct MaxBuildJobsSetting : public BaseSetting<unsigned int>
|
||||||
const std::string & name,
|
const std::string & name,
|
||||||
const std::string & description,
|
const std::string & description,
|
||||||
const std::set<std::string> & aliases = {})
|
const std::set<std::string> & aliases = {})
|
||||||
: BaseSetting<unsigned int>(def, name, description, aliases)
|
: BaseSetting<unsigned int>(def, true, name, description, aliases)
|
||||||
{
|
{
|
||||||
options->addSetting(this);
|
options->addSetting(this);
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ struct PluginFilesSetting : public BaseSetting<Paths>
|
||||||
const std::string & name,
|
const std::string & name,
|
||||||
const std::string & description,
|
const std::string & description,
|
||||||
const std::set<std::string> & aliases = {})
|
const std::set<std::string> & aliases = {})
|
||||||
: BaseSetting<Paths>(def, name, description, aliases)
|
: BaseSetting<Paths>(def, true, name, description, aliases)
|
||||||
{
|
{
|
||||||
options->addSetting(this);
|
options->addSetting(this);
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,9 @@ public:
|
||||||
{"build-max-jobs"}};
|
{"build-max-jobs"}};
|
||||||
|
|
||||||
Setting<unsigned int> buildCores{
|
Setting<unsigned int> buildCores{
|
||||||
this, getDefaultCores(), "cores",
|
this,
|
||||||
|
getDefaultCores(),
|
||||||
|
"cores",
|
||||||
R"(
|
R"(
|
||||||
Sets the value of the `NIX_BUILD_CORES` environment variable in the
|
Sets the value of the `NIX_BUILD_CORES` environment variable in the
|
||||||
invocation of builders. Builders can use this variable at their
|
invocation of builders. Builders can use this variable at their
|
||||||
|
@ -141,7 +143,7 @@ public:
|
||||||
command line switch and defaults to `1`. The value `0` means that
|
command line switch and defaults to `1`. The value `0` means that
|
||||||
the builder should use all available CPU cores in the system.
|
the builder should use all available CPU cores in the system.
|
||||||
)",
|
)",
|
||||||
{"build-cores"}};
|
{"build-cores"}, false};
|
||||||
|
|
||||||
/* Read-only mode. Don't copy stuff to the store, don't change
|
/* Read-only mode. Don't copy stuff to the store, don't change
|
||||||
the database. */
|
the database. */
|
||||||
|
@ -583,10 +585,11 @@ public:
|
||||||
platform and generate incompatible code, so you may wish to
|
platform and generate incompatible code, so you may wish to
|
||||||
cross-check the results of using this option against proper
|
cross-check the results of using this option against proper
|
||||||
natively-built versions of your derivations.
|
natively-built versions of your derivations.
|
||||||
)"};
|
)", {}, false};
|
||||||
|
|
||||||
Setting<StringSet> systemFeatures{
|
Setting<StringSet> systemFeatures{
|
||||||
this, getDefaultSystemFeatures(),
|
this,
|
||||||
|
getDefaultSystemFeatures(),
|
||||||
"system-features",
|
"system-features",
|
||||||
R"(
|
R"(
|
||||||
A set of system “features” supported by this machine, e.g. `kvm`.
|
A set of system “features” supported by this machine, e.g. `kvm`.
|
||||||
|
@ -602,7 +605,7 @@ public:
|
||||||
This setting by default includes `kvm` if `/dev/kvm` is accessible,
|
This setting by default includes `kvm` if `/dev/kvm` is accessible,
|
||||||
and the pseudo-features `nixos-test`, `benchmark` and `big-parallel`
|
and the pseudo-features `nixos-test`, `benchmark` and `big-parallel`
|
||||||
that are used in Nixpkgs to route builds to specific machines.
|
that are used in Nixpkgs to route builds to specific machines.
|
||||||
)"};
|
)", {}, false};
|
||||||
|
|
||||||
Setting<Strings> substituters{
|
Setting<Strings> substituters{
|
||||||
this,
|
this,
|
||||||
|
|
|
@ -10,6 +10,7 @@ std::map<std::string, nlohmann::json> BaseSetting<T>::toJSONObject()
|
||||||
auto obj = AbstractSetting::toJSONObject();
|
auto obj = AbstractSetting::toJSONObject();
|
||||||
obj.emplace("value", value);
|
obj.emplace("value", value);
|
||||||
obj.emplace("defaultValue", defaultValue);
|
obj.emplace("defaultValue", defaultValue);
|
||||||
|
obj.emplace("documentDefault", documentDefault);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,16 +232,19 @@ protected:
|
||||||
|
|
||||||
T value;
|
T value;
|
||||||
const T defaultValue;
|
const T defaultValue;
|
||||||
|
const bool documentDefault;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
BaseSetting(const T & def,
|
BaseSetting(const T & def,
|
||||||
|
const bool documentDefault,
|
||||||
const std::string & name,
|
const std::string & name,
|
||||||
const std::string & description,
|
const std::string & description,
|
||||||
const std::set<std::string> & aliases = {})
|
const std::set<std::string> & aliases = {})
|
||||||
: AbstractSetting(name, description, aliases)
|
: AbstractSetting(name, description, aliases)
|
||||||
, value(def)
|
, value(def)
|
||||||
, defaultValue(def)
|
, defaultValue(def)
|
||||||
|
, documentDefault(documentDefault)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
operator const T &() const { return value; }
|
operator const T &() const { return value; }
|
||||||
|
@ -288,8 +291,9 @@ public:
|
||||||
const T & def,
|
const T & def,
|
||||||
const std::string & name,
|
const std::string & name,
|
||||||
const std::string & description,
|
const std::string & description,
|
||||||
const std::set<std::string> & aliases = {})
|
const std::set<std::string> & aliases = {},
|
||||||
: BaseSetting<T>(def, name, description, aliases)
|
const bool documentDefault = true)
|
||||||
|
: BaseSetting<T>(def, documentDefault, name, description, aliases)
|
||||||
{
|
{
|
||||||
options->addSetting(this);
|
options->addSetting(this);
|
||||||
}
|
}
|
||||||
|
@ -311,7 +315,7 @@ public:
|
||||||
const std::string & name,
|
const std::string & name,
|
||||||
const std::string & description,
|
const std::string & description,
|
||||||
const std::set<std::string> & aliases = {})
|
const std::set<std::string> & aliases = {})
|
||||||
: BaseSetting<Path>(def, name, description, aliases)
|
: BaseSetting<Path>(def, true, name, description, aliases)
|
||||||
, allowEmpty(allowEmpty)
|
, allowEmpty(allowEmpty)
|
||||||
{
|
{
|
||||||
options->addSetting(this);
|
options->addSetting(this);
|
||||||
|
|
|
@ -161,7 +161,7 @@ namespace nix {
|
||||||
Setting<std::string> setting{&config, "", "name-of-the-setting", "description"};
|
Setting<std::string> setting{&config, "", "name-of-the-setting", "description"};
|
||||||
setting.assign("value");
|
setting.assign("value");
|
||||||
|
|
||||||
ASSERT_EQ(config.toJSON().dump(), R"#({"name-of-the-setting":{"aliases":[],"defaultValue":"","description":"description\n","value":"value"}})#");
|
ASSERT_EQ(config.toJSON().dump(), R"#({"name-of-the-setting":{"aliases":[],"defaultValue":"","description":"description\n","documentDefault":true,"value":"value"}})#");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(Config, setSettingAlias) {
|
TEST(Config, setSettingAlias) {
|
||||||
|
|
Loading…
Reference in a new issue