treewide: add literalDocBook text to options with complex defaults

some options have default that are best described in prose, such as
defaults that depend on the system stateVersion, defaults that are
derivations specific to the surrounding context, or those where the
expression is much longer and harder to understand than a simple text
snippet.
This commit is contained in:
pennae 2021-12-05 22:06:49 +01:00
parent 6eaf4f90c2
commit 2d564521c0
20 changed files with 90 additions and 5 deletions

View file

@ -71,6 +71,7 @@ in
type = types.nullOr (types.enum pkgs.pinentry.flavors);
example = "gnome3";
default = defaultPinentryFlavor;
defaultText = literalDocBook ''matching the configured desktop environment'';
description = ''
Which pinentry interface to use. If not null, the path to the
pinentry binary will be passed to gpg-agent via commandline and

View file

@ -128,6 +128,10 @@ in {
mpdCfg.credentials).passwordFile
else
null;
defaultText = literalDocBook ''
The first password file with read access configured for MPD when using a local instance,
otherwise <literal>null</literal>.
'';
type = types.nullOr types.str;
description = ''
File containing the password for the mpd daemon.

View file

@ -1,4 +1,4 @@
{ config, pkgs, lib, ... }:
{ config, options, pkgs, lib, ... }:
with lib;
@ -23,6 +23,10 @@ in {
take 3 (splitString "." config.services.kubernetes.apiserver.serviceClusterIpRange
))
) + ".254";
defaultText = literalDocBook ''
The <literal>x.y.z.254</literal> IP of
<literal>config.${options.services.kubernetes.apiserver.serviceClusterIpRange}</literal>.
'';
type = types.str;
};

View file

@ -36,6 +36,7 @@ let
key = mkOption {
description = "Key of taint.";
default = name;
defaultText = literalDocBook "Name of this submodule.";
type = str;
};
value = mkOption {

View file

@ -281,6 +281,10 @@ in
type = types.path;
internal = true;
default = etcSlurm;
defaultText = literalDocBook ''
Directory created from generated config files and
<literal>config.${opt.extraConfigPaths}</literal>.
'';
description = ''
Path to directory with slurm config files. This option is set by default from the
Slurm module and is meant to make the Slurm config file available to other modules.

View file

@ -71,6 +71,7 @@ in {
baseq3 = mkOption {
type = types.either types.package types.path;
default = defaultBaseq3;
defaultText = literalDocBook "Manually downloaded Quake 3 installation directory.";
example = "/var/lib/q3ds";
description = ''
Path to the baseq3 files (pak*.pk3). If this is on the nix store (type = package) all .pk3 files should be saved

View file

@ -47,6 +47,7 @@ in
$highlight_bin = "${pkgs.highlight}/bin/highlight";
${cfg.extraConfig}
'';
defaultText = literalDocBook "generated config file";
type = types.path;
readOnly = true;
internal = true;

View file

@ -403,6 +403,29 @@ in {
database = cfg.database_name;
};
}.${cfg.database_type};
defaultText = literalDocBook ''
<variablelist>
<varlistentry>
<term>using sqlite3</term>
<listitem>
<programlisting>
{ database = "''${config.${opt.dataDir}}/homeserver.db"; }
</programlisting>
</listitem>
</varlistentry>
<varlistentry>
<term>using psycopg2</term>
<listitem>
<programlisting>
psycopg2 = {
user = config.${opt.database_user};
database = config.${opt.database_name};
}
</programlisting>
</listitem>
</varlistentry>
</variablelist>
'';
description = ''
Arguments to pass to the engine.
'';

View file

@ -401,6 +401,7 @@ in
config = mkOption {
internal = true;
default = pkgs.writeText "rippled.conf" rippledCfg;
defaultText = literalDocBook "generated config file";
};
};
};

View file

