From e9f9e2dab1274664683887df3f1c1405c64de58f Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Sun, 17 Aug 2025 20:42:40 +0200 Subject: [PATCH] doc: Add Modules, modules.generic.meta-maintainers --- doc/doc-support/package.nix | 32 ++++++++++++++++++++++++++++++++ doc/manual.md.in | 1 + doc/modules/generic.chapter.md | 16 ++++++++++++++++ doc/modules/index.md | 12 ++++++++++++ doc/redirects.json | 9 +++++++++ 5 files changed, 70 insertions(+) create mode 100644 doc/modules/generic.chapter.md create mode 100644 doc/modules/index.md diff --git a/doc/doc-support/package.nix b/doc/doc-support/package.nix index 8ed6865a1c90..8e5651864d48 100644 --- a/doc/doc-support/package.nix +++ b/doc/doc-support/package.nix @@ -15,12 +15,43 @@ markdown-code-runner, roboto, treefmt, + nixosOptionsDoc, }: stdenvNoCC.mkDerivation ( finalAttrs: let inherit (finalAttrs.finalPackage.optionsDoc) optionsJSON; inherit (finalAttrs.finalPackage) epub lib-docs pythonInterpreterTable; + + # Make anything from lib (the module system internals) invisible + hide-lib = + opt: + opt + // { + visible = if lib.all (decl: decl == "lib/modules.nix") opt.declarations then false else opt.visible; + }; + + toURL = + decl: + let + declStr = toString decl; + root = toString (../..); + subpath = lib.removePrefix "/" (lib.removePrefix root declStr); + in + if lib.hasPrefix root declStr then + { + url = "https://github.com/NixOS/nixpkgs/blob/master/${subpath}"; + name = "nixpkgs/${subpath}"; + } + else + decl; + + mapURLs = opt: opt // { declarations = map toURL opt.declarations; }; + + docs.generic.meta-maintainers = nixosOptionsDoc { + inherit (lib.evalModules { modules = [ ../../modules/generic/meta-maintainers.nix ]; }) options; + transformOptions = opt: hide-lib (mapURLs opt); + }; in { name = "nixpkgs-manual"; @@ -49,6 +80,7 @@ stdenvNoCC.mkDerivation ( ln -s ${optionsJSON}/share/doc/nixos/options.json ./config-options.json ln -s ${treefmt.functionsDoc.markdown} ./packages/treefmt-functions.section.md ln -s ${treefmt.optionsDoc.optionsJSON}/share/doc/nixos/options.json ./treefmt-options.json + ln -s ${docs.generic.meta-maintainers.optionsJSON}/share/doc/nixos/options.json ./options-modules-generic-meta-maintainers.json ''; buildPhase = '' diff --git a/doc/manual.md.in b/doc/manual.md.in index 160c6eaead3c..8d75d0fe459e 100644 --- a/doc/manual.md.in +++ b/doc/manual.md.in @@ -11,6 +11,7 @@ lib.md stdenv.md toolchains.md build-helpers.md +modules/index.md development.md contributing.md interoperability.md diff --git a/doc/modules/generic.chapter.md b/doc/modules/generic.chapter.md new file mode 100644 index 000000000000..2a14812160e0 --- /dev/null +++ b/doc/modules/generic.chapter.md @@ -0,0 +1,16 @@ + +# Generic {#modules-generic} + +Generic modules can be imported to extend configurations of any [class]. + +## `meta-maintainers.nix` {#modules-generic-meta-maintainers} + +The options below become available when using `imports = [ (nixpkgs + "/modules/generic/meta-maintainers.nix") ];`. + +```{=include=} options +id-prefix: opt-modules-generic-meta-maintainers- +list-id: configuration-variable-list +source: ../options-modules-generic-meta-maintainers.json +``` + +[class]: https://nixos.org/manual/nixpkgs/unstable/#module-system-lib-evalModules-param-class diff --git a/doc/modules/index.md b/doc/modules/index.md new file mode 100644 index 000000000000..af4897f11d6d --- /dev/null +++ b/doc/modules/index.md @@ -0,0 +1,12 @@ +# Modules {#modules} + +The Nixpkgs repository provides [Module System] modules for various purposes. + +The following sections are organized by [module class]. + +```{=include=} chapters +generic.chapter.md +``` + +[Module System]: https://nixos.org/manual/nixpkgs/unstable/#module-system +[module class]: https://nixos.org/manual/nixpkgs/unstable/#module-system-lib-evalModules-param-class diff --git a/doc/redirects.json b/doc/redirects.json index 8f7810698bbc..215f10bfc640 100644 --- a/doc/redirects.json +++ b/doc/redirects.json @@ -130,6 +130,15 @@ "minor-ghc-deprecation": [ "index.html#minor-ghc-deprecation" ], + "modules": [ + "index.html#modules" + ], + "modules-generic": [ + "index.html#modules-generic" + ], + "modules-generic-meta-maintainers": [ + "index.html#modules-generic-meta-maintainers" + ], "neovim": [ "index.html#neovim" ],