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

Show sub options of freeform types #97042

Merged
merged 2 commits into from Sep 7, 2020

Conversation

infinisil
Copy link
Member

@infinisil infinisil commented Sep 3, 2020

Motivation for this change

Previously if you set the freeform type (as introduced in #82743) to e.g. attrsOf (submodule ..), those submodule options wouldn't be shown in the manual.

Originally this problem was brought to my attention by @alexarice

With an option declaration like

{ lib, ... }: {
  options.foofoofoo = lib.mkOption {
    type = lib.types.submodule {
      freeformType = lib.types.attrsOf (lib.types.submodule {
        options.bar = lib.mkOption {
          description = "Freeform bar";
        };
      });
      options.qux.bar = lib.mkOption {
        description = "Qux bar";
      };
      options.bar = lib.mkOption {
        description = "Submodule bar";
      };
    };
  };
}

The manual now correctly shows

2020-09-03_21-17

Ping @roberth

Things done
  • Checked that the manual still builds
  • Checked that even more complex cases like freeformType = attrsOf (attrsOf (submodule { freeformType = attrsOf ... work
  • Added a test for checking that submodule options are present

Previously if you set the freeform type to e.g. attrsOf (submodule ..),
those submodule options wouldn't be shown in the manual.
@infinisil infinisil added the 6.topic: module system About NixOS module system internals label Sep 3, 2020
Copy link
Member

@roberth roberth left a comment

Choose a reason for hiding this comment

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

Suggestion and it would be nice to have a simple test case for this.

@alexarice
Copy link
Contributor

Just checked out the change on my code and seems to work well. Thanks @infinisil

Only nitpick is the following:
screenshot46

Is there a way to stop this top level package appearing in the documentation?

@infinisil
Copy link
Member Author

@roberth Added a test for that

@alexarice Not possible as of now, but I'll keep this use case in mind if I happen to touch the relevant code for it :)

@infinisil infinisil merged commit f73b762 into NixOS:master Sep 7, 2020
@infinisil infinisil deleted the freeform-option-docs branch September 7, 2020 17:33
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

3 participants