mkOption
lib.options.mkOption
Docs pulled from | This Revision | 4 days ago
Creates an Option attribute set. mkOption accepts an attribute set with the following keys:
Inputs
- Structured attribute set
- Attribute set containing none or some of the following attributes.
default- Optional default value used when no definition is given in the configuration.
defaultText- Substitute for documenting the
default, if evaluating the default value during documentation rendering is not possible. - Can be any nix value that evaluates.
- Usage with
lib.literalMDorlib.literalExpressionis supported example- Optional example value used in the manual.
- Can be any nix value that evaluates.
- Usage with
lib.literalMDorlib.literalExpressionis supported description- Optional string describing the option. This is required if option documentation is generated.
relatedPackages- Optional related packages used in the manual (see
genRelatedPackagesin../nixos/lib/make-options-doc/default.nix). type- Optional option type, providing type-checking and value merging.
apply- Optional function that converts the option value to something else.
internal- Optional boolean indicating whether the option is for NixOS developers only.
visible- Optional, whether the option and/or sub-options show up in the manual. Use false to hide the option and any sub-options from submodules. Use "shallow" to hide only sub-options. Use "transparent" to hide this option, but not its sub-options. Default: true.
readOnly- Optional boolean indicating whether the option can be set only once.
...(any other attribute)- Any other attribute is passed through to the resulting option attribute set.
Examples
lib.options.mkOption usage example
mkOption { } // => { _type = "option"; }
mkOption { default = "foo"; } // => { _type = "option"; default = "foo"; }
Noogle detected
Implementation
The following is the current implementation of this function.
mkOption =
{
default ? null,
defaultText ? null,
example ? null,
description ? null,
relatedPackages ? null,
type ? null,
apply ? null,
internal ? null,
visible ? null,
readOnly ? null,
}@attrs:
attrs // { _type = "option"; };