Conversation
roberth
left a comment
There was a problem hiding this comment.
Not sure.
Is this the only use case?
lib/modules.nix
Outdated
There was a problem hiding this comment.
I don't think this is the right trade-off. It's already lazy and when you do access an attr value, like that of pkgs, you'll force it anyway. Checking its type attr before returning it is a cheap and one-time operation.
There was a problem hiding this comment.
OfBorg just finished. Allocations are down by 0.0002%
https://github.com/NixOS/nixpkgs/pull/160489/checks?check_run_id=5236802082
There was a problem hiding this comment.
So I don't think we should trade the ability to mkForce in _module.args for arguably no benefit.
There was a problem hiding this comment.
See #160489 (comment), mkForce and co. still work on the spine
There was a problem hiding this comment.
I must have read too much into "raw".
The tests demonstrate it clearly.
Perhaps the docs can clarify that it's not entirely raw?
There was a problem hiding this comment.
I guess the confusion comes from #132448 where types.raw originally worked like that, not doing any processing at all, but I changed that after discussing it with you :)
I think mentioning that in the docs is a good idea
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
|
@roberth This type still works with let lib = import ./lib; in
lib.evalModules {
modules = [
{
options.foo = lib.mkOption {
type = lib.types.raw;
};
config.foo = lib.mkMerge [
(lib.mkIf false 10)
20
(lib.mkIf true (lib.mkForce 30))
];
}
];
}
The main use case for Other than We also need to deprecate |
This one seems valid. |
There was a problem hiding this comment.
I think what's important is that
- it doesn't merge or check
- it does apply priorities
- it should be used if and only if merging and checking are not desirable
"Especially useful" and "recommended" are a bit too encouraging for something that should be applied with attention.
There was a problem hiding this comment.
Sounds good, I updated the docs
Fixes NixOS#53458, as types.raw doesn't allow setting multiple values
| : A type which doesn't do any checking, merging or nested evaluation. It | ||
| accepts a single arbitrary value that is not recursed into, making it | ||
| useful for values coming from outside the module system, such as package | ||
| sets or arbitrary data. Options of this type are still evaluated according | ||
| to priorities and conditionals, so `mkForce`, `mkIf` and co. still work on | ||
| the option value itself, but not for any value nested within it. This type | ||
| should only be used when checking, merging and nested evaluation are not | ||
| desirable. |
|
As expected, this broke my config because I was adding my own stuff to Probably just a "me" problem not worth looking into as I couldn't reproduce that error on a minimal config. |
|
I'd like |
|
Yeah, I guess it's supposed to be a middle ground between |
|
As a general rule, The systemd logic can move into importable modules instead, after #156533 |
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/tweag-nix-dev-update-25/18003/1 |
Motivation for this change
types.rawas a type that doesn't do any nested processing formkIf,mkForce, etc. on its values. This is useful when this processing would throw errors or where it would be too expensive (such as with package sets like nixpkgs).types.rawfor_module.args's type. This finally fixes _module.args.name gets merged on assignment #53458This is split off from #132448. This is also motivated by wanting to deprecate
types.attrsandtypes.unspecified, for whichtypes.attrsOf types.rawandtypes.raw(ortypes.anything) is an adequate general replacement.Things done