Navigation Menu

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

lib/options: Only recurse into visible sub options #82897

Merged
merged 1 commit into from Mar 19, 2020

Conversation

infinisil
Copy link
Member

Motivation for this change

Fixes #82862, which was introduced with #78135

Confirmed this works with a config.nix like this:

{ pkgs, config, lib, ... }: with lib;
{

  imports = [
    (lib.mkRenamedOptionModule [ "oldoldoldold" ] [ "newnewnewnew" ])
  ];

  options.newnewnewnew = lib.mkOption {
    type = types.attrsOf (types.submodule {
      options.subsubsubsub = lib.mkOption {
        type = types.str;
        default = "test";
        description = "hello";
      };
    });
    default = {};
    description = "bar";
  };

  config.documentation.nixos.includeAllModules = true;

  config.boot.loader.grub.device = "nodev";
  config.fileSystems."/".device = "test";
}

Then building the manual and opening it:

$ nix-build nixos --arg configuration ./config.nix -A config.system.build.manual.manualHTML
$ xdg-open result/share/doc/nixos/options.html

And then searching for the string subsubsubsub. Before this PR it would occur once under oldoldoldold.<name>.subsubsubsub and once under newnewnewnew.<name>.subsubsubsub, but only the latter of which is present after this PR.

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.

Works. Will backport.

@roberth roberth merged commit 9b3515e into NixOS:master Mar 19, 2020
@infinisil infinisil deleted the fix-recursive-visible-docs branch April 2, 2020 05:56
infinisil added a commit that referenced this pull request Dec 18, 2020
Initially #82897 prevented
non-visible options from being rendered in the manual, but
visible-but-internal options were still being recursed into. This fixes
this, aligning the recurse condition here with the one in
make-options-doc/default.nix
infinisil added a commit to infinisil/nixpkgs that referenced this pull request Mar 4, 2022
lib/options: Don't show internal suboption in the manual

Initially NixOS#82897 prevented
non-visible options from being rendered in the manual, but
visible-but-internal options were still being recursed into. This fixes
this, aligning the recurse condition here with the one in
make-options-doc/default.nix

lib/modules: Implement module-builtin assertions

This implements assertions/warnings supported by the module system directly,
instead of just being a NixOS option (see
nixos/modules/misc/assertions.nix).

This has the following benefits:
- It allows cleanly redoing the user interface. The new
  implementation specifically allows disabling assertions or
  converting them to warnings instead.
- Assertions/warnings can now be thrown easily from within
  submodules, which previously wasn't possible and needed workarounds.

nixos/assertions: Use module-builtin assertion implementation

lib/modules: Use module-builtin assertions for mkRemovedOptionModule and co.

nixos/modules: Allow options to be coerced to a string for convenience

nixos/modules: Expose the internal module in the top-level documentation

nixos/docs: Update assertion docs for new module-builtin ones

lib/tests: Implement generalized checkConfigCodeOutErr for module tests

lib/tests: Add tests for module-builtin assertions

lib/modules: Rename _module.assertions to _module.checks

lib/modules: Remove _module.checks.*.triggerPath as it's not necessary

Previously this option was thought to be necessary to avoid infinite
recursion, but it actually isn't, since the check evaluation isn't fed
back into the module fixed-point.

lib/modules: _module.check should always be internal

Honestly this option should probably just be removed

lib/modules: Introduce _module.checks.*.check

Previously the .enable option was used to encode the condition as well,
which lead to some oddness:
- In order to encode an assertion, one had to invert it
- To disable a check, one had to mkForce it

By introducing a separate .check option this is solved because:
- It can be used to encode assertions
- Disabling is done separately with .enable option, whose default can be
  overridden without a mkForce

lib/modules: Prefix mkRemovedOptionModule & co. check names

To avoid name clashes

Co-authored-by: Robert Hensing <robert@roberthensing.nl>

bla
github-actions bot pushed a commit to nix-community/nixpkgs.lib that referenced this pull request Dec 4, 2022
Initially NixOS/nixpkgs#82897 prevented
non-visible options from being rendered in the manual, but
visible-but-internal options were still being recursed into. This fixes
this, aligning the recurse condition here with the one in
make-options-doc/default.nix
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.

Deprecated child options appear in manual when renaming submodule
2 participants