1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-12-11 11:31:03 +01:00

doc: make HTML manual build optional

Add `html-manual` Meson option to allow building manpages without the
HTML manual, removing the mdbook dependency for manpage-only builds.

Changes:
- Add `html-manual` Meson option (default: true)
- Make HTML manual build conditional in meson.build
- Add `buildHtmlManual` parameter to package.nix
- Conditional outputs: ["out" "man"] when enabled, ["out"] when disabled
- Make mdbook/rsync/json-schema-for-humans dependencies conditional
- Add `nix-manual-manpages-only` package variant

This allows systems that only need manpages to avoid the mdbook build
dependency while preserving full functionality for HTML manual builds.
This commit is contained in:
Robert Hensing 2025-12-06 21:16:29 +01:00
parent cca8b5ca60
commit ab0ca5f922
7 changed files with 167 additions and 123 deletions

View file

@ -21,9 +21,13 @@ endif
nix = find_program('nix', native : true) nix = find_program('nix', native : true)
mdbook = find_program('mdbook', native : true)
bash = find_program('bash', native : true) bash = find_program('bash', native : true)
# HTML manual dependencies (conditional)
if get_option('html-manual')
mdbook = find_program('mdbook', native : true)
rsync = find_program('rsync', required : true, native : true) rsync = find_program('rsync', required : true, native : true)
endif
pymod = import('python') pymod = import('python')
python = pymod.find_installation('python3') python = pymod.find_installation('python3')
@ -109,6 +113,8 @@ else
nix_input = [] nix_input = []
endif endif
# HTML manual build (conditional)
if get_option('html-manual')
manual = custom_target( manual = custom_target(
'manual', 'manual',
command : [ command : [
@ -158,6 +164,7 @@ manual = custom_target(
'markdown', 'markdown',
], ],
depfile : 'manual.d', depfile : 'manual.d',
build_by_default : true,
env : { env : {
'RUST_LOG' : 'info', 'RUST_LOG' : 'info',
'MDBOOK_SUBSTITUTE_SEARCH' : meson.current_build_dir() / 'source', 'MDBOOK_SUBSTITUTE_SEARCH' : meson.current_build_dir() / 'source',
@ -170,6 +177,7 @@ install_subdir(
manual_html.full_path(), manual_html.full_path(),
install_dir : get_option('datadir') / 'doc/nix', install_dir : get_option('datadir') / 'doc/nix',
) )
endif
nix_nested_manpages = [ nix_nested_manpages = [
[ [

View file

@ -4,3 +4,10 @@ option(
value : true, value : true,
description : 'Whether this is an official release build (affects documentation URLs)', description : 'Whether this is an official release build (affects documentation URLs)',
) )
option(
'html-manual',
type : 'boolean',
value : true,
description : 'Whether to build the HTML manual (requires mdbook)',
)

View file

@ -19,6 +19,11 @@
# Configuration Options # Configuration Options
version, version,
/**
Whether to build the HTML manual.
When false, only manpages are built, avoiding the mdbook dependency.
*/
buildHtmlManual ? true,
# `tests` attribute # `tests` attribute
testers, testers,
@ -57,9 +62,22 @@ mkMesonDerivation (finalAttrs: {
../../doc/manual/package.nix; ../../doc/manual/package.nix;
# TODO the man pages should probably be separate # TODO the man pages should probably be separate
outputs = [ outputs =
if buildHtmlManual then
[
"out" "out"
"man" "man"
]
else
[ "out" ]; # Only one output when HTML manual is disabled; use "out" for manpages
# When HTML manual is disabled, install manpages to "out" instead of "man"
mesonFlags = [
(lib.mesonBool "official-release" officialRelease)
(lib.mesonBool "html-manual" buildHtmlManual)
]
++ lib.optionals (!buildHtmlManual) [
"--mandir=${placeholder "out"}/share/man"
]; ];
nativeBuildInputs = [ nativeBuildInputs = [
@ -67,41 +85,40 @@ mkMesonDerivation (finalAttrs: {
meson meson
ninja ninja
(lib.getBin lowdown-unsandboxed) (lib.getBin lowdown-unsandboxed)
mdbook
jq jq
python3 python3
]
++ lib.optionals buildHtmlManual [
mdbook
rsync rsync
json-schema-for-humans json-schema-for-humans
changelog-d
] ]
++ lib.optionals (!officialRelease) [ ++ lib.optionals (!officialRelease && buildHtmlManual) [
# When not an official release, we likely have changelog entries that have # When not an official release, we likely have changelog entries that have
# yet to be rendered. # yet to be rendered.
# When released, these are rendered into a committed file to save a dependency. # When released, these are rendered into a committed file to save a dependency.
changelog-d changelog-d
]; ];
mesonFlags = [
(lib.mesonBool "official-release" officialRelease)
];
preConfigure = '' preConfigure = ''
chmod u+w ./.version chmod u+w ./.version
echo ${finalAttrs.version} > ./.version echo ${finalAttrs.version} > ./.version
''; '';
postInstall = '' postInstall = lib.optionalString buildHtmlManual ''
mkdir -p ''$out/nix-support mkdir -p ''$out/nix-support
echo "doc manual ''$out/share/doc/nix/manual" >> ''$out/nix-support/hydra-build-products echo "doc manual ''$out/share/doc/nix/manual" >> ''$out/nix-support/hydra-build-products
''; '';
passthru = lib.optionalAttrs buildHtmlManual {
/** /**
The root of the HTML manual. The root of the HTML manual.
E.g. "${nix-manual.site}/index.html" exists. E.g. "${nix-manual.site}/index.html" exists.
*/ */
passthru.site = finalAttrs.finalPackage + "/share/doc/nix/manual";
passthru.tests = site = finalAttrs.finalPackage + "/share/doc/nix/manual";
tests =
let let
redirect-targets = callPackage ./redirect-targets-html.nix { }; redirect-targets = callPackage ./redirect-targets-html.nix { };
in in
@ -129,6 +146,7 @@ mkMesonDerivation (finalAttrs: {
}; };
}; };
}; };
};
meta = { meta = {
platforms = lib.platforms.all; platforms = lib.platforms.all;

View file

@ -35,6 +35,7 @@ endforeach
json_schema_generated_files = [] json_schema_generated_files = []
if json_schema_for_humans.found()
# Generate markdown documentation from JSON schema # Generate markdown documentation from JSON schema
# Note: output must be just a filename, not a path # Note: output must be just a filename, not a path
gen_file = custom_target( gen_file = custom_target(
@ -55,7 +56,6 @@ gen_file = custom_target(
) )
idx = 0 idx = 0
if json_schema_for_humans.found()
foreach schema_name : schemas foreach schema_name : schemas
#schema_file = 'schema' / schema_name + '.yaml' #schema_file = 'schema' / schema_name + '.yaml'

View file

@ -369,6 +369,7 @@
# TODO probably should be `nix-cli` # TODO probably should be `nix-cli`
nix = self.packages.${system}.nix-everything; nix = self.packages.${system}.nix-everything;
nix-manual = nixpkgsFor.${system}.native.nixComponents2.nix-manual; nix-manual = nixpkgsFor.${system}.native.nixComponents2.nix-manual;
nix-manual-manpages-only = nixpkgsFor.${system}.native.nixComponents2.nix-manual-manpages-only;
nix-internal-api-docs = nixpkgsFor.${system}.native.nixComponents2.nix-internal-api-docs; nix-internal-api-docs = nixpkgsFor.${system}.native.nixComponents2.nix-internal-api-docs;
nix-external-api-docs = nixpkgsFor.${system}.native.nixComponents2.nix-external-api-docs; nix-external-api-docs = nixpkgsFor.${system}.native.nixComponents2.nix-external-api-docs;
} }

View file

@ -429,6 +429,15 @@ in
The manual as would be published on https://nix.dev/reference/nix-manual The manual as would be published on https://nix.dev/reference/nix-manual
*/ */
nix-manual = callPackage ../doc/manual/package.nix { version = fineVersion; }; nix-manual = callPackage ../doc/manual/package.nix { version = fineVersion; };
/**
Manpages only (no HTML manual, no mdbook dependency)
*/
nix-manual-manpages-only = callPackage ../doc/manual/package.nix {
version = fineVersion;
buildHtmlManual = false;
};
/** /**
Doxygen pages for C++ code Doxygen pages for C++ code
*/ */

View file

@ -70,6 +70,7 @@ let
] ]
++ lib.optionals enableDocs [ ++ lib.optionals enableDocs [
"nix-manual" "nix-manual"
"nix-manual-manpages-only"
"nix-internal-api-docs" "nix-internal-api-docs"
"nix-external-api-docs" "nix-external-api-docs"
] ]