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
Merged

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.
Copy link
Contributor

@roberth roberth left a comment

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

@alexarice
Copy link
Contributor

@alexarice alexarice commented Sep 4, 2020

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

@Infinisil Infinisil commented Sep 4, 2020

@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
16 checks passed
16 checks passed
tests tests
Details
action
Details
Evaluation Performance Report Evaluator Performance Report
Details
Wait for ofborg
Details
grahamcofborg-eval ^.^!
Details
grahamcofborg-eval-check-meta config.nix: checkMeta = true
Details
grahamcofborg-eval-darwin nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="f320dba"; rev="f320dbae41cf875ea669b2a8b6083bf2a54f70ce"; } ./pkgs/t
Details
grahamcofborg-eval-lib-tests nix-build --arg pkgs import ./. {} ./lib/tests/release.nix
Details
grahamcofborg-eval-nixos nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="f320dba"; rev="f320dbae41cf875ea669b2a8b6083bf2a54f70ce"; } ./nixos/
Details
grahamcofborg-eval-nixos-manual nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="f320dba"; rev="f320dbae41cf875ea669b2a8b6083bf2a54f70ce"; } ./nixos/
Details
grahamcofborg-eval-nixos-options nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="f320dba"; rev="f320dbae41cf875ea669b2a8b6083bf2a54f70ce"; } ./nixos/
Details
grahamcofborg-eval-nixpkgs-manual nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="f320dba"; rev="f320dbae41cf875ea669b2a8b6083bf2a54f70ce"; } ./pkgs/t
Details
grahamcofborg-eval-nixpkgs-tarball nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="f320dba"; rev="f320dbae41cf875ea669b2a8b6083bf2a54f70ce"; } ./pkgs/t
Details
grahamcofborg-eval-nixpkgs-unstable-jobset nix-instantiate --arg nixpkgs { outPath=./.; revCount=999999; shortRev="f320dba"; rev="f320dbae41cf875ea669b2a8b6083bf2a54f70ce"; } ./pkgs/t
Details
grahamcofborg-eval-package-list nix-env -qa --json --file .
Details
grahamcofborg-eval-package-list-no-aliases nix-env -qa --json --file . --arg config { allowAliases = false; }
Details
@Infinisil Infinisil deleted the Infinisil:freeform-option-docs branch Sep 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.