nixos manual: extract some build paths

Co-authored-by: Shahar "Dawn" Or <mightyiampresence@gmail.com>
This commit is contained in:
Alejandro Sanchez Medina 2023-07-13 11:28:19 +02:00 committed by Shahar "Dawn" Or
parent 13aeddb926
commit a49d40a005
2 changed files with 13 additions and 7 deletions

View file

@ -0,0 +1,4 @@
{
outputPath = "share/doc/nixos";
indexPath = "index.html";
}

View file

@ -16,6 +16,8 @@ let
lib = pkgs.lib; lib = pkgs.lib;
common = import ./common.nix;
manpageUrls = pkgs.path + "/doc/manpage-urls.json"; manpageUrls = pkgs.path + "/doc/manpage-urls.json";
# We need to strip references to /nix/store/* from options, # We need to strip references to /nix/store/* from options,
@ -78,11 +80,11 @@ let
substituteInPlace ./nixos-options.md \ substituteInPlace ./nixos-options.md \
--replace \ --replace \
'@NIXOS_OPTIONS_JSON@' \ '@NIXOS_OPTIONS_JSON@' \
${optionsDoc.optionsJSON}/share/doc/nixos/options.json ${optionsDoc.optionsJSON}/${common.outputPath}/options.json
substituteInPlace ./development/writing-nixos-tests.section.md \ substituteInPlace ./development/writing-nixos-tests.section.md \
--replace \ --replace \
'@NIXOS_TEST_OPTIONS_JSON@' \ '@NIXOS_TEST_OPTIONS_JSON@' \
${testOptionsDoc.optionsJSON}/share/doc/nixos/options.json ${testOptionsDoc.optionsJSON}/${common.outputPath}/options.json
sed -e '/@PYTHON_MACHINE_METHODS@/ {' -e 'r ${testDriverMachineDocstrings}/machine-methods.md' -e 'd' -e '}' \ sed -e '/@PYTHON_MACHINE_METHODS@/ {' -e 'r ${testDriverMachineDocstrings}/machine-methods.md' -e 'd' -e '}' \
-i ./development/writing-nixos-tests.section.md -i ./development/writing-nixos-tests.section.md
''; '';
@ -99,7 +101,7 @@ in rec {
} }
'' ''
# Generate the HTML manual. # Generate the HTML manual.
dst=$out/share/doc/nixos dst=$out/${common.outputPath}
mkdir -p $dst mkdir -p $dst
cp ${../../../doc/style.css} $dst/style.css cp ${../../../doc/style.css} $dst/style.css
@ -120,7 +122,7 @@ in rec {
--toc-depth 1 \ --toc-depth 1 \
--chunk-toc-depth 1 \ --chunk-toc-depth 1 \
./manual.md \ ./manual.md \
$dst/index.html $dst/${common.indexPath}
mkdir -p $out/nix-support mkdir -p $out/nix-support
echo "nix-build out $out" >> $out/nix-support/hydra-build-products echo "nix-build out $out" >> $out/nix-support/hydra-build-products
@ -131,7 +133,7 @@ in rec {
manual = manualHTML; manual = manualHTML;
# Index page of the NixOS manual. # Index page of the NixOS manual.
manualHTMLIndex = "${manualHTML}/share/doc/nixos/index.html"; manualHTMLIndex = "${manualHTML}/${common.outputPath}/${common.indexPath}";
manualEpub = runCommand "nixos-manual-epub" manualEpub = runCommand "nixos-manual-epub"
{ nativeBuildInputs = [ buildPackages.libxml2.bin buildPackages.libxslt.bin buildPackages.zip ]; { nativeBuildInputs = [ buildPackages.libxml2.bin buildPackages.libxslt.bin buildPackages.zip ];
@ -162,7 +164,7 @@ in rec {
} }
'' ''
# Generate the epub manual. # Generate the epub manual.
dst=$out/share/doc/nixos dst=$out/${common.outputPath}
xsltproc \ xsltproc \
--param chapter.autolabel 0 \ --param chapter.autolabel 0 \
@ -197,7 +199,7 @@ in rec {
mkdir -p $out/share/man/man5 mkdir -p $out/share/man/man5
nixos-render-docs -j $NIX_BUILD_CORES options manpage \ nixos-render-docs -j $NIX_BUILD_CORES options manpage \
--revision ${lib.escapeShellArg revision} \ --revision ${lib.escapeShellArg revision} \
${optionsJSON}/share/doc/nixos/options.json \ ${optionsJSON}/${common.outputPath}/options.json \
$out/share/man/man5/configuration.nix.5 $out/share/man/man5/configuration.nix.5
''; '';