lib.types.submodule: deprecate the submodule family#377718
lib.types.submodule: deprecate the submodule family#377718hsjobeki wants to merge 3 commits intoNixOS:masterfrom
Conversation
builtins.warn does abort the evaluation when NIX_ABORT_ON_WARN is set this leads to failing in documentation rendering where nixosOptionsDoc is called with warningsAreErrors=true (default) bigger renames are therefore impossible with lib.warn / builtins.warn The introduction allows for soft deprecation of types without breaking NixOS or downstream documentation tooling
|
I am aware of the problem, and part of me wants to do it, but I believe doing this just isn't worth the human cost of annoying messages and making all the changes. Maybe this could be done in a future where all "non-programming"¹ submodules have become I would definitely block it on #334680 (records) anyway, because it provides a slightly better alternative for many submodules. ¹ I would call use of |
SubconfigurationWe have a naming problem where it's not clear which things are "functions" and which are data Functions:
Value-like, no parameters:
Arguably a submodule is not a module but a configuration, so I would suggest subconfiguration if we were to rename it. (Also fwiw |
So, essentially we're just changing And renaming the option-type to a) draw attention to the semantic change and b) take the opportunity to improve its name. Quoting the manual:
So it always felt strange to me that it was enabled in
While they may solve similar problems in many cases, records and submodules (subconfigurations) are very different tools in the toolbox, IMO. I don't know if I agree that records should block improving how submodules/configurations are dealt with?
Agreed, if a little verbose. |
I don't agree. Is this idea representing the implementation or is it what the user interacts with? What is the difference between a module and a submodule for a user? # A module
{
imports = [];
config = {};
options = {};
}vs a submodule # A submodule
{
imports = [];
config = {};
options = {};
}But maybe i understand this wrong, what is the difference? |
|
Submodules are fundamentally a bit of a weird type.
...So the appropriate name depends on which aspect you wish to describe: Should the name describe the definitions? Or should it describe the final value? Or should it represent the whole thing end-to-end? In my mind, "submodule" represents the definitions well, but it obfuscates what the final value is. I think "sub-configuration" better represents the whole type end-to-end, but I still worry it could be overly verbose or too much jargon. |
This PR adds a graceful trace to
types.submoduieand promotes migrating to the alternative lib.types.module that is introduced here as more well behaved.Problem: as described in #377575
The following code behaves inconsistently.
While using the exact same code
submoduleWithresolves theimports.Alternatives considered:
config.importsProblems:
config.configandconfig.optionsfor the same reason. Which is again unclear how many usages it has and how to deprecate it.Cons:
submodulehas about ~1050 occurrences in .nix files in nixpkgs.submoduleWithhas about 20 occurrencessubmodulehas potentially 21k occurrences in .nix files only on github (https://github.com/search?q=lang%3Anix+%2F%28%5C.%2B%7C%5Cs%2B%29submodule%5Cs%2F&type=code)submoduleis well established in the communityPros:
types.moduleis gracefulconfig.importsandconfig.optionsvia shorthand, must double check)Compare the type
modulevssubmodule. Why should the type of amodulebe different that thesubmodule? In fact all module are submodules. So why the name of the type suggests something else?type Module :: { imports :: ListOf Module; config :: ...; options :: ...; }and
evalModules :: { module :: ListOf Module; } -> Configuration(not sure about the result. but the point about the name should be clear)I am also very divided on this topic. And seeking for advice how to actively improve the situation.
Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.