Skip to content

Commit

Permalink
nixos/doc: clean up defaults and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ncfavier committed Oct 4, 2021
1 parent 330b1e0 commit 2ddc335
Show file tree
Hide file tree
Showing 584 changed files with 1,612 additions and 1,554 deletions.
10 changes: 10 additions & 0 deletions nixos/doc/manual/development/option-declarations.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,19 @@ The function `mkOption` accepts the following arguments.
of the module will have to define the value of the option, otherwise
an error will be thrown.

`defaultText`

: A textual representation of the default value to be rendered verbatim in
the manual. Useful if the default value is a complex expression or depends
on other values or packages.
Use `lib.literalExpression` for a Nix expression, `lib.literalDocBook` for
a plain English description in DocBook format.

`example`

: An example value that will be shown in the NixOS manual.
You can use `lib.literalExpression` and `lib.literalDocBook` in the same way
as in `defaultText`.

`description`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,31 @@ options = {
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<literal>defaultText</literal>
</term>
<listitem>
<para>
A textual representation of the default value to be rendered
verbatim in the manual. Useful if the default value is a
complex expression or depends on other values or packages. Use
<literal>lib.literalExpression</literal> for a Nix expression,
<literal>lib.literalDocBook</literal> for a plain English
description in DocBook format.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<literal>example</literal>
</term>
<listitem>
<para>
An example value that will be shown in the NixOS manual.
An example value that will be shown in the NixOS manual. You
can use <literal>lib.literalExpression</literal> and
<literal>lib.literalDocBook</literal> in the same way as in
<literal>defaultText</literal>.
</para>
</listitem>
</varlistentry>
Expand Down
2 changes: 1 addition & 1 deletion nixos/maintainers/scripts/ec2/amazon-image.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ in {
};

contents = mkOption {
example = literalExample ''
example = literalExpression ''
[ { source = pkgs.memtest86 + "/memtest.bin";
target = "boot/memtest.bin";
}
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/config/fonts/fonts.nix
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ in
fonts = mkOption {
type = types.listOf types.path;
default = [];
example = literalExample "[ pkgs.dejavu_fonts ]";
example = literalExpression "[ pkgs.dejavu_fonts ]";
description = "List of primary font paths.";
};

Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/config/i18n.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ with lib;
allLocales = any (x: x == "all") config.i18n.supportedLocales;
locales = config.i18n.supportedLocales;
};
example = literalExample "pkgs.glibcLocales";
example = literalExpression "pkgs.glibcLocales";
description = ''
Customized pkg.glibcLocales package.
Expand Down
16 changes: 8 additions & 8 deletions nixos/modules/config/krb5/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ in {
kerberos = mkOption {
type = types.package;
default = pkgs.krb5Full;
defaultText = "pkgs.krb5Full";
example = literalExample "pkgs.heimdal";
defaultText = literalExpression "pkgs.krb5Full";
example = literalExpression "pkgs.heimdal";
description = ''
The Kerberos implementation that will be present in
<literal>environment.systemPackages</literal> after enabling this
Expand All @@ -96,7 +96,7 @@ in {
type = with types; either attrs lines;
default = {};
apply = attrs: filterEmbeddedMetadata attrs;
example = literalExample ''
example = literalExpression ''
{
default_realm = "ATHENA.MIT.EDU";
};
Expand All @@ -109,7 +109,7 @@ in {
realms = mkOption {
type = with types; either attrs lines;
default = {};
example = literalExample ''
example = literalExpression ''
{
"ATHENA.MIT.EDU" = {
admin_server = "athena.mit.edu";
Expand All @@ -127,7 +127,7 @@ in {
domain_realm = mkOption {
type = with types; either attrs lines;
default = {};
example = literalExample ''
example = literalExpression ''
{
"example.com" = "EXAMPLE.COM";
".example.com" = "EXAMPLE.COM";
Expand All @@ -142,7 +142,7 @@ in {
capaths = mkOption {
type = with types; either attrs lines;
default = {};
example = literalExample ''
example = literalExpression ''
{
"ATHENA.MIT.EDU" = {
"EXAMPLE.COM" = ".";
Expand All @@ -161,7 +161,7 @@ in {
appdefaults = mkOption {
type = with types; either attrs lines;
default = {};
example = literalExample ''
example = literalExpression ''
{
pam = {
debug = false;
Expand All @@ -182,7 +182,7 @@ in {
plugins = mkOption {
type = with types; either attrs lines;
default = {};
example = literalExample ''
example = literalExpression ''
{
ccselect = {
disable = "k5identity";
Expand Down
6 changes: 3 additions & 3 deletions nixos/modules/config/networking.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ in

networking.hosts = lib.mkOption {
type = types.attrsOf (types.listOf types.str);
example = literalExample ''
example = literalExpression ''
{
"127.0.0.1" = [ "foo.bar.baz" ];
"192.168.0.2" = [ "fileserver.local" "nameserver.local" ];
Expand All @@ -34,8 +34,8 @@ in

networking.hostFiles = lib.mkOption {
type = types.listOf types.path;
defaultText = lib.literalExample "Hosts from `networking.hosts` and `networking.extraHosts`";
example = lib.literalExample ''[ "''${pkgs.my-blocklist-package}/share/my-blocklist/hosts" ]'';
defaultText = literalDocBook "Hosts from <option>networking.hosts</option> and <option>networking.extraHosts</option>";
example = literalExpression ''[ "''${pkgs.my-blocklist-package}/share/my-blocklist/hosts" ]'';
description = ''
Files that should be concatenated together to form <filename>/etc/hosts</filename>.
'';
Expand Down
4 changes: 2 additions & 2 deletions nixos/modules/config/power-management.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ in
powerUpCommands = mkOption {
type = types.lines;
default = "";
example = literalExample ''
example = literalExpression ''
"''${pkgs.hdparm}/sbin/hdparm -B 255 /dev/sda"
'';
description =
Expand All @@ -49,7 +49,7 @@ in
powerDownCommands = mkOption {
type = types.lines;
default = "";
example = literalExample ''
example = literalExpression ''
"''${pkgs.hdparm}/sbin/hdparm -B 255 /dev/sda"
'';
description =
Expand Down
10 changes: 5 additions & 5 deletions nixos/modules/config/pulseaudio.nix
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ in {
default = if config.services.jack.jackd.enable
then pkgs.pulseaudioFull
else pkgs.pulseaudio;
defaultText = "pkgs.pulseaudio";
example = literalExample "pkgs.pulseaudioFull";
defaultText = literalExpression "pkgs.pulseaudio";
example = literalExpression "pkgs.pulseaudioFull";
description = ''
The PulseAudio derivation to use. This can be used to enable
features (such as JACK support, Bluetooth) via the
Expand All @@ -161,7 +161,7 @@ in {
extraModules = mkOption {
type = types.listOf types.package;
default = [];
example = literalExample "[ pkgs.pulseaudio-modules-bt ]";
example = literalExpression "[ pkgs.pulseaudio-modules-bt ]";
description = ''
Extra pulseaudio modules to use. This is intended for out-of-tree
pulseaudio modules like extra bluetooth codecs.
Expand All @@ -184,7 +184,7 @@ in {
type = types.attrsOf types.unspecified;
default = {};
description = "Config of the pulse daemon. See <literal>man pulse-daemon.conf</literal>.";
example = literalExample ''{ realtime-scheduling = "yes"; }'';
example = literalExpression ''{ realtime-scheduling = "yes"; }'';
};
};

Expand All @@ -204,7 +204,7 @@ in {
allowedIpRanges = mkOption {
type = types.listOf types.str;
default = [];
example = literalExample ''[ "127.0.0.1" "192.168.1.0/24" ]'';
example = literalExpression ''[ "127.0.0.1" "192.168.1.0/24" ]'';
description = ''
A list of IP subnets that are allowed to stream to the server.
'';
Expand Down
8 changes: 3 additions & 5 deletions nixos/modules/config/shells-environment.nix
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,8 @@ in

environment.binsh = mkOption {
default = "${config.system.build.binsh}/bin/sh";
defaultText = "\${config.system.build.binsh}/bin/sh";
example = literalExample ''
"''${pkgs.dash}/bin/dash"
'';
defaultText = literalExpression ''"''${config.system.build.binsh}/bin/sh"'';
example = literalExpression ''"''${pkgs.dash}/bin/dash"'';
type = types.path;
visible = false;
description = ''
Expand All @@ -152,7 +150,7 @@ in

environment.shells = mkOption {
default = [];
example = literalExample "[ pkgs.bashInteractive pkgs.zsh ]";
example = literalExpression "[ pkgs.bashInteractive pkgs.zsh ]";
description = ''
A list of permissible login shells for user accounts.
No need to mention <literal>/bin/sh</literal>
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/config/sysctl.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ in

boot.kernel.sysctl = mkOption {
default = {};
example = literalExample ''
example = literalExpression ''
{ "net.ipv4.tcp_syncookies" = false; "vm.swappiness" = 60; }
'';
type = types.attrsOf sysctlOption;
Expand Down
6 changes: 3 additions & 3 deletions nixos/modules/config/system-path.nix
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ in
systemPackages = mkOption {
type = types.listOf types.package;
default = [];
example = literalExample "[ pkgs.firefox pkgs.thunderbird ]";
example = literalExpression "[ pkgs.firefox pkgs.thunderbird ]";
description = ''
The set of packages that appear in
/run/current-system/sw. These packages are
Expand All @@ -73,9 +73,9 @@ in
defaultPackages = mkOption {
type = types.listOf types.package;
default = defaultPackages;
example = literalExample "[]";
example = [];
description = ''
Set of default packages that aren't strictly neccessary
Set of default packages that aren't strictly necessary
for a running system, entries can be removed for a more
minimal NixOS installation.
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/config/unix-odbc-drivers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ in {
environment.unixODBCDrivers = mkOption {
type = types.listOf types.package;
default = [];
example = literalExample "with pkgs.unixODBCDrivers; [ sqlite psql ]";
example = literalExpression "with pkgs.unixODBCDrivers; [ sqlite psql ]";
description = ''
Specifies Unix ODBC drivers to be registered in
<filename>/etc/odbcinst.ini</filename>. You may also want to
Expand Down
6 changes: 3 additions & 3 deletions nixos/modules/config/users-groups.nix
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ let
shell = mkOption {
type = types.nullOr (types.either types.shellPackage (passwdEntry types.path));
default = pkgs.shadow;
defaultText = "pkgs.shadow";
example = literalExample "pkgs.bashInteractive";
defaultText = literalExpression "pkgs.shadow";
example = literalExpression "pkgs.bashInteractive";
description = ''
The path to the user's shell. Can use shell derivations,
like <literal>pkgs.bashInteractive</literal>. Don’t
Expand Down Expand Up @@ -291,7 +291,7 @@ let
packages = mkOption {
type = types.listOf types.package;
default = [];
example = literalExample "[ pkgs.firefox pkgs.thunderbird ]";
example = literalExpression "[ pkgs.firefox pkgs.thunderbird ]";
description = ''
The set of packages that should be made available to the user.
This is in contrast to <option>environment.systemPackages</option>,
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/config/xdg/portals/wlr.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ in
default = { };

# Example taken from the manpage
example = literalExample ''
example = literalExpression ''
{
screencast = {
output_name = "HDMI-A-1";
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/hardware/ckb-next.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ in
package = mkOption {
type = types.package;
default = pkgs.ckb-next;
defaultText = "pkgs.ckb-next";
defaultText = literalExpression "pkgs.ckb-next";
description = ''
The package implementing the Corsair keyboard/mouse driver.
'';
Expand Down
10 changes: 5 additions & 5 deletions nixos/modules/hardware/device-tree.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let
each .dtb file matching "compatible" of the overlay.
'';
default = null;
example = literalExample "./dts/overlays.dts";
example = literalExpression "./dts/overlays.dts";
};

dtsText = mkOption {
Expand All @@ -31,7 +31,7 @@ let
Literal DTS contents, overlay is applied to
each .dtb file matching "compatible" of the overlay.
'';
example = literalExample ''
example = ''
/dts-v1/;
/plugin/;
/ {
Expand Down Expand Up @@ -125,8 +125,8 @@ in

kernelPackage = mkOption {
default = config.boot.kernelPackages.kernel;
defaultText = "config.boot.kernelPackages.kernel";
example = literalExample "pkgs.linux_latest";
defaultText = literalExpression "config.boot.kernelPackages.kernel";
example = literalExpression "pkgs.linux_latest";
type = types.path;
description = ''
Kernel package containing the base device-tree (.dtb) to boot. Uses
Expand Down Expand Up @@ -156,7 +156,7 @@ in

overlays = mkOption {
default = [];
example = literalExample ''
example = literalExpression ''
[
{ name = "pps"; dtsFile = ./dts/pps.dts; }
{ name = "spi";
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/hardware/digitalbitbox.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ in
package = mkOption {
type = types.package;
default = pkgs.digitalbitbox;
defaultText = "pkgs.digitalbitbox";
defaultText = literalExpression "pkgs.digitalbitbox";
description = "The Digital Bitbox package to use. This can be used to install a package with udev rules that differ from the defaults.";
};
};
Expand Down
4 changes: 2 additions & 2 deletions nixos/modules/hardware/opengl.nix
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ in
extraPackages = mkOption {
type = types.listOf types.package;
default = [];
example = literalExample "with pkgs; [ vaapiIntel libvdpau-va-gl vaapiVdpau intel-ocl ]";
example = literalExpression "with pkgs; [ vaapiIntel libvdpau-va-gl vaapiVdpau intel-ocl ]";
description = ''
Additional packages to add to OpenGL drivers. This can be used
to add OpenCL drivers, VA-API/VDPAU drivers etc.
Expand All @@ -99,7 +99,7 @@ in
extraPackages32 = mkOption {
type = types.listOf types.package;
default = [];
example = literalExample "with pkgs.pkgsi686Linux; [ vaapiIntel libvdpau-va-gl vaapiVdpau ]";
example = literalExpression "with pkgs.pkgsi686Linux; [ vaapiIntel libvdpau-va-gl vaapiVdpau ]";
description = ''
Additional packages to add to 32-bit OpenGL drivers on
64-bit systems. Used when <option>driSupport32Bit</option> is
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/hardware/opentabletdriver.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ in
package = mkOption {
type = types.package;
default = pkgs.opentabletdriver;
defaultText = "pkgs.opentabletdriver";
defaultText = literalExpression "pkgs.opentabletdriver";
description = ''
OpenTabletDriver derivation to use.
'';
Expand Down
Loading

0 comments on commit 2ddc335

Please sign in to comment.