How is the NixOS module documentation generated?

So I see that the mkOption function has a documentation field, and that the manual and search.nixos.org are generated from them. I’m wanting to integrate the documentation into a project I’m working on , but I can’t quite figure out how the documentation fields are actually consumed by these tools. Does anyone have any idea?

You could use the function pkgs.nixosOptionsDoc to generate various files containing option descriptions. There are also some documentation in https://github.com/NixOS/nixpkgs/blob/db21819e91aee7d2bc2edb5845bdad65cddb5cee/nixos/lib/make-options-doc/default.nix

You may want to have a look at nmd. It is a standalone version of the NixOS documentation system that I put together for Home Manager and my NUR, with some additions to support AsciiDoc.

2 Likes

Are you looking for the import scripts for search.nixos.org? They’re here: nixos-search/channel.py at 7c89b2349cfb7e9d7374bebdbff5b592ff5f0802 · NixOS/nixos-search · GitHub

Thanks everyone for the pointers. My goal is to generate an interactive nix module editor that provides structured editing and help for options as you’re editing. This will help me get all the option data in one place.