Skip to content

Make mdBook dependency optional (#14548), fix manpage links#14727

Merged
Ericson2314 merged 3 commits intoNixOS:masterfrom
roberth:issue-14548
Dec 6, 2025
Merged

Make mdBook dependency optional (#14548), fix manpage links#14727
Ericson2314 merged 3 commits intoNixOS:masterfrom
roberth:issue-14548

Conversation

@roberth
Copy link
Member

@roberth roberth commented Dec 6, 2025

Motivation

The first commit prepares the codebase for mdbook to be actually optional, because the manpages were previously derived from mdBook markdown output, which I found both surprising and explainable.
It reinvents the wheel a bit, but that's what you get for picking markdown; a better solution did not exist.

The second commit is nice side catch: URLs in the manpages now refer to the website, instead of broken relative paths.

The third commit implements #14548.

Context


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

Add standalone markdown preprocessor to generate manpages without requiring
mdbook's Rust toolchain. This removes a significant build dependency for
manpage generation while keeping the HTML manual (mdbook) working unchanged.

Changes:
- Add expand-includes.py: Python 3 script that recursively expands
  {{#include}} directives, resolves @docroot@ to nix.dev URLs, and handles
  @generated@/ paths for build-generated files
- Update render-manpage.sh: Replace mdbook-based implementation with
  standalone version that uses expand-includes.py + lowdown
- Update meson.build: All 134 manpage targets now use standalone renderer
  with proper dependencies (expand-includes.py, experimental-features-shortlist)
- Fix nix-hash.md: Remove extra parenthesis in markdown link syntax

Benefits:
- No mdbook/Rust toolchain required for manpage builds
- Manpages contain nix.dev/latest URLs instead of broken relative paths
- Fixes bug where mdbook didn't expand experimental-features-shortlist.md
- 98.5% identical output to mdbook (2 files differ, both acceptable)

All 134 manpages (131 section 1, 2 section 5, 1 section 8) build successfully.
@roberth roberth force-pushed the issue-14548 branch 2 times, most recently from 3e44dfd to 3ed5c1e Compare December 6, 2025 20:53
Add configurable documentation URLs that change based on whether this is
an official release or development build:

- Nix builds:
  - Development (officialRelease = false): Use /latest/ URLs
  - Official releases (officialRelease = true): Use versioned URLs with
    MAJOR.MINOR only (e.g., /2.33/ instead of /2.33.0/)
- Plain meson builds: Default to versioned URLs (official-release = true)

Changes:
- Add --doc-url parameter to expand-includes.py
- Add meson option 'official-release' (defaults to true for Meson builds)
- Compute doc_url in meson.build based on version and official-release
- Forward Nix officialRelease variable to Meson in package.nix
- Update render-manpage.sh to pass doc-url parameter

This allows distros (Fedora, etc.) to have stable versioned URLs by default,
while Nix development builds point to /latest/ for up-to-date documentation.
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.
@Ericson2314 Ericson2314 added this pull request to the merge queue Dec 6, 2025
Merged via the queue into NixOS:master with commit 42d7d96 Dec 6, 2025
16 checks passed
@edolstra edolstra mentioned this pull request Dec 9, 2025
@fricklerhandwerk
Copy link
Contributor

fricklerhandwerk commented Feb 9, 2026

@roberth lowdown can be told not to render relative links for a while now: kristapsdz/lowdown#105

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

could mdbook be made an optional dependency?

3 participants