···163163 # TODO: Change the type of this option to a submodule with a
164164 # freeformType, so that individual arguments can be documented
165165 # separately
166166- description = ''
166166+ description = lib.mdDoc ''
167167 Additional arguments passed to each module in addition to ones
168168- like <literal>lib</literal>, <literal>config</literal>,
169169- and <literal>pkgs</literal>, <literal>modulesPath</literal>.
170170- </para>
171171- <para>
168168+ like `lib`, `config`,
169169+ and `pkgs`, `modulesPath`.
170170+172171 This option is also available to all submodules. Submodules do not
173172 inherit args from their parent module, nor do they provide args to
174173 their parent module or sibling submodules. The sole exception to
175175- this is the argument <literal>name</literal> which is provided by
174174+ this is the argument `name` which is provided by
176175 parent modules to a submodule and contains the attribute name
177176 the submodule is bound to, or a unique generated name if it is
178177 not bound to an attribute.
179179- </para>
180180- <para>
178178+181179 Some arguments are already passed by default, of which the
182182- following <emphasis>cannot</emphasis> be changed with this option:
183183- <itemizedlist>
184184- <listitem>
185185- <para>
186186- <varname>lib</varname>: The nixpkgs library.
187187- </para>
188188- </listitem>
189189- <listitem>
190190- <para>
191191- <varname>config</varname>: The results of all options after merging the values from all modules together.
192192- </para>
193193- </listitem>
194194- <listitem>
195195- <para>
196196- <varname>options</varname>: The options declared in all modules.
197197- </para>
198198- </listitem>
199199- <listitem>
200200- <para>
201201- <varname>specialArgs</varname>: The <literal>specialArgs</literal> argument passed to <literal>evalModules</literal>.
202202- </para>
203203- </listitem>
204204- <listitem>
205205- <para>
206206- All attributes of <varname>specialArgs</varname>
207207- </para>
208208- <para>
209209- Whereas option values can generally depend on other option values
210210- thanks to laziness, this does not apply to <literal>imports</literal>, which
211211- must be computed statically before anything else.
212212- </para>
213213- <para>
214214- For this reason, callers of the module system can provide <literal>specialArgs</literal>
215215- which are available during import resolution.
216216- </para>
217217- <para>
218218- For NixOS, <literal>specialArgs</literal> includes
219219- <varname>modulesPath</varname>, which allows you to import
220220- extra modules from the nixpkgs package tree without having to
221221- somehow make the module aware of the location of the
222222- <literal>nixpkgs</literal> or NixOS directories.
223223- <programlisting>
224224- { modulesPath, ... }: {
225225- imports = [
226226- (modulesPath + "/profiles/minimal.nix")
227227- ];
228228- }
229229- </programlisting>
230230- </para>
231231- </listitem>
232232- </itemizedlist>
233233- </para>
234234- <para>
180180+ following *cannot* be changed with this option:
181181+ - {var}`lib`: The nixpkgs library.
182182+ - {var}`config`: The results of all options after merging the values from all modules together.
183183+ - {var}`options`: The options declared in all modules.
184184+ - {var}`specialArgs`: The `specialArgs` argument passed to `evalModules`.
185185+ - All attributes of {var}`specialArgs`
186186+187187+ Whereas option values can generally depend on other option values
188188+ thanks to laziness, this does not apply to `imports`, which
189189+ must be computed statically before anything else.
190190+191191+ For this reason, callers of the module system can provide `specialArgs`
192192+ which are available during import resolution.
193193+194194+ For NixOS, `specialArgs` includes
195195+ {var}`modulesPath`, which allows you to import
196196+ extra modules from the nixpkgs package tree without having to
197197+ somehow make the module aware of the location of the
198198+ `nixpkgs` or NixOS directories.
199199+ ```
200200+ { modulesPath, ... }: {
201201+ imports = [
202202+ (modulesPath + "/profiles/minimal.nix")
203203+ ];
204204+ }
205205+ ```
206206+235207 For NixOS, the default value for this option includes at least this argument:
236236- <itemizedlist>
237237- <listitem>
238238- <para>
239239- <varname>pkgs</varname>: The nixpkgs package set according to
240240- the <option>nixpkgs.pkgs</option> option.
241241- </para>
242242- </listitem>
243243- </itemizedlist>
208208+ - {var}`pkgs`: The nixpkgs package set according to
209209+ the {option}`nixpkgs.pkgs` option.
244210 '';
245211 };
246212···248214 type = types.bool;
249215 internal = true;
250216 default = true;
251251- description = "Whether to check whether all option definitions have matching declarations.";
217217+ description = lib.mdDoc "Whether to check whether all option definitions have matching declarations.";
252218 };
253219254220 _module.freeformType = mkOption {
255221 type = types.nullOr types.optionType;
256222 internal = true;
257223 default = null;
258258- description = ''
224224+ description = lib.mdDoc ''
259225 If set, merge all definitions that don't have an associated option
260226 together using this type. The result then gets combined with the
261261- values of all declared options to produce the final <literal>
262262- config</literal> value.
227227+ values of all declared options to produce the final `
228228+ config` value.
263229264264- If this is <literal>null</literal>, definitions without an option
265265- will throw an error unless <option>_module.check</option> is
230230+ If this is `null`, definitions without an option
231231+ will throw an error unless {option}`_module.check` is
266232 turned off.
267233 '';
268234 };
···270236 _module.specialArgs = mkOption {
271237 readOnly = true;
272238 internal = true;
273273- description = ''
239239+ description = lib.mdDoc ''
274240 Externally provided module arguments that can't be modified from
275241 within a configuration, but can be used in module imports.
276242 '';
···11671133 {
11681134 options = setAttrByPath from (mkOption {
11691135 inherit visible;
11701170- description = "Alias of <option>${showOption to}</option>.";
11361136+ description = lib.mdDoc "Alias of {option}`${showOption to}`.";
11711137 apply = x: use (toOf config);
11721138 } // optionalAttrs (toType != null) {
11731139 type = toType;
+1-1
lib/options.nix
···137137 let default' = if !isList default then [ default ] else default;
138138 in mkOption {
139139 type = lib.types.package;
140140- description = "The ${name} package to use.";
140140+ description = lib.mdDoc "The ${name} package to use.";
141141 default = attrByPath default'
142142 (throw "${concatStringsSep "." default'} cannot be found in pkgs") pkgs;
143143 defaultText = literalExpression ("pkgs." + concatStringsSep "." default');