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

nixosOptionsDoc generates config for the built-in module system option _module.args. #293510

Open
frederictobiasc opened this issue Mar 5, 2024 · 0 comments
Labels
0.kind: bug Something is broken 6.topic: documentation Meta-discussion about documentation and its workflow 6.topic: module system About "NixOS" module system internals

Comments

@frederictobiasc
Copy link
Contributor

Describe the bug

Generating module options documentation with nixosOptionsDoc generates config for the built-in module system option _module.args since b9756b4.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Create minimal example:
# generate-doc.nix
with import <nixpkgs> {};
  {}: let
    eval = lib.evalModules {
      specialArgs = {inherit pkgs;};
      modules = [(_: {_module.check = false;})];
    };
    optionsDoc = nixosOptionsDoc {
      inherit (eval) options;
    };
  in
    runCommand "options-doc.md" {} ''
      cat ${optionsDoc.optionsCommonMark} > $out
    ''
  1. Run nix-build generate-doc.nix
  2. Observe that result contains a chapter about _module.args

Expected behavior

An empty result, like prior to b9756b4.

Alternatively documentation at nixosOptionsDoc about how to disable generating documentation for built-in options.

Additional context

I wonder what is the best way of hiding the built-in module system options from docs.

Ways I came up with:

User filters the eval result

  eval = lib.evalModules {
    specialArgs = {inherit pkgs;};
    modules = [ (_: {_module.check = false;}) ];
  };

  cleanEval = lib.filterAttrsRecursive (n: v: n != "_module") eval;

User makes _module.args internal

# my-module.nix
{ ... }: {
  options._module.args = lib.mkOption {
    internal = true;
  };
  ...
}

Extend nixosOptionsDoc with a filter

See #293494

Notify maintainers

@asymmetric @ryantm

Metadata

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.1.79, NixOS, 24.05 (Uakari), 24.05pre-git`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.1`
 - channels(root): `"home-manager, nixos"`
 - channels(istobic): `""`
 - nixpkgs: `/home/istobic/.nix-defexpr/channels/nixpkgs`

Add a 👍 reaction to issues you find important.

@frederictobiasc frederictobiasc added the 0.kind: bug Something is broken label Mar 5, 2024
@infinisil infinisil added the 6.topic: module system About "NixOS" module system internals label Mar 6, 2024
@frederictobiasc frederictobiasc added the 6.topic: documentation Meta-discussion about documentation and its workflow label Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken 6.topic: documentation Meta-discussion about documentation and its workflow 6.topic: module system About "NixOS" module system internals
Projects
None yet
Development

No branches or pull requests

2 participants