···
in case of multiple value definitions.
<section xml:id="sec-option-types-basic">
9
-
<title>Basic Types</title>
9
+
<title>Basic types</title>
Basic types are the simplest available types in the module system.
Basic types include multiple string types that mainly differ in
···
A top-level store path. This can be an attribute set
pointing to a store path, like a derivation or a flake
54
+
<literal>types.enum</literal>
55
+
<emphasis><literal>l</literal></emphasis>
59
+
One element of the list
60
+
<emphasis><literal>l</literal></emphasis>, e.g.
61
+
<literal>types.enum [ "left" "right" ]</literal>.
62
+
Multiple definitions cannot be merged.
···
154
-
Integer-related types:
159
-
<literal>types.int</literal>
169
-
<literal>types.ints.{s8, s16, s32}</literal>
173
-
Signed integers with a fixed length (8, 16 or 32 bits). They
174
-
go from −2^n/2 to 2^n/2−1 respectively (e.g.
175
-
<literal>−128</literal> to <literal>127</literal> for 8
182
-
<literal>types.ints.unsigned</literal>
186
-
An unsigned integer (that is >= 0).
192
-
<literal>types.ints.{u8, u16, u32}</literal>
196
-
Unsigned integers with a fixed length (8, 16 or 32 bits).
197
-
They go from 0 to 2^n−1 respectively (e.g.
198
-
<literal>0</literal> to <literal>255</literal> for 8 bits).
204
-
<literal>types.ints.positive</literal>
208
-
A positive integer (that is > 0).
214
-
<literal>types.port</literal>
218
-
A port number. This type is an alias to
219
-
<literal>types.ints.u16</literal>.
225
-
String-related types:
230
-
<literal>types.str</literal>
234
-
A string. Multiple definitions cannot be merged.
240
-
<literal>types.lines</literal>
244
-
A string. Multiple definitions are concatenated with a new
245
-
line <literal>"\n"</literal>.
251
-
<literal>types.commas</literal>
255
-
A string. Multiple definitions are concatenated with a comma
256
-
<literal>","</literal>.
262
-
<literal>types.envVar</literal>
266
-
A string. Multiple definitions are concatenated with a
267
-
collon <literal>":"</literal>.
273
-
<literal>types.strMatching</literal>
277
-
A string matching a specific regular expression. Multiple
278
-
definitions cannot be merged. The regular expression is
279
-
processed using <literal>builtins.match</literal>.
167
+
<section xml:id="sec-option-types-numeric">
168
+
<title>Numeric types</title>
172
+
<literal>types.int</literal>
182
+
<literal>types.ints.{s8, s16, s32}</literal>
186
+
Signed integers with a fixed length (8, 16 or 32 bits).
187
+
They go from −2^n/2 to 2^n/2−1 respectively (e.g.
188
+
<literal>−128</literal> to <literal>127</literal> for 8
195
+
<literal>types.ints.unsigned</literal>
199
+
An unsigned integer (that is >= 0).
205
+
<literal>types.ints.{u8, u16, u32}</literal>
209
+
Unsigned integers with a fixed length (8, 16 or 32 bits).
210
+
They go from 0 to 2^n−1 respectively (e.g.
211
+
<literal>0</literal> to <literal>255</literal> for 8
218
+
<literal>types.ints.between</literal>
219
+
<emphasis><literal>lowest highest</literal></emphasis>
224
+
<emphasis><literal>lowest</literal></emphasis> and
225
+
<emphasis><literal>highest</literal></emphasis> (both
232
+
<literal>types.ints.positive</literal>
236
+
A positive integer (that is > 0).
242
+
<literal>types.port</literal>
246
+
A port number. This type is an alias to
247
+
<literal>types.ints.u16</literal>.
253
+
<literal>types.float</literal>
257
+
A floating point number.
261
+
Converting a floating point number to a string with
262
+
<literal>toString</literal> or <literal>toJSON</literal>
264
+
<link xlink:href="https://github.com/NixOS/nix/issues/5733">precision
272
+
<literal>types.number</literal>
276
+
Either a signed integer or a floating point number. No
277
+
implicit conversion is done between the two types, and
278
+
multiple equal definitions will only be merged if they
279
+
have the same type.
285
+
<literal>types.numbers.between</literal>
286
+
<emphasis><literal>lowest highest</literal></emphasis>
290
+
An integer or floating point number between
291
+
<emphasis><literal>lowest</literal></emphasis> and
292
+
<emphasis><literal>highest</literal></emphasis> (both
299
+
<literal>types.numbers.nonnegative</literal>
303
+
A nonnegative integer or floating point number (that is
310
+
<literal>types.numbers.positive</literal>
314
+
A positive integer or floating point number (that is >
321
+
<section xml:id="sec-option-types-string">
322
+
<title>String types</title>
326
+
<literal>types.str</literal>
330
+
A string. Multiple definitions cannot be merged.
336
+
<literal>types.separatedString</literal>
337
+
<emphasis><literal>sep</literal></emphasis>
341
+
A string. Multiple definitions are concatenated with
342
+
<emphasis><literal>sep</literal></emphasis>, e.g.
343
+
<literal>types.separatedString "|"</literal>.
349
+
<literal>types.lines</literal>
353
+
A string. Multiple definitions are concatenated with a new
354
+
line <literal>"\n"</literal>.
360
+
<literal>types.commas</literal>
364
+
A string. Multiple definitions are concatenated with a
365
+
comma <literal>","</literal>.
371
+
<literal>types.envVar</literal>
375
+
A string. Multiple definitions are concatenated with a
376
+
colon <literal>":"</literal>.
382
+
<literal>types.strMatching</literal>
386
+
A string matching a specific regular expression. Multiple
387
+
definitions cannot be merged. The regular expression is
388
+
processed using <literal>builtins.match</literal>.
285
-
<section xml:id="sec-option-types-value">
286
-
<title>Value Types</title>
395
+
<section xml:id="sec-option-types-submodule">
396
+
<title>Submodule types</title>
288
-
Value types are types that take a value parameter.
398
+
Submodules are detailed in
399
+
<link linkend="section-option-types-submodule">Submodule</link>.
293
-
<literal>types.enum</literal>
294
-
<emphasis><literal>l</literal></emphasis>
298
-
One element of the list
299
-
<emphasis><literal>l</literal></emphasis>, e.g.
300
-
<literal>types.enum [ "left" "right" ]</literal>.
301
-
Multiple definitions cannot be merged.
307
-
<literal>types.separatedString</literal>
308
-
<emphasis><literal>sep</literal></emphasis>
312
-
A string with a custom separator
313
-
<emphasis><literal>sep</literal></emphasis>, e.g.
314
-
<literal>types.separatedString "|"</literal>.
320
-
<literal>types.ints.between</literal>
321
-
<emphasis><literal>lowest highest</literal></emphasis>
326
-
<emphasis><literal>lowest</literal></emphasis> and
327
-
<emphasis><literal>highest</literal></emphasis> (both
328
-
inclusive). Useful for creating types like
329
-
<literal>types.port</literal>.
<literal>types.submodule</literal>
<emphasis><literal>o</literal></emphasis>
···
in composed types to create modular options. This is
<literal>types.submoduleWith { modules = toList o; shorthandOnlyDefinesConfig = true; }</literal>.
348
-
Submodules are detailed in
349
-
<link linkend="section-option-types-submodule">Submodule</link>.
···
<section xml:id="sec-option-types-composed">
470
-
<title>Composed Types</title>
537
+
<title>Composed types</title>
Composed types are types that take a type as parameter.
<literal>listOf int</literal> and
···
<section xml:id="sec-option-types-custom">
853
-
<title>Custom Types</title>
920
+
<title>Custom types</title>
Custom types can be created with the
<literal>mkOptionType</literal> function. As type creation