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

Conversation

oxij
Copy link
Member

@oxij oxij commented Feb 18, 2019

What? Why?

An edited version of #47177. See commit messages below.

git log

  • nixos: doc: 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 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.

    This was originally implemented in nixos-manual: Include all modules in documentation generation #47177, edited for more configurability and
    rebased onto master by @oxij.

  • nixos: doc: increase maxdepth for xsltproc

    See manual fails to build on master #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
    manual fails to build on master #37903 (comment).

nix-instantiate environment

  • Host OS: Linux 4.9, SLNOS 19.03
  • Nix: nix-env (Nix) 2.1.3
  • Multi-user: yes
  • Sandbox: yes
  • NIXPKGS_CONFIG:
{
  checkMeta = true;
  doCheckByDefault = true;
}

nix-env -qaP diffs

  • On x86_64-linux:

    • Updated (2):
      • tests.nixos-functions.nixos-test
      • tests.nixos-functions.nixosTest-test
  • On aarch64-linux: ditto

  • On x86_64-darwin: noop

/cc original author of #47177 @arianvp, documentation aficionados @grahamc @vcunat

@arianvp
Copy link
Member

arianvp commented Feb 19, 2019

Thanks for moving this forward!

@@ -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.


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?

@oxij
Copy link
Member Author

oxij commented Feb 20, 2019 via email

Copy link
Contributor

@danbst danbst left a comment

Choose a reason for hiding this comment

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

OCD

OK :)

I'd also like things like documentation only for custom modules, documentation only about used options, documentation about only changed options, but this is very out of scope in this context.

@infinisil
Copy link
Member

Can you add a release note for this? I think this very much warrants one

@oxij oxij force-pushed the pull/47177-nixos-doc-include-all-modules-edited branch from b99203c to 6ccd848 Compare February 21, 2019 19:58
@oxij
Copy link
Member Author

oxij commented Feb 21, 2019 via email

@danbst
Copy link
Contributor

danbst commented Feb 21, 2019

I've tried building my system with this patch. Turns out, lots of my custom options are not documented, so I end up in:

error: Option `nixpkgs.latestPackages' has no description.
(use '--show-trace' to show detailed location information)

Fix was easy, add description = ""; to all options, but still it required fixes. Perhaps gradual enable is needed - first add option with false as default, then set it by default true in nixos-generate-config, then change default after a few releases.

@oxij oxij requested a review from edolstra as a code owner February 22, 2019 00:07
@oxij
Copy link
Member Author

oxij commented Feb 22, 2019 via email

@infinisil
Copy link
Member

Testing this on my setup uncovered that nixops' option descriptions apparently don't all evaluate:

error: attribute 'bootstrap' missing, at /nix/store/nsnycm9acirddfdwj0mwiqx88ilwp4mi-nixops-1.6.1pre2728_8ed39f9/share/nix/nixops/gce.nix:343:19

This should be fixed in nixops and nixpkgs' nixopsUnstable should be updated before this can be merged.

@danbst
Copy link
Contributor

danbst commented Mar 5, 2019

Change default to false (with respected release notes changes) and I'll merge. It can even be backported to 19.03.

Because this can fail configuration evaluation, we should warn users first. They update to 19.03, see some red warnings in configuration and know, that option declarations must be fixed before 19.09, because 19.09 will make this behavior default.

This is just an idea. Making default false will make life easier for maintainers.

@oxij oxij force-pushed the pull/47177-nixos-doc-include-all-modules-edited branch 2 times, most recently from 2c5ce91 to ee229ba Compare March 5, 2019 09:35
arianvp and others added 3 commits March 5, 2019 09:41
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 NixOS#47177, edited for more configurability,
documented and rebased onto master by @oxij.
See NixOS#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
NixOS#37903 (comment).
…out descriptions

For convenience, it's not like not having a description is deadly or something.
@oxij oxij force-pushed the pull/47177-nixos-doc-include-all-modules-edited branch from ee229ba to a53b3ba Compare March 5, 2019 09:42
@oxij
Copy link
Member Author

oxij commented Mar 5, 2019 via email

@danbst danbst merged commit 1f409d0 into NixOS:master Mar 5, 2019
@danbst
Copy link
Contributor

danbst commented Mar 5, 2019

thanks @oxij and @arianvp !

@oxij oxij deleted the pull/47177-nixos-doc-include-all-modules-edited branch August 12, 2023 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants