Skip to content

RFC42-style options that default to unset, to have no attribute in config despite option #158594

@roberth

Description

@roberth

When defining an option in an RFC42-style free-form settings module, say settings.foo, the module system always creates a config.settings.foo value containing the default value.

Some configuration formats require that config definitions are omitted in order to get the default behavior. Filtering those out of the config is unpleasant at least and as far as I know we don't have a standard solution for it.

We could add a mkOption argument that has the effect of producing no default value and no config attribute when no definitions are present for the option.

This will allow us to simplify modules that need to elide unset options and it lowers the threshold for defining options within a settings module, improving documentation and merge semantics.

Notify maintainers

@infinisil

Additional context

This idea has come up in #112494 as well, but I'm not convinced that it isn't feasible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: enhancementAdd something new or improve an existing system.2.status: stalehttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md6.topic: module systemAbout "NixOS" module system internals
    No fields configured for issues without a type.

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions