Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 456f09d76fca
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1f409d0879e4
Choose a head ref
  • 4 commits
  • 5 files changed
  • 3 contributors

Commits on Mar 5, 2019

  1. nixos: doc: optionally include all modules in manual generation

    Before this change `man 5 configuration.nix` would only show options of modules in
    the `baseModules` set, which consists only of the list of modules in
    `nixos/modules/module-list.nix`
    
    With this change applied and `documentation.nixos.includeAllModules` option enabled
    all modules included in `configuration.nix` file will be used instead.
    
    This makes configurations with custom modules self-documenting. It also means
    that importing non-`baseModules` modules like `gce.nix` or `azure.nix`
    will make their documentation available in `man 5 configuration.nix`.
    
    `documentation.nixos.includeAllModules` is currently set to `false` by
    default as enabling it usually uncovers bugs and prevents evaluation.
    It should be set to `true` in a release or two.
    
    This was originally implemented in #47177, edited for more configurability,
    documented and rebased onto master by @oxij.
    arianvp authored and oxij committed Mar 5, 2019
    Copy the full SHA
    2e75a7b View commit details
  2. nixos: doc: increase maxdepth for xsltproc

    See #37903 (comment)
    for details. With the previous patch and some custom modules included in
    `configuration.nix` the above bug is very easy to trigger.
    
    This is a simplest workaround I have. A proper solution would look like
    #37903 (comment).
    oxij committed Mar 5, 2019
    Copy the full SHA
    ca496b1 View commit details
  3. lib: optionAttrSetToDocList: warn instead of throwing on options with…

    …out descriptions
    
    For convenience, it's not like not having a description is deadly or something.
    oxij committed Mar 5, 2019
    Copy the full SHA
    a53b3ba View commit details
  4. Merge pull request #56020 from oxij/pull/47177-nixos-doc-include-all-…

    …modules-edited
    
    nixos: doc: include all modules in manual generation
    danbst authored Mar 5, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    1f409d0 View commit details
Showing with 30 additions and 6 deletions.
  1. +1 −1 lib/options.nix
  2. +1 −0 nixos/doc/manual/default.nix
  3. +11 −1 nixos/doc/manual/release-notes/rl-1909.xml
  4. +2 −2 nixos/lib/eval-config.nix
  5. +15 −2 nixos/modules/misc/documentation.nix
2 changes: 1 addition & 1 deletion lib/options.nix
Original file line number Diff line number Diff line change
@@ -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;
1 change: 1 addition & 0 deletions nixos/doc/manual/default.nix
Original file line number Diff line number Diff line change
@@ -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 \
12 changes: 11 additions & 1 deletion nixos/doc/manual/release-notes/rl-1909.xml
Original file line number Diff line number Diff line change
@@ -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>
4 changes: 2 additions & 2 deletions nixos/lib/eval-config.nix
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@ in rec {
# system configuration.
inherit (lib.evalModules {
inherit prefix check;
modules = modules ++ extraModules ++ baseModules ++ [ pkgsModule ];
modules = baseModules ++ extraModules ++ [ pkgsModule ] ++ modules;
args = extraArgs;
specialArgs =
{ modulesPath = builtins.toString ../modules; } // specialArgs;
@@ -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;
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);

/* 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.
@@ -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; };
};
@@ -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>.
'';
};

};

};