Declaration: Difference between revisions
imported>Fadenb Created page with "NixOS module has declarations to provide an interface for other modules. Option declarations are used to make NixOS aware of configuration possibilities or to hide the comple..." |
imported>Evertras No edit summary |
||
| (4 intermediate revisions by 4 users not shown) | |||
| Line 1: | Line 1: | ||
NixOS module has declarations to provide an interface for other modules. Option declarations are used to make NixOS aware of configuration possibilities or to hide the complexity of configuration. Option declarations are used to provide an interface over the inherent complexity of configuring the system. | NixOS module has declarations to provide an interface for other modules. Option declarations are used to make NixOS aware of configuration possibilities or to hide the complexity of configuration. Option declarations are used to provide an interface over the inherent complexity of configuring the system. | ||
See also [ | See also [https://nixos.org/nixos/manual/index.html#sec-option-declarations the manual]. | ||
= Option attributes = | = Option attributes = | ||
| Line 42: | Line 42: | ||
with lib; | with lib; | ||
services.fooBar.option = mkOption { | services.fooBar.option = mkOption { | ||
type = with types; uniq | type = with types; uniq str; | ||
description = " | description = " | ||
... | ... | ||
| Line 53: | Line 53: | ||
== Simple Types == | == Simple Types == | ||
* <code> | * <code>anything</code>: Useful when it is used under a meta-type. | ||
* <code>bool</code>: A Boolean useful for enable flags. The merge function is a logical OR between all definitions. | * <code>bool</code>: A Boolean useful for enable flags. The merge function is a logical OR between all definitions. | ||
* <code>int</code>: An Integer. | * <code>int</code>: An Integer. | ||
* <code> | * <code>str</code>: A string where all definitions are concatenated. | ||
* <code>envVar</code>: A string where all definitions are concatenated with a colon between all definitions. | * <code>envVar</code>: A string where all definitions are concatenated with a colon between all definitions. | ||
* <code>attrs</code>: An attribute set. (you should prefer <code>attrsOf inferred</code>) | * <code>attrs</code>: An attribute set. (you should prefer <code>attrsOf inferred</code>) | ||
| Line 75: | Line 75: | ||
* <code>optionSet</code>: '''DEPRECATED, probably use submodule instead''' This type is used to benefit from the modular system used by NixOS inside an option. When this type is enabled, it merge the <code>options</code> attribute of option declarations with each definition. The result is the fixed configuration of each module. This option is often see in conjunction with <code>attrsOf</code> or <code>listOf</code>. Modules declared in option declaration appear in the generated manual with a prefix representing the container type, respectively "<code>.<name></code>" and "<code>.*</code>". Reference to definition files do not appears in the generated manual because the system cannot track them. | * <code>optionSet</code>: '''DEPRECATED, probably use submodule instead''' This type is used to benefit from the modular system used by NixOS inside an option. When this type is enabled, it merge the <code>options</code> attribute of option declarations with each definition. The result is the fixed configuration of each module. This option is often see in conjunction with <code>attrsOf</code> or <code>listOf</code>. Modules declared in option declaration appear in the generated manual with a prefix representing the container type, respectively "<code>.<name></code>" and "<code>.*</code>". Reference to definition files do not appears in the generated manual because the system cannot track them. | ||
[[Category:NixOS]] | |||