Skip to content

put all option docs build flavors on equal footing#147265

Merged
infinisil merged 4 commits intoNixOS:masterfrom
pennae:option-docs-build
Dec 8, 2021
Merged

put all option docs build flavors on equal footing#147265
infinisil merged 4 commits intoNixOS:masterfrom
pennae:option-docs-build

Conversation

@pennae
Copy link
Contributor

@pennae pennae commented Nov 24, 2021

Motivation for this change

in #142040 the option docs generation was changed to not sort options.xml in the nix build. in that spirit also stop generating ascii doc and MD doc in nix, and farm that out to scripts too. to make this easier we standardize on options.json as the primary source of options documentation, generating options.xml from options.json when needed. (hopefully docbook will go away soon 🤞)

this may slightly slow down the system build. the optionsDocBook build is definitely impacted, but the full system build seems to not be (or within the noise level of our measurements).

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 21.11 Release Notes (or backporting 21.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: documentation This PR adds or changes documentation labels Nov 24, 2021
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Nov 24, 2021
@Artturin Artturin requested a review from domenkozar November 24, 2021 16:43
@pennae
Copy link
Contributor Author

pennae commented Nov 26, 2021

to set a stage for this a little, this is part of an effort to cache most of the options doc build as well. json is much easier to merge than the xml output nix produces, and caching parts of the doc build requires merging options descriptions. the MD and asciidoc changes happened to line up with the need to make json the primary export format for option docs so they ended up converted as well.

Copy link
Member

@jtojnar jtojnar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just few nits.

use the json file derivation we already have to also generate the asciidoc and
md options docs instead of formatting the options in nix. docbook docs are
already produced in derivations.

the new script produce the exact same output as the old in-nix generation.
there are no remaining users of sorted option lists except the docbook build,
which sorts its input separately.
to do this we must replace derivations with attrsets in make-options-doc, since
xml can represent derivations differently from attrset but json cannot. this
also given asciidoc and mddoc the ability to handle derivation differently,
which they previously didn't have.
Copy link
Member

@jtojnar jtojnar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks.

@pennae pennae mentioned this pull request Dec 8, 2021
13 tasks
Copy link
Member

@infinisil infinisil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty neat!



<xsl:template match="derivation">
<xsl:template match="attrs[attr[@name = '_type' and string[@value = 'derivation']]]">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this change for?

Copy link
Contributor Author

@pennae pennae Dec 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nix xml makes a distinction between derivations and attrsets, but json can't. to get around this we instead format derivations as a _typed special value here, like options and examples are handled already

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense!

@infinisil infinisil merged commit 15c41e1 into NixOS:master Dec 8, 2021
@sternenseemann
Copy link
Member

sternenseemann commented Dec 14, 2021

Breaks NixOS with Nix 2.3, see #150623.

@pennae pennae deleted the option-docs-build branch December 14, 2021 04:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: documentation This PR adds or changes documentation 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants