summaryrefslogtreecommitdiffstats
path: root/lib/modules.nix
diff options
context:
space:
mode:
authorNicolas B. Pierron <nicolas.b.pierron@gmail.com>2015-03-12 23:19:23 +0100
committerNicolas B. Pierron <nicolas.b.pierron@gmail.com>2015-03-15 14:45:42 +0100
commit05e8a48fb4af4c20134362c77ba6c5b4c6e49268 (patch)
treeba24acdcf42b858f477faa0ba996346e66808698 /lib/modules.nix
parented91474e9b94f06a44b7aa5bda9911292f709f54 (diff)
Document and rename internal option of modules.
Diffstat (limited to 'lib/modules.nix')
-rw-r--r--lib/modules.nix34
1 files changed, 17 insertions, 17 deletions
diff --git a/lib/modules.nix b/lib/modules.nix
index a3c3fe7fc1ae..dcede0c46c63 100644
--- a/lib/modules.nix
+++ b/lib/modules.nix
@@ -17,51 +17,51 @@ rec {
evalModules) and the less declarative the module set is. */
evalModules = { modules
, prefix ? []
- , # !!! This can be specified modularly now, can we remove it?
+ , # This would be remove in the future, Prefer _module.args option instead.
args ? {}
- , # !!! This can be specified modularly now, can we remove it?
+ , # This would be remove in the future, Prefer _module.check option instead.
check ? true
}:
let
+ # This internal module declare internal options under the `_module'
+ # attribute. These options are fragile, as they are used by the
+ # module system to change the interpretation of modules.
internalModule = rec {
_file = ./modules.nix;
key = _file;
options = {
- __internal.args = mkOption {
- description = "Arguments passed to each module.";
-
- # !!! Should this be types.uniq types.unspecified?
+ _module.args = mkOption {
type = types.attrsOf types.unspecified;
-
internal = true;
+ description = "Arguments passed to each module.";
};
- __internal.check = mkOption {
- description = "Whether to check whether all option definitions have matching declarations.";
-
+ _module.check = mkOption {
type = types.uniq types.bool;
-
internal = true;
-
default = check;
+ description = "Whether to check whether all option definitions have matching declarations.";
};
};
config = {
- __internal.args = args;
+ _module.args = args;
};
};
+
closed = closeModules (modules ++ [ internalModule ]) { inherit config options; lib = import ./.; };
+
# Note: the list of modules is reversed to maintain backward
# compatibility with the old module system. Not sure if this is
# the most sensible policy.
options = mergeModules prefix (reverseList closed);
+
# Traverse options and extract the option values into the final
# config set. At the same time, check whether all option
# definitions have matching declarations.
- # !!! __internal.check's value can't depend on any other config values
+ # !!! _module.check's value can't depend on any other config values
# without an infinite recursion. One way around this is to make the
# 'config' passed around to the modules be unconditionally unchecked,
# and only do the check in 'result'.
@@ -71,7 +71,7 @@ rec {
if isOption v then v.value
else yieldConfig (prefix ++ [n]) v) set) ["_definedNames"];
in
- if options.__internal.check.value && set ? _definedNames then
+ if options._module.check.value && set ? _definedNames then
fold (m: res:
fold (name: res:
if set ? ${name} then res else throw "The option `${showOption (prefix ++ [name])}' defined in `${m.file}' does not exist.")
@@ -122,7 +122,7 @@ rec {
let
# Module arguments are resolved in a strict manner when attribute set
# deconstruction is used. As the arguments are now defined with the
- # config.__interanl.args option, the strictness used on the attribute
+ # config._module.args option, the strictness used on the attribute
# set argument would cause an infinite loop, if the result of the
# option is given as argument.
#
@@ -135,7 +135,7 @@ rec {
requiredArgs = builtins.attrNames (builtins.functionArgs f);
extraArgs = builtins.listToAttrs (map (name: {
inherit name;
- value = config.__internal.args.${name};
+ value = config._module.args.${name};
}) requiredArgs);
in f (extraArgs // arg)
else