···
77
-
/* See https://nixos.org/manual/nixpkgs/unstable/#module-system-lib-evalModules
78
-
or file://./../doc/module-system/module-system.chapter.md
78
+
See https://nixos.org/manual/nixpkgs/unstable/#module-system-lib-evalModules
79
+
or file://./../doc/module-system/module-system.chapter.md
80
-
!!! Please think twice before adding to this argument list! The more
81
-
that is specified here instead of in the modules themselves the harder
82
-
it is to transparently move a set of modules to be a submodule of another
83
-
config (as the proper arguments need to be replicated at each call to
84
-
evalModules) and the less declarative the module set is. */
81
+
!!! Please think twice before adding to this argument list! The more
82
+
that is specified here instead of in the modules themselves the harder
83
+
it is to transparently move a set of modules to be a submodule of another
84
+
config (as the proper arguments need to be replicated at each call to
85
+
evalModules) and the less declarative the module set is.
evalModules = evalModulesArgs@
···
382
-
Collects all modules recursively into the form
384
+
Collects all modules recursively into the form
385
-
disabled = [ <list of disabled modules> ];
386
-
# All modules of the main module list
390
-
module = <module for key1>;
391
-
# All modules imported by the module for key1
395
-
module = <module for key1-1>;
396
-
# All modules imported by the module for key1-1
387
+
disabled = [ <list of disabled modules> ];
388
+
# All modules of the main module list
392
+
module = <module for key1>;
393
+
# All modules imported by the module for key1
397
+
module = <module for key1-1>;
398
+
# All modules imported by the module for key1-1
collectStructuredModules =
···
in modulesPath: initialModules: args:
filterModules modulesPath (collectStructuredModules unknownModule "" initialModules args);
462
-
/* Wrap a module with a default location for reporting errors. */
465
+
Wrap a module with a default location for reporting errors.
472
+
: 1\. Function argument
476
+
: 2\. Function argument
setDefaultModuleLocation = file: m:
{ _file = file; imports = [ m ]; };
466
-
/* Massage a module into canonical form, that is, a set consisting
467
-
of ‘options’, ‘config’ and ‘imports’ attributes. */
482
+
Massage a module into canonical form, that is, a set consisting
483
+
of ‘options’, ‘config’ and ‘imports’ attributes.
490
+
: 1\. Function argument
494
+
: 2\. Function argument
498
+
: 3\. Function argument
unifyModuleSyntax = file: key: m:
addMeta = config: if m ? meta
···
in f (args // extraArgs);
531
-
/* Merge a list of modules. This will recurse over the option
532
-
declarations in all modules, combining them into a single set.
533
-
At the same time, for each option declaration, it will merge the
534
-
corresponding option definitions in all machines, returning them
535
-
in the ‘value’ attribute of each option.
564
+
Merge a list of modules. This will recurse over the option
565
+
declarations in all modules, combining them into a single set.
566
+
At the same time, for each option declaration, it will merge the
567
+
corresponding option definitions in all machines, returning them
568
+
in the ‘value’ attribute of each option.
537
-
This returns a set like
539
-
# A recursive set of options along with their final values
541
-
foo = { _type = "option"; value = "option value of foo"; ... };
542
-
bar.baz = { _type = "option"; value = "option value of bar.baz"; ... };
545
-
# A list of definitions that weren't matched by any option
547
-
{ file = "file.nix"; prefix = [ "qux" ]; value = "qux"; }
570
+
This returns a set like
572
+
# A recursive set of options along with their final values
574
+
foo = { _type = "option"; value = "option value of foo"; ... };
575
+
bar.baz = { _type = "option"; value = "option value of bar.baz"; ... };
578
+
# A list of definitions that weren't matched by any option
580
+
{ file = "file.nix"; prefix = [ "qux" ]; value = "qux"; }
590
+
: 1\. Function argument
594
+
: 2\. Function argument
mergeModules = prefix: modules:
mergeModules' prefix modules
···
throw (concatStringsSep "\n\n" paragraphs);
743
-
/* Merge multiple option declarations into a single declaration. In
744
-
general, there should be only one declaration of each option.
745
-
The exception is the ‘options’ attribute, which specifies
746
-
sub-options. These can be specified multiple times to allow one
747
-
module to add sub-options to an option declared somewhere else
748
-
(e.g. multiple modules define sub-options for ‘fileSystems’).
788
+
Merge multiple option declarations into a single declaration. In
789
+
general, there should be only one declaration of each option.
790
+
The exception is the ‘options’ attribute, which specifies
791
+
sub-options. These can be specified multiple times to allow one
792
+
module to add sub-options to an option declared somewhere else
793
+
(e.g. multiple modules define sub-options for ‘fileSystems’).
795
+
'loc' is the list of attribute names where the option is located.
797
+
'opts' is a list of modules. Each module has an options attribute which
798
+
correspond to the definition of 'loc' in 'opt.file'.
805
+
: 1\. Function argument
750
-
'loc' is the list of attribute names where the option is located.
752
-
'opts' is a list of modules. Each module has an options attribute which
753
-
correspond to the definition of 'loc' in 'opt.file'. */
809
+
: 2\. Function argument
···
) { inherit loc; declarations = []; declarationPositions = []; options = []; } opts;
822
-
/* Merge all the definitions of an option to produce the final
880
+
Merge all the definitions of an option to produce the final
888
+
: 1\. Function argument
892
+
: 2\. Function argument
896
+
: 3\. Function argument
evalOptionValue = loc: opt: defs:
# Add in the default value for this option, if any.
···
905
-
/* Given a config set, expand mkMerge properties, and push down the
906
-
other properties into the children. The result is a list of
907
-
config sets that do not have properties at top-level. For
980
+
Given a config set, expand mkMerge properties, and push down the
981
+
other properties into the children. The result is a list of
982
+
config sets that do not have properties at top-level. For
910
-
mkMerge [ { boot = set1; } (mkIf cond { boot = set2; services = set3; }) ]
985
+
mkMerge [ { boot = set1; } (mkIf cond { boot = set2; services = set3; }) ]
912
-
is transformed into
987
+
is transformed into
914
-
[ { boot = set1; } { boot = mkIf cond set2; services = mkIf cond set3; } ].
989
+
[ { boot = set1; } { boot = mkIf cond set2; services = mkIf cond set3; } ].
991
+
This transform is the critical step that allows mkIf conditions
992
+
to refer to the full configuration without creating an infinite
916
-
This transform is the critical step that allows mkIf conditions
917
-
to refer to the full configuration without creating an infinite
1000
+
: 1\. Function argument
pushDownProperties = cfg:
if cfg._type or "" == "merge" then
···
else # FIXME: handle mkOrder?
930
-
/* Given a config value, expand mkMerge properties, and discharge
931
-
any mkIf conditions. That is, this is the place where mkIf
932
-
conditions are actually evaluated. The result is a list of
933
-
config values. For example, ‘mkIf false x’ yields ‘[]’,
934
-
‘mkIf true x’ yields ‘[x]’, and
1013
+
Given a config value, expand mkMerge properties, and discharge
1014
+
any mkIf conditions. That is, this is the place where mkIf
1015
+
conditions are actually evaluated. The result is a list of
1016
+
config values. For example, ‘mkIf false x’ yields ‘[]’,
1017
+
‘mkIf true x’ yields ‘[x]’, and
1019
+
mkMerge [ 1 (mkIf true 2) (mkIf true (mkIf false 3)) ]
936
-
mkMerge [ 1 (mkIf true 2) (mkIf true (mkIf false 3)) ]
1028
+
: 1\. Function argument
dischargeProperties = def:
if def._type or "" == "merge" then
···
954
-
/* Given a list of config values, process the mkOverride properties,
955
-
that is, return the values that have the highest (that is,
956
-
numerically lowest) priority, and strip the mkOverride
957
-
properties. For example,
1045
+
Given a list of config values, process the mkOverride properties,
1046
+
that is, return the values that have the highest (that is,
1047
+
numerically lowest) priority, and strip the mkOverride
1048
+
properties. For example,
959
-
[ { file = "/1"; value = mkOverride 10 "a"; }
960
-
{ file = "/2"; value = mkOverride 20 "b"; }
961
-
{ file = "/3"; value = "z"; }
962
-
{ file = "/4"; value = mkOverride 10 "d"; }
1050
+
[ { file = "/1"; value = mkOverride 10 "a"; }
1051
+
{ file = "/2"; value = mkOverride 20 "b"; }
1052
+
{ file = "/3"; value = "z"; }
1053
+
{ file = "/4"; value = mkOverride 10 "d"; }
1058
+
[ { file = "/1"; value = "a"; }
1059
+
{ file = "/4"; value = "d"; }
1062
+
Note that "z" has the default priority 100.
967
-
[ { file = "/1"; value = "a"; }
968
-
{ file = "/4"; value = "d"; }
971
-
Note that "z" has the default priority 100.
1069
+
: 1\. Function argument
filterOverrides = defs: (filterOverrides' defs).values;
···
985
-
/* Sort a list of properties. The sort priority of a property is
986
-
defaultOrderPriority by default, but can be overridden by wrapping the property
1084
+
Sort a list of properties. The sort priority of a property is
1085
+
defaultOrderPriority by default, but can be overridden by wrapping the property
1093
+
: 1\. Function argument
···
else opt // { type = opt.type.substSubModules opt.options; options = []; };
Merge an option's definitions in a way that preserves the priority of the
individual attributes in the option value.
This does not account for all option semantics, such as readOnly.
1014
-
option -> attrsOf { highestPrio, value }
1125
+
: 1\. Function argument
1130
+
option -> attrsOf { highestPrio, value }
mergeAttrDefinitionsWithPrio = opt:
···
1166
+
: 1\. Function argument
1170
+
: 2\. Function argument
mkIf = condition: content:
···
mkIf (isOption option && option.isDefined);
1119
-
/* Compatibility. */
1257
+
: 1\. Function argument
1261
+
: 2\. Function argument
fixMergeModules = modules: args: evalModules { inherit modules args; check = false; };
1123
-
/* Return a module that causes a warning to be shown if the
1124
-
specified option is defined. For example,
1267
+
Return a module that causes a warning to be shown if the
1268
+
specified option is defined. For example,
1270
+
mkRemovedOptionModule [ "boot" "loader" "grub" "bootDevice" ] "<replacement instructions>"
1126
-
mkRemovedOptionModule [ "boot" "loader" "grub" "bootDevice" ] "<replacement instructions>"
1272
+
causes a assertion if the user defines boot.loader.grub.bootDevice.
1128
-
causes a assertion if the user defines boot.loader.grub.bootDevice.
1274
+
replacementInstructions is a string that provides instructions on
1275
+
how to achieve the same functionality without the removed option,
1276
+
or alternatively a reasoning why the functionality is not needed.
1277
+
replacementInstructions SHOULD be provided!
1130
-
replacementInstructions is a string that provides instructions on
1131
-
how to achieve the same functionality without the removed option,
1132
-
or alternatively a reasoning why the functionality is not needed.
1133
-
replacementInstructions SHOULD be provided!
1284
+
: 1\. Function argument
1286
+
`replacementInstructions`
1288
+
: 2\. Function argument
mkRemovedOptionModule = optionName: replacementInstructions:
···
1151
-
/* Return a module that causes a warning to be shown if the
1152
-
specified "from" option is defined; the defined value is however
1153
-
forwarded to the "to" option. This can be used to rename options
1154
-
while providing backward compatibility. For example,
1307
+
Return a module that causes a warning to be shown if the
1308
+
specified "from" option is defined; the defined value is however
1309
+
forwarded to the "to" option. This can be used to rename options
1310
+
while providing backward compatibility. For example,
1312
+
mkRenamedOptionModule [ "boot" "copyKernels" ] [ "boot" "loader" "grub" "copyKernels" ]
1314
+
forwards any definitions of boot.copyKernels to
1315
+
boot.loader.grub.copyKernels while printing a warning.
1317
+
This also copies over the priority from the aliased option to the
1318
+
non-aliased option.
1156
-
mkRenamedOptionModule [ "boot" "copyKernels" ] [ "boot" "loader" "grub" "copyKernels" ]
1158
-
forwards any definitions of boot.copyKernels to
1159
-
boot.loader.grub.copyKernels while printing a warning.
1161
-
This also copies over the priority from the aliased option to the
1162
-
non-aliased option.
1325
+
: 1\. Function argument
1329
+
: 2\. Function argument
mkRenamedOptionModule = from: to: doRename {
···
mkRenamedOptionModuleWith = {
1172
-
/* Old option path as list of strings. */
1340
+
Old option path as list of strings.
1174
-
/* New option path as list of strings. */
1344
+
New option path as list of strings.
Release number of the first release that contains the rename, ignoring backports.
Set it to the upcoming release, matching the nixpkgs/.version file.
···
"Obsolete option `${showOption from}' is used. It was renamed to `${showOption to}'.";
1191
-
/* Return a module that causes a warning to be shown if any of the "from"
1192
-
option is defined; the defined values can be used in the "mergeFn" to set
1194
-
This function can be used to merge multiple options into one that has a
1363
+
Return a module that causes a warning to be shown if any of the "from"
1364
+
option is defined; the defined values can be used in the "mergeFn" to set
1366
+
This function can be used to merge multiple options into one that has a
1369
+
"mergeFn" takes the module "config" as a parameter and must return a value
1370
+
of "to" option type.
1372
+
mkMergedOptionModule
1377
+
let value = p: getAttrFromPath p config;
1379
+
if (value [ "a" "b" "c" ]) == true then "foo"
1380
+
else if (value [ "d" "e" "f" ]) == true then "bar"
1383
+
- options.a.b.c is a removed boolean option
1384
+
- options.d.e.f is a removed boolean option
1385
+
- options.x.y.z is a new str option that combines a.b.c and d.e.f
1388
+
This show a warning if any a.b.c or d.e.f is set, and set the value of
1389
+
x.y.z to the result of the merge function
1396
+
: 1\. Function argument
1197
-
"mergeFn" takes the module "config" as a parameter and must return a value
1198
-
of "to" option type.
1200
-
mkMergedOptionModule
1205
-
let value = p: getAttrFromPath p config;
1207
-
if (value [ "a" "b" "c" ]) == true then "foo"
1208
-
else if (value [ "d" "e" "f" ]) == true then "bar"
1400
+
: 2\. Function argument
1211
-
- options.a.b.c is a removed boolean option
1212
-
- options.d.e.f is a removed boolean option
1213
-
- options.x.y.z is a new str option that combines a.b.c and d.e.f
1216
-
This show a warning if any a.b.c or d.e.f is set, and set the value of
1217
-
x.y.z to the result of the merge function
1404
+
: 3\. Function argument
mkMergedOptionModule = from: to: mergeFn:
{ config, options, ... }:
···
1243
-
/* Single "from" version of mkMergedOptionModule.
1244
-
Return a module that causes a warning to be shown if the "from" option is
1245
-
defined; the defined value can be used in the "mergeFn" to set the "to"
1247
-
This function can be used to change an option into another that has a
1431
+
Single "from" version of mkMergedOptionModule.
1432
+
Return a module that causes a warning to be shown if the "from" option is
1433
+
defined; the defined value can be used in the "mergeFn" to set the "to"
1435
+
This function can be used to change an option into another that has a
1438
+
"mergeFn" takes the module "config" as a parameter and must return a value of
1441
+
mkChangedOptionModule [ "a" "b" "c" ] [ "x" "y" "z" ]
1443
+
let value = getAttrFromPath [ "a" "b" "c" ] config;
1445
+
if value > 100 then "high"
1448
+
- options.a.b.c is a removed int option
1449
+
- options.x.y.z is a new str option that supersedes a.b.c
1451
+
This show a warning if a.b.c is set, and set the value of x.y.z to the
1452
+
result of the change function
1250
-
"mergeFn" takes the module "config" as a parameter and must return a value of
1253
-
mkChangedOptionModule [ "a" "b" "c" ] [ "x" "y" "z" ]
1255
-
let value = getAttrFromPath [ "a" "b" "c" ] config;
1257
-
if value > 100 then "high"
1459
+
: 1\. Function argument
1463
+
: 2\. Function argument
1260
-
- options.a.b.c is a removed int option
1261
-
- options.x.y.z is a new str option that supersedes a.b.c
1263
-
This show a warning if a.b.c is set, and set the value of x.y.z to the
1264
-
result of the change function
1467
+
: 3\. Function argument
mkChangedOptionModule = from: to: changeFn:
mkMergedOptionModule [ from ] to changeFn;
1269
-
/* Like ‘mkRenamedOptionModule’, but doesn't show a warning. */
1473
+
Like ‘mkRenamedOptionModule’, but doesn't show a warning.
1480
+
: 1\. Function argument
1484
+
: 2\. Function argument
mkAliasOptionModule = from: to: doRename {
···
1277
-
/* Transitional version of mkAliasOptionModule that uses MD docs.
1494
+
Transitional version of mkAliasOptionModule that uses MD docs.
1279
-
This function is no longer necessary and merely an alias of `mkAliasOptionModule`.
1496
+
This function is no longer necessary and merely an alias of `mkAliasOptionModule`.
mkAliasOptionModuleMD = mkAliasOptionModule;
1283
-
/* mkDerivedConfig : Option a -> (a -> Definition b) -> Definition b
1501
+
mkDerivedConfig : Option a -> (a -> Definition b) -> Definition b
Create config definitions with the same priority as the definition of another option.
This should be used for option definitions where one option sets the value of another as a convenience.
···
value using `mkDerivedConfig options.text (pkgs.writeText "filename.conf")`.
It takes care of setting the right priority using `mkOverride`.
1515
+
: 1\. Function argument
1519
+
: 2\. Function argument
# TODO: make the module system error message include information about `opt` in
# error messages about conflicts. E.g. introduce a variation of `mkOverride` which
···
(opt.highestPrio or defaultOverridePriority)
Return a module that help declares an option that has been renamed.
When a value is defined for the old option, it is forwarded to the `to` option.
# List of strings representing the attribute path of the old option.
···
lib.setDefaultModuleLocation modulePath (import modulePath staticArg);
1453
-
/* Use this function to import a JSON file as NixOS configuration.
1683
+
Use this function to import a JSON file as NixOS configuration.
1455
-
modules.importJSON :: path -> attrs
1685
+
modules.importJSON :: path -> attrs
1692
+
: 1\. Function argument
config = lib.importJSON file;
1462
-
/* Use this function to import a TOML file as NixOS configuration.
1700
+
Use this function to import a TOML file as NixOS configuration.
1464
-
modules.importTOML :: path -> attrs
1702
+
modules.importTOML :: path -> attrs
1709
+
: 1\. Function argument