Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos: doc: include all modules in manual generation #56020

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/options.nix
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ rec {
docOption = rec {
loc = opt.loc;
name = showOption opt.loc;
description = opt.description or (throw "Option `${name}' has no description.");
description = opt.description or (lib.warn "Option `${name}' has no description." "This option has no description.");
declarations = filter (x: x != unknownModule) opt.declarations;
internal = opt.internal or false;
visible = opt.visible or true;
Expand Down
1 change: 1 addition & 0 deletions nixos/doc/manual/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ in rec {
# Generate manpages.
mkdir -p $out/share/man
xsltproc --nonet \
--maxdepth 6000 \
--param man.output.in.separate.dir 1 \
--param man.output.base.dir "'$out/share/man/'" \
--param man.endnotes.are.numbered 0 \
Expand Down
12 changes: 11 additions & 1 deletion nixos/doc/manual/release-notes/rl-1909.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,17 @@

<itemizedlist>
<listitem>
<para />
<para>
The <option>documentation</option> module gained an option named
<option>documentation.nixos.includeAllModules</option> which makes the generated
<citerefentry><refentrytitle>configuration.nix</refentrytitle>
<manvolnum>5</manvolnum></citerefentry> manual page include all options from all NixOS modules
included in a given <literal>configuration.nix</literal> configuration file. Currently, it is
set to <literal>false</literal> by default as enabling it frequently prevents evaluation. But
the plan is to eventually have it set to <literal>true</literal> by default. Please set it to
<literal>true</literal> now in your <literal>configuration.nix</literal> and fix all the bugs
it uncovers.
</para>
</listitem>
</itemizedlist>
</section>
Expand Down
4 changes: 2 additions & 2 deletions nixos/lib/eval-config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ in rec {
# system configuration.
inherit (lib.evalModules {
inherit prefix check;
modules = modules ++ extraModules ++ baseModules ++ [ pkgsModule ];
modules = baseModules ++ extraModules ++ [ pkgsModule ] ++ modules;
Copy link
Contributor

Choose a reason for hiding this comment

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

what is the rational here? AFAIK modules don't depend on their order.

args = extraArgs;
specialArgs =
{ modulesPath = builtins.toString ../modules; } // specialArgs;
Expand All @@ -60,7 +60,7 @@ in rec {
# These are the extra arguments passed to every module. In
# particular, Nixpkgs is passed through the "pkgs" argument.
extraArgs = extraArgs_ // {
inherit modules baseModules;
inherit baseModules extraModules modules;
};

inherit (config._module.args) pkgs;
Expand Down
17 changes: 15 additions & 2 deletions nixos/modules/misc/documentation.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{ config, lib, pkgs, baseModules, ... }:
{ config, lib, pkgs, baseModules, extraModules, modules, ... }:

with lib;

let

cfg = config.documentation;

manualModules = baseModules ++ optionals cfg.nixos.includeAllModules (extraModules ++ modules);
Copy link
Contributor

Choose a reason for hiding this comment

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

This ignores pkgsModule module. Why ignore that?


/* For the purpose of generating docs, evaluate options with each derivation
in `pkgs` (recursively) replaced by a fake with path "\${pkgs.attribute.path}".
It isn't perfect, but it seems to cover a vast majority of use cases.
Expand All @@ -18,7 +20,7 @@ let
options =
let
scrubbedEval = evalModules {
modules = [ { nixpkgs.localSystem = config.nixpkgs.localSystem; } ] ++ baseModules;
modules = [ { nixpkgs.localSystem = config.nixpkgs.localSystem; } ] ++ manualModules;
args = (config._module.args) // { modules = [ ]; };
specialArgs = { pkgs = scrubDerivations "pkgs" pkgs; };
};
Expand Down Expand Up @@ -146,6 +148,17 @@ in
'';
};

nixos.includeAllModules = mkOption {
type = types.bool;
default = false;
description = ''
Whether the generated NixOS's documentation should include documentation for all
the options from all the NixOS modules included in the current
<literal>configuration.nix</literal>. Disabling this will make the manual
generator to ignore options defined outside of <literal>baseModules</literal>.
'';
};

};

};
Expand Down