lol

lib/modules: convert option description to MD

pennae e04a0908 f2ea09ec

+44 -78
+43 -77
lib/modules.nix
··· 163 163 # TODO: Change the type of this option to a submodule with a 164 164 # freeformType, so that individual arguments can be documented 165 165 # separately 166 - description = '' 166 + description = lib.mdDoc '' 167 167 Additional arguments passed to each module in addition to ones 168 - like <literal>lib</literal>, <literal>config</literal>, 169 - and <literal>pkgs</literal>, <literal>modulesPath</literal>. 170 - </para> 171 - <para> 168 + like `lib`, `config`, 169 + and `pkgs`, `modulesPath`. 170 + 172 171 This option is also available to all submodules. Submodules do not 173 172 inherit args from their parent module, nor do they provide args to 174 173 their parent module or sibling submodules. The sole exception to 175 - this is the argument <literal>name</literal> which is provided by 174 + this is the argument `name` which is provided by 176 175 parent modules to a submodule and contains the attribute name 177 176 the submodule is bound to, or a unique generated name if it is 178 177 not bound to an attribute. 179 - </para> 180 - <para> 178 + 181 179 Some arguments are already passed by default, of which the 182 - following <emphasis>cannot</emphasis> be changed with this option: 183 - <itemizedlist> 184 - <listitem> 185 - <para> 186 - <varname>lib</varname>: The nixpkgs library. 187 - </para> 188 - </listitem> 189 - <listitem> 190 - <para> 191 - <varname>config</varname>: The results of all options after merging the values from all modules together. 192 - </para> 193 - </listitem> 194 - <listitem> 195 - <para> 196 - <varname>options</varname>: The options declared in all modules. 197 - </para> 198 - </listitem> 199 - <listitem> 200 - <para> 201 - <varname>specialArgs</varname>: The <literal>specialArgs</literal> argument passed to <literal>evalModules</literal>. 202 - </para> 203 - </listitem> 204 - <listitem> 205 - <para> 206 - All attributes of <varname>specialArgs</varname> 207 - </para> 208 - <para> 209 - Whereas option values can generally depend on other option values 210 - thanks to laziness, this does not apply to <literal>imports</literal>, which 211 - must be computed statically before anything else. 212 - </para> 213 - <para> 214 - For this reason, callers of the module system can provide <literal>specialArgs</literal> 215 - which are available during import resolution. 216 - </para> 217 - <para> 218 - For NixOS, <literal>specialArgs</literal> includes 219 - <varname>modulesPath</varname>, which allows you to import 220 - extra modules from the nixpkgs package tree without having to 221 - somehow make the module aware of the location of the 222 - <literal>nixpkgs</literal> or NixOS directories. 223 - <programlisting> 224 - { modulesPath, ... }: { 225 - imports = [ 226 - (modulesPath + "/profiles/minimal.nix") 227 - ]; 228 - } 229 - </programlisting> 230 - </para> 231 - </listitem> 232 - </itemizedlist> 233 - </para> 234 - <para> 180 + following *cannot* be changed with this option: 181 + - {var}`lib`: The nixpkgs library. 182 + - {var}`config`: The results of all options after merging the values from all modules together. 183 + - {var}`options`: The options declared in all modules. 184 + - {var}`specialArgs`: The `specialArgs` argument passed to `evalModules`. 185 + - All attributes of {var}`specialArgs` 186 + 187 + Whereas option values can generally depend on other option values 188 + thanks to laziness, this does not apply to `imports`, which 189 + must be computed statically before anything else. 190 + 191 + For this reason, callers of the module system can provide `specialArgs` 192 + which are available during import resolution. 193 + 194 + For NixOS, `specialArgs` includes 195 + {var}`modulesPath`, which allows you to import 196 + extra modules from the nixpkgs package tree without having to 197 + somehow make the module aware of the location of the 198 + `nixpkgs` or NixOS directories. 199 + ``` 200 + { modulesPath, ... }: { 201 + imports = [ 202 + (modulesPath + "/profiles/minimal.nix") 203 + ]; 204 + } 205 + ``` 206 + 235 207 For NixOS, the default value for this option includes at least this argument: 236 - <itemizedlist> 237 - <listitem> 238 - <para> 239 - <varname>pkgs</varname>: The nixpkgs package set according to 240 - the <option>nixpkgs.pkgs</option> option. 241 - </para> 242 - </listitem> 243 - </itemizedlist> 208 + - {var}`pkgs`: The nixpkgs package set according to 209 + the {option}`nixpkgs.pkgs` option. 244 210 ''; 245 211 }; 246 212 ··· 248 214 type = types.bool; 249 215 internal = true; 250 216 default = true; 251 - description = "Whether to check whether all option definitions have matching declarations."; 217 + description = lib.mdDoc "Whether to check whether all option definitions have matching declarations."; 252 218 }; 253 219 254 220 _module.freeformType = mkOption { 255 221 type = types.nullOr types.optionType; 256 222 internal = true; 257 223 default = null; 258 - description = '' 224 + description = lib.mdDoc '' 259 225 If set, merge all definitions that don't have an associated option 260 226 together using this type. The result then gets combined with the 261 - values of all declared options to produce the final <literal> 262 - config</literal> value. 227 + values of all declared options to produce the final ` 228 + config` value. 263 229 264 - If this is <literal>null</literal>, definitions without an option 265 - will throw an error unless <option>_module.check</option> is 230 + If this is `null`, definitions without an option 231 + will throw an error unless {option}`_module.check` is 266 232 turned off. 267 233 ''; 268 234 }; ··· 270 236 _module.specialArgs = mkOption { 271 237 readOnly = true; 272 238 internal = true; 273 - description = '' 239 + description = lib.mdDoc '' 274 240 Externally provided module arguments that can't be modified from 275 241 within a configuration, but can be used in module imports. 276 242 ''; ··· 1167 1133 { 1168 1134 options = setAttrByPath from (mkOption { 1169 1135 inherit visible; 1170 - description = "Alias of <option>${showOption to}</option>."; 1136 + description = lib.mdDoc "Alias of {option}`${showOption to}`."; 1171 1137 apply = x: use (toOf config); 1172 1138 } // optionalAttrs (toType != null) { 1173 1139 type = toType;
+1 -1
lib/options.nix
··· 137 137 let default' = if !isList default then [ default ] else default; 138 138 in mkOption { 139 139 type = lib.types.package; 140 - description = "The ${name} package to use."; 140 + description = lib.mdDoc "The ${name} package to use."; 141 141 default = attrByPath default' 142 142 (throw "${concatStringsSep "." default'} cannot be found in pkgs") pkgs; 143 143 defaultText = literalExpression ("pkgs." + concatStringsSep "." default');