Skip to content

lib.options.optionAttrSetToDocList: add visible = "transparent"#441782

Merged
roberth merged 4 commits intoNixOS:masterfrom
MattSturgeon:doc-option-transparent
Sep 11, 2025
Merged

lib.options.optionAttrSetToDocList: add visible = "transparent"#441782
roberth merged 4 commits intoNixOS:masterfrom
MattSturgeon:doc-option-transparent

Conversation

@MattSturgeon
Copy link
Contributor

@MattSturgeon MattSturgeon commented Sep 10, 2025

It came up in a discussion that there is a way to mark an option as invisible, or an option's sub-options, but not a way to mark an option as invisible without hiding its sub-options.

Technically, you can mark an option as internal, and this will have a similar effect. That's because, currently, optionAttrSetToDocList will not check internal when deciding whether to recurse into sub-options. However that feels like an implementation detail that I'm uncomfortable relying on. According to their docs, visible and internal have subtly different semantics, too; so I'm uncomfortable using them interchangeably.

This PR expands the test suite to explicitly test how optionAttrSetToDocList handles visible and internal, then adds a new visible = "transparent" value. This new value is used to indicate that the option is not visible, but its sub-options are.

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

Add a 👍 reaction to pull requests you find important.

@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 6.topic: module system About "NixOS" module system internals 6.topic: lib The Nixpkgs function library labels Sep 10, 2025
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.

LGTM, and the test is much appreciated.

We now cover the whole (self:Bool × children:Bool) space and while arguably that would be a cleaner representation (with children defaulting to the value of self), but I'd prefer to save that refactor for a major revision where we can implement it without evaluation memory overhead (virtually all docs things under a single mkOption attr).

I did notice duplicate and out of date docs in the NixOS manual, but that's also out of scope for this PR.

So just that one suggestion and then I think it's ready for merge.

@MattSturgeon
Copy link
Contributor Author

I did notice duplicate and out of date docs in the NixOS manual, but that's also out of scope for this PR.

I did a quick grep for "shallow" and didn't find anything, hence why I only touched the nixdoc comments.

Looking closer, there's #sec-option-declarations. It seems like visible and internal are currently undocumented in the manual 👀

Personally, I'd like to remove the duplication and generate docs for functions like this using nixdoc, like we do for (e.g.) most of lib.

roberth and others added 2 commits September 11, 2025 17:00
Allows marking an option as invisible, without excluding its sub-options.

In practice, this is similar to `visible = true; internal = true;`,
however it is more explicit and less reliant on implementation details.
@roberth roberth added this pull request to the merge queue Sep 11, 2025
Merged via the queue into NixOS:master with commit 0bdb5c1 Sep 11, 2025
29 of 31 checks passed
@MattSturgeon MattSturgeon deleted the doc-option-transparent branch September 11, 2025 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: lib The Nixpkgs function library 6.topic: module system About "NixOS" module system internals 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants