···134134 ${if prefix == []
135135 then null # unset => visible
136136 else "internal"} = true;
137137- # TODO: hidden during the markdown transition to not expose downstream
138138- # users of the docs infra to markdown if they're not ready for it.
139139- # we don't make this visible conditionally because it can impact
140140- # performance (https://github.com/NixOS/nixpkgs/pull/208407#issuecomment-1368246192)
141141- visible = false;
142137 # TODO: Change the type of this option to a submodule with a
143138 # freeformType, so that individual arguments can be documented
144139 # separately
···11461141 use = id;
11471142 };
1148114311491149- /* Transitional version of mkAliasOptionModule that uses MD docs. */
11501150- mkAliasOptionModuleMD = from: to: doRename {
11511151- inherit from to;
11521152- visible = true;
11531153- warn = false;
11541154- use = id;
11551155- markdown = true;
11561156- };
11441144+ /* Transitional version of mkAliasOptionModule that uses MD docs.
11451145+11461146+ This function is no longer necessary and merely an alias of `mkAliasOptionModule`.
11471147+ */
11481148+ mkAliasOptionModuleMD = mkAliasOptionModule;
1157114911581150 /* mkDerivedConfig : Option a -> (a -> Definition b) -> Definition b
11591151···11751167 (opt.highestPrio or defaultOverridePriority)
11761168 (f opt.value);
1177116911781178- doRename = { from, to, visible, warn, use, withPriority ? true, markdown ? false }:
11701170+ doRename = { from, to, visible, warn, use, withPriority ? true }:
11791171 { config, options, ... }:
11801172 let
11811173 fromOpt = getAttrFromPath from options;
···11861178 {
11871179 options = setAttrByPath from (mkOption {
11881180 inherit visible;
11891189- description = if markdown
11901190- then lib.mdDoc "Alias of {option}`${showOption to}`."
11911191- else "Alias of <option>${showOption to}</option>.";
11811181+ description = "Alias of {option}`${showOption to}`.";
11921182 apply = x: use (toOf config);
11931183 } // optionalAttrs (toType != null) {
11941184 type = toType;
+8-25
lib/options.nix
···100100 name: mkOption {
101101 default = false;
102102 example = true;
103103- description =
104104- if name ? _type && name._type == "mdDoc"
105105- then lib.mdDoc "Whether to enable ${name.text}."
106106- else "Whether to enable ${name}.";
103103+ description = "Whether to enable ${name}.";
107104 type = lib.types.bool;
108105 };
109106···185182 (if isList example then "pkgs." + concatStringsSep "." example else example);
186183 });
187184188188- /* Like mkPackageOption, but emit an mdDoc description instead of DocBook. */
189189- mkPackageOptionMD = pkgs: name: extra:
190190- let option = mkPackageOption pkgs name extra;
191191- in option // { description = lib.mdDoc option.description; };
185185+ /* Alias of mkPackageOption. Previously used to create options with markdown
186186+ documentation, which is no longer required.
187187+ */
188188+ mkPackageOptionMD = mkPackageOption;
192189193190 /* This option accepts anything, but it does not produce any result.
194191···344341 if ! isString text then throw "literalExpression expects a string."
345342 else { _type = "literalExpression"; inherit text; };
346343347347- literalExample = lib.warn "literalExample is deprecated, use literalExpression instead, or use literalDocBook for a non-Nix description." literalExpression;
348348-349349-350350- /* For use in the `defaultText` and `example` option attributes. Causes the
351351- given DocBook text to be inserted verbatim in the documentation, for when
352352- a `literalExpression` would be too hard to read.
353353- */
354354- literalDocBook = text:
355355- if ! isString text then throw "literalDocBook expects a string."
356356- else
357357- lib.warnIf (lib.isInOldestRelease 2211)
358358- "literalDocBook is deprecated, use literalMD instead"
359359- { _type = "literalDocBook"; inherit text; };
344344+ literalExample = lib.warn "literalExample is deprecated, use literalExpression instead, or use literalMD for a non-Nix description." literalExpression;
360345361346 /* Transition marker for documentation that's already migrated to markdown
362362- syntax.
347347+ syntax. This is a no-op and no longer needed.
363348 */
364364- mdDoc = text:
365365- if ! isString text then throw "mdDoc expects a string."
366366- else { _type = "mdDoc"; inherit text; };
349349+ mdDoc = lib.id;
367350368351 /* For use in the `defaultText` and `example` option attributes. Causes the
369352 given MD text to be inserted verbatim in the documentation, for when
···11-<reference xmlns="http://docbook.org/ns/docbook"
22- xmlns:xlink="http://www.w3.org/1999/xlink"
33- xmlns:xi="http://www.w3.org/2001/XInclude">
44- <title>NixOS Reference Pages</title>
55- <info>
66- <author>
77- <personname><firstname>Eelco</firstname><surname>Dolstra</surname></personname>
88- <contrib>Author</contrib>
99- </author>
1010- <author>
1111- <personname><othername>The Nixpkgs/NixOS contributors</othername></personname>
1212- <contrib>Author</contrib>
1313- </author>
1414- <copyright><year>2007-2022</year><holder>Eelco Dolstra and the Nixpkgs/NixOS contributors</holder>
1515- </copyright>
1616- </info>
1717- <refentry>
1818- <refmeta>
1919- <refentrytitle><filename>configuration.nix</filename>
2020- </refentrytitle><manvolnum>5</manvolnum>
2121- <refmiscinfo class="source">NixOS</refmiscinfo>
2222- <!-- <refmiscinfo class="version"><xi:include href="version.txt" parse="text"/></refmiscinfo> -->
2323- </refmeta>
2424- <refnamediv>
2525- <refname><filename>configuration.nix</filename></refname>
2626- <refpurpose>NixOS system configuration specification</refpurpose>
2727- </refnamediv>
2828- <refsection>
2929- <title>Description</title>
3030- <para>
3131- The file <filename>/etc/nixos/configuration.nix</filename> contains the
3232- declarative specification of your NixOS system configuration. The command
3333- <command>nixos-rebuild</command> takes this file and realises the system
3434- configuration specified therein.
3535- </para>
3636- </refsection>
3737- <refsection>
3838- <title>Options</title>
3939- <para>
4040- You can use the following options in <filename>configuration.nix</filename>.
4141- </para>
4242- <xi:include href="./generated/options-db.xml"
4343- xpointer="configuration-variable-list" />
4444- </refsection>
4545- </refentry>
4646-</reference>
+2
nixos/doc/manual/release-notes/rl-2311.section.md
···58585959- A new option was added to the virtualisation module that enables specifying explicitly named network interfaces in QEMU VMs. The existing `virtualisation.vlans` is still supported for cases where the name of the network interface is irrelevant.
60606161+- DocBook option documentation is no longer supported, all module documentation now uses markdown.
6262+6163- `services.nginx` gained a `defaultListen` option at server-level with support for PROXY protocol listeners, also `proxyProtocol` is now exposed in `services.nginx.virtualHosts.<name>.listen` option. It is now possible to run PROXY listeners and non-PROXY listeners at a server-level, see [#213510](https://github.com/NixOS/nixpkgs/pull/213510/) for more details.
62646365## Nixpkgs internals {#sec-release-23.11-nixpkgs-internals}
+31-38
nixos/lib/make-options-doc/default.nix
···3939# allow docbook option docs if `true`. only markdown documentation is allowed when set to
4040# `false`, and a different renderer may be used with different bugs and performance
4141# characteristics but (hopefully) indistinguishable output.
4242-, allowDocBook ? true
4242+# deprecated since 23.11.
4343+# TODO remove in a while.
4444+, allowDocBook ? false
4345# whether lib.mdDoc is required for descriptions to be read as markdown.
4444-# !!! when this is eventually flipped to true, `lib.doRename` should also default to emitting Markdown
4545-, markdownByDefault ? false
4646+# deprecated since 23.11.
4747+# TODO remove in a while.
4848+, markdownByDefault ? true
4649}:
5050+5151+assert markdownByDefault && ! allowDocBook;
47524853let
4954 rawOpts = lib.optionAttrSetToDocList options;
···134139 TOUCH_IF_DB=$dst/.used-docbook \
135140 python ${./mergeJSON.py} \
136141 ${lib.optionalString warningsAreErrors "--warnings-are-errors"} \
137137- ${if allowDocBook then "--warn-on-docbook" else "--error-on-docbook"} \
138142 $baseJSON $options \
139143 > $dst/options.json
140144141141- brotli -9 < $dst/options.json > $dst/options.json.br
142142-143143- mkdir -p $out/nix-support
144144- echo "file json $dst/options.json" >> $out/nix-support/hydra-build-products
145145- echo "file json-br $dst/options.json.br" >> $out/nix-support/hydra-build-products
146146- '';
147147-148148- optionsUsedDocbook = pkgs.runCommand "options-used-docbook" {} ''
149149- if [ -e ${optionsJSON}/share/doc/nixos/.used-docbook ]; then
150150- echo 1
151151- else
152152- echo 0
153153- fi >"$out"
154154- '';
155155-156156- optionsDocBook = pkgs.runCommand "options-docbook.xml" {
157157- nativeBuildInputs = [
158158- pkgs.nixos-render-docs
159159- ];
160160- } ''
161161- nixos-render-docs -j $NIX_BUILD_CORES options docbook \
162162- --manpage-urls ${pkgs.path + "/doc/manpage-urls.json"} \
163163- --revision ${lib.escapeShellArg revision} \
164164- --document-type ${lib.escapeShellArg documentType} \
165165- --varlist-id ${lib.escapeShellArg variablelistId} \
166166- --id-prefix ${lib.escapeShellArg optionIdPrefix} \
167167- ${lib.optionalString markdownByDefault "--markdown-by-default"} \
168168- ${optionsJSON}/share/doc/nixos/options.json \
169169- options.xml
170170-171171- if grep /nixpkgs/nixos/modules options.xml; then
145145+ if grep /nixpkgs/nixos/modules $dst/options.json; then
172146 echo "The manual appears to depend on the location of Nixpkgs, which is bad"
173147 echo "since this prevents sharing via the NixOS channel. This is typically"
174148 echo "caused by an option default that refers to a relative path (see above"
···176150 exit 1
177151 fi
178152179179- ${pkgs.libxslt.bin}/bin/xsltproc \
180180- -o "$out" ${./postprocess-option-descriptions.xsl} options.xml
181181- '';
153153+ brotli -9 < $dst/options.json > $dst/options.json.br
154154+155155+ mkdir -p $out/nix-support
156156+ echo "file json $dst/options.json" >> $out/nix-support/hydra-build-products
157157+ echo "file json-br $dst/options.json.br" >> $out/nix-support/hydra-build-products
158158+ '';
159159+160160+ optionsDocBook = lib.warn "optionsDocBook is deprecated since 23.11 and will be removed in 24.05"
161161+ (pkgs.runCommand "options-docbook.xml" {
162162+ nativeBuildInputs = [
163163+ pkgs.nixos-render-docs
164164+ ];
165165+ } ''
166166+ nixos-render-docs -j $NIX_BUILD_CORES options docbook \
167167+ --manpage-urls ${pkgs.path + "/doc/manpage-urls.json"} \
168168+ --revision ${lib.escapeShellArg revision} \
169169+ --document-type ${lib.escapeShellArg documentType} \
170170+ --varlist-id ${lib.escapeShellArg variablelistId} \
171171+ --id-prefix ${lib.escapeShellArg optionIdPrefix} \
172172+ ${optionsJSON}/share/doc/nixos/options.json \
173173+ "$out"
174174+ '');
182175}
-60
nixos/lib/make-options-doc/mergeJSON.py
···4343 return result
44444545warningsAreErrors = False
4646-warnOnDocbook = False
4747-errorOnDocbook = False
4846optOffset = 0
4947for arg in sys.argv[1:]:
5048 if arg == "--warnings-are-errors":
5149 optOffset += 1
5250 warningsAreErrors = True
5353- if arg == "--warn-on-docbook":
5454- optOffset += 1
5555- warnOnDocbook = True
5656- elif arg == "--error-on-docbook":
5757- optOffset += 1
5858- errorOnDocbook = True
59516052options = pivot(json.load(open(sys.argv[1 + optOffset], 'r')))
6153overrides = pivot(json.load(open(sys.argv[2 + optOffset], 'r')))
···84768577severity = "error" if warningsAreErrors else "warning"
86788787-def is_docbook(o, key):
8888- val = o.get(key, {})
8989- if not isinstance(val, dict):
9090- return False
9191- return val.get('_type', '') == 'literalDocBook'
9292-9379# check that every option has a description
9480hasWarnings = False
9581hasErrors = False
9696-hasDocBook = False
9782for (k, v) in options.items():
9898- if warnOnDocbook or errorOnDocbook:
9999- kind = "error" if errorOnDocbook else "warning"
100100- if isinstance(v.value.get('description', {}), str):
101101- hasErrors |= errorOnDocbook
102102- hasDocBook = True
103103- print(
104104- f"\x1b[1;31m{kind}: option {v.name} description uses DocBook\x1b[0m",
105105- file=sys.stderr)
106106- elif is_docbook(v.value, 'defaultText'):
107107- hasErrors |= errorOnDocbook
108108- hasDocBook = True
109109- print(
110110- f"\x1b[1;31m{kind}: option {v.name} default uses DocBook\x1b[0m",
111111- file=sys.stderr)
112112- elif is_docbook(v.value, 'example'):
113113- hasErrors |= errorOnDocbook
114114- hasDocBook = True
115115- print(
116116- f"\x1b[1;31m{kind}: option {v.name} example uses DocBook\x1b[0m",
117117- file=sys.stderr)
118118-11983 if v.value.get('description', None) is None:
12084 hasWarnings = True
12185 print(f"\x1b[1;31m{severity}: option {v.name} has no description\x1b[0m", file=sys.stderr)
···12589 print(
12690 f"\x1b[1;31m{severity}: option {v.name} has no type. Please specify a valid type, see " +
12791 "https://nixos.org/manual/nixos/stable/index.html#sec-option-types\x1b[0m", file=sys.stderr)
128128-129129-if hasDocBook:
130130- (why, what) = (
131131- ("disallowed for in-tree modules", "contribution") if errorOnDocbook
132132- else ("deprecated for option documentation", "module")
133133- )
134134- print("Explanation: The documentation contains descriptions, examples, or defaults written in DocBook. " +
135135- "NixOS is in the process of migrating from DocBook to Markdown, and " +
136136- f"DocBook is {why}. To change your {what} to "+
137137- "use Markdown, apply mdDoc and literalMD and use the *MD variants of option creation " +
138138- "functions where they are available. For example:\n" +
139139- "\n" +
140140- " example.foo = mkOption {\n" +
141141- " description = lib.mdDoc ''your description'';\n" +
142142- " defaultText = lib.literalMD ''your description of default'';\n" +
143143- " };\n" +
144144- "\n" +
145145- " example.enable = mkEnableOption (lib.mdDoc ''your thing'');\n" +
146146- " example.package = mkPackageOptionMD pkgs \"your-package\" {};\n" +
147147- " imports = [ (mkAliasOptionModuleMD [ \"example\" \"args\" ] [ \"example\" \"settings\" ]) ];",
148148- file = sys.stderr)
149149- with open(os.getenv('TOUCH_IF_DB'), 'x'):
150150- # just make sure it exists
151151- pass
1529215393if hasErrors:
15494 sys.exit(1)
···11-<?xml version="1.0"?>
22-33-<xsl:stylesheet version="1.0"
44- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
55- xmlns:str="http://exslt.org/strings"
66- xmlns:exsl="http://exslt.org/common"
77- xmlns:db="http://docbook.org/ns/docbook"
88- xmlns:nixos="tag:nixos.org"
99- extension-element-prefixes="str exsl">
1010- <xsl:output method='xml' encoding="UTF-8" />
1111-1212- <xsl:template match="@*|node()">
1313- <xsl:copy>
1414- <xsl:apply-templates select="@*|node()" />
1515- </xsl:copy>
1616- </xsl:template>
1717-1818- <xsl:template name="break-up-description">
1919- <xsl:param name="input" />
2020- <xsl:param name="buffer" />
2121-2222- <!-- Every time we have two newlines following each other, we want to
2323- break it into </para><para>. -->
2424- <xsl:variable name="parbreak" select="'

'" />
2525-2626- <!-- Similar to "(head:tail) = input" in Haskell. -->
2727- <xsl:variable name="head" select="$input[1]" />
2828- <xsl:variable name="tail" select="$input[position() > 1]" />
2929-3030- <xsl:choose>
3131- <xsl:when test="$head/self::text() and contains($head, $parbreak)">
3232- <!-- If the haystack provided to str:split() directly starts or
3333- ends with $parbreak, it doesn't generate a <token/> for that,
3434- so we are doing this here. -->
3535- <xsl:variable name="splitted-raw">
3636- <xsl:if test="starts-with($head, $parbreak)"><token /></xsl:if>
3737- <xsl:for-each select="str:split($head, $parbreak)">
3838- <token><xsl:value-of select="node()" /></token>
3939- </xsl:for-each>
4040- <!-- Something like ends-with($head, $parbreak), but there is
4141- no ends-with() in XSLT, so we need to use substring(). -->
4242- <xsl:if test="
4343- substring($head, string-length($head) -
4444- string-length($parbreak) + 1) = $parbreak
4545- "><token /></xsl:if>
4646- </xsl:variable>
4747- <xsl:variable name="splitted"
4848- select="exsl:node-set($splitted-raw)/token" />
4949- <!-- The buffer we had so far didn't contain any text nodes that
5050- contain a $parbreak, so we can put the buffer along with the
5151- first token of $splitted into a para element. -->
5252- <para xmlns="http://docbook.org/ns/docbook">
5353- <xsl:apply-templates select="exsl:node-set($buffer)" />
5454- <xsl:apply-templates select="$splitted[1]/node()" />
5555- </para>
5656- <!-- We have already emitted the first splitted result, so the
5757- last result is going to be set as the new $buffer later
5858- because its contents may not be directly followed up by a
5959- $parbreak. -->
6060- <xsl:for-each select="$splitted[position() > 1
6161- and position() < last()]">
6262- <para xmlns="http://docbook.org/ns/docbook">
6363- <xsl:apply-templates select="node()" />
6464- </para>
6565- </xsl:for-each>
6666- <xsl:call-template name="break-up-description">
6767- <xsl:with-param name="input" select="$tail" />
6868- <xsl:with-param name="buffer" select="$splitted[last()]/node()" />
6969- </xsl:call-template>
7070- </xsl:when>
7171- <!-- Either non-text node or one without $parbreak, which we just
7272- want to buffer and continue recursing. -->
7373- <xsl:when test="$input">
7474- <xsl:call-template name="break-up-description">
7575- <xsl:with-param name="input" select="$tail" />
7676- <!-- This essentially appends $head to $buffer. -->
7777- <xsl:with-param name="buffer">
7878- <xsl:if test="$buffer">
7979- <xsl:for-each select="exsl:node-set($buffer)">
8080- <xsl:apply-templates select="." />
8181- </xsl:for-each>
8282- </xsl:if>
8383- <xsl:apply-templates select="$head" />
8484- </xsl:with-param>
8585- </xsl:call-template>
8686- </xsl:when>
8787- <!-- No more $input, just put the remaining $buffer in a para. -->
8888- <xsl:otherwise>
8989- <para xmlns="http://docbook.org/ns/docbook">
9090- <xsl:apply-templates select="exsl:node-set($buffer)" />
9191- </para>
9292- </xsl:otherwise>
9393- </xsl:choose>
9494- </xsl:template>
9595-9696- <xsl:template match="nixos:option-description">
9797- <xsl:choose>
9898- <!--
9999- Only process nodes that are comprised of a single <para/> element,
100100- because if that's not the case the description already contains
101101- </para><para> in between and we need no further processing.
102102- -->
103103- <xsl:when test="count(db:para) > 1">
104104- <xsl:apply-templates select="node()" />
105105- </xsl:when>
106106- <xsl:otherwise>
107107- <xsl:call-template name="break-up-description">
108108- <xsl:with-param name="input"
109109- select="exsl:node-set(db:para/node())" />
110110- </xsl:call-template>
111111- </xsl:otherwise>
112112- </xsl:choose>
113113- </xsl:template>
114114-115115-</xsl:stylesheet>
+4-26
nixos/modules/misc/documentation.nix
···107107 } >&2
108108 '';
109109110110- inherit (cfg.nixos.options) warningsAreErrors allowDocBook;
110110+ inherit (cfg.nixos.options) warningsAreErrors;
111111 };
112112113113···160160 (mkRenamedOptionModule [ "programs" "info" "enable" ] [ "documentation" "info" "enable" ])
161161 (mkRenamedOptionModule [ "programs" "man" "enable" ] [ "documentation" "man" "enable" ])
162162 (mkRenamedOptionModule [ "services" "nixosManual" "enable" ] [ "documentation" "nixos" "enable" ])
163163+ (mkRemovedOptionModule
164164+ [ "documentation" "nixos" "options" "allowDocBook" ]
165165+ "DocBook option documentation is no longer supported")
163166 ];
164167165168 options = {
···264267 '';
265268 };
266269267267- nixos.options.allowDocBook = mkOption {
268268- type = types.bool;
269269- default = true;
270270- description = lib.mdDoc ''
271271- Whether to allow DocBook option docs. When set to `false` all option using
272272- DocBook documentation will cause a manual build error; additionally a new
273273- renderer may be used.
274274-275275- ::: {.note}
276276- The `false` setting for this option is not yet fully supported. While it
277277- should work fine and produce the same output as the previous toolchain
278278- using DocBook it may not work in all circumstances. Whether markdown option
279279- documentation is allowed is independent of this option.
280280- :::
281281- '';
282282- };
283283-284270 nixos.options.warningsAreErrors = mkOption {
285271 type = types.bool;
286272 default = true;
···358344359345 (mkIf cfg.nixos.enable {
360346 system.build.manual = manual;
361361-362362- system.activationScripts.check-manual-docbook = ''
363363- if [[ $(cat ${manual.optionsUsedDocbook}) = 1 ]]; then
364364- echo -e "\e[31;1mwarning\e[0m: This configuration contains option documentation in docbook." \
365365- "Support for docbook is deprecated and will be removed after NixOS 23.05." \
366366- "See nix-store --read-log ${builtins.unsafeDiscardStringContext manual.optionsJSON.drvPath}"
367367- fi
368368- '';
369347370348 environment.systemPackages = []
371349 ++ optional cfg.man.enable manual.manpages