nixos/manual: split manpages-combined from manual-combined

once we generate the entire manual-combined.xml with a single
nixos-render-docs invocation we will no longer need any options xml
files. likewise we do not need the test options xml in the manpage
build. splitting manpages-combined from manual-combined also allows
these two to run in parallel, slightly improving build times.

pennae ef413e3e 9977f997

Changed files
+55 -39
nixos
doc
manual
+55 -39
nixos/doc/manual/default.nix
···
"--stringparam chunk.toc ${toc}"
];
+
linterFunctions = ''
+
# outputs the context of an xmllint error output
+
# LEN lines around the failing line are printed
+
function context {
+
# length of context
+
local LEN=6
+
# lines to print before error line
+
local BEFORE=4
+
+
# xmllint output lines are:
+
# file.xml:1234: there was an error on line 1234
+
while IFS=':' read -r file line rest; do
+
echo
+
if [[ -n "$rest" ]]; then
+
echo "$file:$line:$rest"
+
local FROM=$(($line>$BEFORE ? $line - $BEFORE : 1))
+
# number lines & filter context
+
nl --body-numbering=a "$file" | sed -n "$FROM,+$LEN p"
+
else
+
if [[ -n "$line" ]]; then
+
echo "$file:$line"
+
else
+
echo "$file"
+
fi
+
fi
+
done
+
}
+
+
function lintrng {
+
xmllint --debug --noout --nonet \
+
--relaxng ${docbook5}/xml/rng/docbook/docbook.rng \
+
"$1" \
+
2>&1 | context 1>&2
+
# ^ redirect assumes xmllint doesn’t print to stdout
+
}
+
'';
+
manual-combined = runCommand "nixos-manual-combined"
{ inherit sources;
nativeBuildInputs = [ buildPackages.libxml2.bin buildPackages.libxslt.bin ];
···
${copySources}
xmllint --xinclude --output ./manual-combined.xml ./manual.xml
-
xmllint --xinclude --noxincludenode \
-
--output ./man-pages-combined.xml ./man-pages.xml
-
# outputs the context of an xmllint error output
-
# LEN lines around the failing line are printed
-
function context {
-
# length of context
-
local LEN=6
-
# lines to print before error line
-
local BEFORE=4
-
-
# xmllint output lines are:
-
# file.xml:1234: there was an error on line 1234
-
while IFS=':' read -r file line rest; do
-
echo
-
if [[ -n "$rest" ]]; then
-
echo "$file:$line:$rest"
-
local FROM=$(($line>$BEFORE ? $line - $BEFORE : 1))
-
# number lines & filter context
-
nl --body-numbering=a "$file" | sed -n "$FROM,+$LEN p"
-
else
-
if [[ -n "$line" ]]; then
-
echo "$file:$line"
-
else
-
echo "$file"
-
fi
-
fi
-
done
-
}
-
-
function lintrng {
-
xmllint --debug --noout --nonet \
-
--relaxng ${docbook5}/xml/rng/docbook/docbook.rng \
-
"$1" \
-
2>&1 | context 1>&2
-
# ^ redirect assumes xmllint doesn’t print to stdout
-
}
+
${linterFunctions}
mkdir $out
cp manual-combined.xml $out/
-
cp man-pages-combined.xml $out/
lintrng $out/manual-combined.xml
-
lintrng $out/man-pages-combined.xml
+
'';
+
+
manpages-combined = runCommand "nixos-manpages-combined.xml"
+
{ nativeBuildInputs = [ buildPackages.libxml2.bin buildPackages.libxslt.bin ];
+
meta.description = "The NixOS manpages as plain docbook XML";
+
}
+
''
+
mkdir generated
+
cp -prd ${./man-pages.xml} man-pages.xml
+
ln -s ${optionsDoc.optionsDocBook} generated/options-db.xml
+
+
xmllint --xinclude --noxincludenode --output $out ./man-pages.xml
+
+
${linterFunctions}
+
+
lintrng $out
'';
in rec {
···
--param man.endnotes.are.numbered 0 \
--param man.break.after.slash 1 \
${docbook_xsl_ns}/xml/xsl/docbook/manpages/docbook.xsl \
-
${manual-combined}/man-pages-combined.xml
+
${manpages-combined}
''
else ''
mkdir -p $out/share/man/man5