Strictly check the arguments to mkOption
And fix various instances of bad arguments.
This commit is contained in:
@@ -11,17 +11,18 @@ with import ./strings.nix;
|
||||
rec {
|
||||
|
||||
isOption = lib.isType "option";
|
||||
mkOption = attrs: attrs // {
|
||||
_type = "option";
|
||||
# name (this is the name of the attributem it is automatically generated by the traversal)
|
||||
# default (value used when no definition exists)
|
||||
# example (documentation)
|
||||
# description (documentation)
|
||||
# type (option type, provide a default merge function and ensure type correctness)
|
||||
# merge (function used to merge definitions into one definition: [ /type/ ] -> /type/)
|
||||
# apply (convert the option value to ease the manipulation of the option result)
|
||||
# options (set of sub-options declarations & definitions)
|
||||
};
|
||||
mkOption =
|
||||
{ default ? null # Default value used when no definition is given in the configuration.
|
||||
, defaultText ? null # Textual representation of the default, for in the manual.
|
||||
, example ? null # Example value used in the manual.
|
||||
, description ? null # String describing the option.
|
||||
, type ? null # Option type, providing type-checking and value merging.
|
||||
, apply ? null # Function that converts the option value to something else.
|
||||
, internal ? null # Whether the option is for NixOS developers only.
|
||||
, visible ? null # Whether the option shows up in the manual.
|
||||
, options ? null # Obsolete, used by types.optionSet.
|
||||
} @ attrs:
|
||||
attrs // { _type = "option"; };
|
||||
|
||||
mkEnableOption = name: mkOption {
|
||||
default = false;
|
||||
|
||||
@@ -201,6 +201,9 @@ rec {
|
||||
name = /* builtins.trace "types.optionSet is deprecated; use types.submodule instead" */ "option set";
|
||||
};
|
||||
|
||||
# Augment the given type with an additional type check function.
|
||||
addCheck = elemType: check: elemType // { check = x: elemType.check x && check x; };
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user