2014-08-24 19:18:18 +02:00
|
|
|
|
<section xmlns="http://docbook.org/ns/docbook"
|
|
|
|
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
|
|
|
xmlns:xi="http://www.w3.org/2001/XInclude"
|
|
|
|
|
version="5.0"
|
|
|
|
|
xml:id="sec-option-declarations">
|
|
|
|
|
|
|
|
|
|
<title>Option Declarations</title>
|
|
|
|
|
|
|
|
|
|
<para>An option declaration specifies the name, type and description
|
2016-05-22 11:29:33 +02:00
|
|
|
|
of a NixOS configuration option. It is invalid to define an option
|
|
|
|
|
that hasn’t been declared in any module. An option declaration
|
2014-08-24 19:18:18 +02:00
|
|
|
|
generally looks like this:
|
|
|
|
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
options = {
|
|
|
|
|
<replaceable>name</replaceable> = mkOption {
|
|
|
|
|
type = <replaceable>type specification</replaceable>;
|
|
|
|
|
default = <replaceable>default value</replaceable>;
|
|
|
|
|
example = <replaceable>example value</replaceable>;
|
|
|
|
|
description = "<replaceable>Description for use in the NixOS manual.</replaceable>";
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
|
|
<para>The function <varname>mkOption</varname> accepts the following arguments.
|
|
|
|
|
|
|
|
|
|
<variablelist>
|
|
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
|
<term><varname>type</varname></term>
|
|
|
|
|
<listitem>
|
2016-09-13 07:04:02 +02:00
|
|
|
|
<para>The type of the option (see <xref linkend='sec-option-types' />).
|
|
|
|
|
It may be omitted, but that’s not advisable since it may lead to errors
|
|
|
|
|
that are hard to diagnose.</para>
|
2014-08-24 19:18:18 +02:00
|
|
|
|
</listitem>
|
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
|
<term><varname>default</varname></term>
|
|
|
|
|
<listitem>
|
|
|
|
|
<para>The default value used if no value is defined by any
|
|
|
|
|
module. A default is not required; in that case, if the option
|
2016-05-22 11:29:33 +02:00
|
|
|
|
value is never used, an error will be thrown.</para>
|
2014-08-24 19:18:18 +02:00
|
|
|
|
</listitem>
|
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
|
<term><varname>example</varname></term>
|
|
|
|
|
<listitem>
|
|
|
|
|
<para>An example value that will be shown in the NixOS manual.</para>
|
|
|
|
|
</listitem>
|
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
|
<term><varname>description</varname></term>
|
|
|
|
|
<listitem>
|
|
|
|
|
<para>A textual description of the option, in DocBook format,
|
|
|
|
|
that will be included in the NixOS manual.</para>
|
|
|
|
|
</listitem>
|
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
|
|
</variablelist>
|
|
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
2015-08-06 19:55:42 +02:00
|
|
|
|
</section>
|