@ -83,6 +83,9 @@ let
mkArgumentsOption = cmd: mkOption {
type = types.listOf types.str;
default = argumentsOf cmd;
defaultText = literalDocBook ''
calculated from <literal>config.services.thanos.${cmd}</literal>
'';
description = ''
Arguments to the <literal>thanos ${cmd}</literal> command.

View file

@ -421,6 +421,7 @@ in
checkReversePath = mkOption {
type = types.either types.bool (types.enum ["strict" "loose"]);
default = kernelHasRPFilter;
defaultText = literalDocBook "<literal>true</literal> if supported by the chosen kernel";
example = "loose";
description =
''

View file

@ -1,9 +1,10 @@
{ config, lib, pkgs, ... }:
{ config, lib, options, pkgs, ... }:
with lib;
let
cfg = config.services.syncthing;
opt = options.services.syncthing;
defaultUser = "syncthing";
defaultGroup = defaultUser;
@ -431,7 +432,26 @@ in {
The path where the settings and keys will exist.
'';
default = cfg.dataDir + optionalString cond "/.config/syncthing";
defaultText = literalExpression "dataDir${optionalString cond " + \"/.config/syncthing\""}";
defaultText = literalDocBook ''
<variablelist>
<varlistentry>
<term><literal>stateVersion >= 19.03</literal></term>
<listitem>
<programlisting>
config.${opt.dataDir} + "/.config/syncthing"
</programlisting>
</listitem>
</varlistentry>
<varlistentry>
<term>otherwise</term>
<listitem>
<programlisting>
config.${opt.dataDir}
</programlisting>
</listitem>
</varlistentry>
</variablelist>
'';
};
extraFlags = mkOption {

View file

@ -140,6 +140,7 @@ in
lib.mkOption {
type = lib.types.port;
default = dbPorts.${cfg.database.type};
defaultText = lib.literalDocBook "default port of selected database";
description = ''
Port of the database to connect to.
'';

View file

@ -499,6 +499,7 @@ in {
occ = mkOption {
type = types.package;
default = occ;
defaultText = literalDocBook "generated script";
internal = true;
description = ''
The nextcloud-occ program preconfigured to target this Nextcloud instance.

View file

@ -1,9 +1,10 @@
{ config, lib, pkgs, ... }:
{ config, lib, options, pkgs, ... }:
with lib;
let
cfg = config.services.lighttpd.collectd;
opt = options.services.lighttpd.collectd;
collectionConf = pkgs.writeText "collection.conf" ''
datadir: "${config.services.collectd.dataDir}"
@ -29,6 +30,9 @@ in
collectionCgi = mkOption {
type = types.path;
default = defaultCollectionCgi;
defaultText = literalDocBook ''
<literal>config.${options.services.collectd.package}</literal> configured for lighttpd
'';
description = ''
Path to collection.cgi script from (collectd sources)/contrib/collection.cgi
This option allows to use a customized version

View file

@ -279,6 +279,9 @@ in
defaultSessionFromLegacyOptions
else
null;
defaultText = literalDocBook ''
Taken from display manager settings or window manager settings, if either is set.
'';
example = "gnome";
description = ''
Graphical session to pre-select in the session chooser (only effective for GDM, LightDM and SDDM).

View file

@ -142,6 +142,7 @@ in
readOnly = true;
internal = true;
default = systemActivationScript (removeAttrs config.system.activationScripts [ "script" ]) true;
defaultText = literalDocBook "generated activation script";
};
system.userActivationScripts = mkOption {

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }:
{ config, lib, options, pkgs, ... }:
with lib;
@ -7,6 +7,7 @@ let
inherit (pkgs) plymouth nixos-icons;
cfg = config.boot.plymouth;
opt = options.boot.plymouth;
nixosBreezePlymouth = pkgs.plasma5Packages.breeze-plymouth.override {
logoFile = cfg.logo;
@ -71,6 +72,11 @@ in
themePackages = mkOption {
default = lib.optional (cfg.theme == "breeze") nixosBreezePlymouth;
defaultText = literalDocBook ''
A NixOS branded variant of the breeze theme when
<literal>config.${opt.theme} == "breeze"</literal>, otherwise
<literal>[ ]</literal>.
'';
type = types.listOf types.package;
description = ''
Extra theme packages for plymouth.

View file

@ -112,6 +112,7 @@ in
readOnly = true;
type = types.bool;
default = inInitrd || inSystem;
defaultText = literalDocBook "<literal>true</literal> if ZFS filesystem support is enabled";
description = "True if ZFS filesystem support is enabled";
};

View file

@ -71,6 +71,10 @@ in
package = mkOption {
type = types.package;
default = crioPackage;
defaultText = literalDocBook ''
<literal>pkgs.cri-o</literal> built with
<literal>config.${opt.extraPackages}</literal>.
'';
internal = true;
description = ''
The final CRI-O package (including extra packages).