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

Generate nix.settings module options from the code #8419

Open
roberth opened this issue May 30, 2023 · 2 comments
Open

Generate nix.settings module options from the code #8419

roberth opened this issue May 30, 2023 · 2 comments
Labels
feature Feature request or proposal settings Settings, global flags, nix.conf

Comments

@roberth
Copy link
Member

roberth commented May 30, 2023

Is your feature request related to a problem? Please describe.

NixOS implements RFC 42 settings for /etc/nix/nix.conf, but that duplicates the C++ settings code defined here.

Describe the solution you'd like

A subcommand that dumps module options, or a file in $out/share/nix.
This can then be vendored by NixOS, so that all options are documented in the NixOS option search, have sensible merging behavior, etc.

Describe alternatives you've considered

Status quo or remove the options. This would be bad UX, for a lack of search and a lack of merging (for users with a split config, but also for predefined configs, profiles).

Additional context

Priorities

Add 👍 to issues you find important.

@roberth roberth added the feature Feature request or proposal label May 30, 2023
@polykernel
Copy link
Contributor

polykernel commented May 30, 2023

I think nix show-config --json currently dumps out a structured JSON object for each Setting consisting of its alias, description, default value and some other information(an important piece of information missing is the type). In theory, it should be possible to parse this result in the NixOS module to generate the option tree(if the type information is provided). That being said, I think eventually moving towards something like a JSON schema would be more robust.

A side note, I was a bit surprised by this behavior from nix show-config. I expected the the --json flag to return a JSON object with keys being the setting names and the values being setting values. The manpage simply says Produce output in JSON format, suitable for consumption by another program. which I think is a bit unclear if this is the intended behavior.

@roberth
Copy link
Member Author

roberth commented May 30, 2023

The ingredient that's missing from nix show-config --json is the type info.
Those are non-trivial to represent. They could be represented using JSON schema, as @polykernel suggests, or a representation of a module system type AST. The latter seems easiest to translate into a functioning option type.

@roberth roberth added the settings Settings, global flags, nix.conf label May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Feature request or proposal settings Settings, global flags, nix.conf
Projects
None yet
Development

No branches or pull requests

2 participants