-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
Introduce types.raw
#160489
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
Merged
Merged
Introduce types.raw
#160489
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| { lib, ... }: { | ||
|
|
||
| options = { | ||
| processedToplevel = lib.mkOption { | ||
| type = lib.types.raw; | ||
| }; | ||
| unprocessedNesting = lib.mkOption { | ||
| type = lib.types.raw; | ||
| }; | ||
| multiple = lib.mkOption { | ||
| type = lib.types.raw; | ||
| }; | ||
| priorities = lib.mkOption { | ||
| type = lib.types.raw; | ||
| }; | ||
| }; | ||
|
|
||
| config = { | ||
| processedToplevel = lib.mkIf true 10; | ||
| unprocessedNesting.foo = throw "foo"; | ||
| multiple = lib.mkMerge [ | ||
| "foo" | ||
| "foo" | ||
| ]; | ||
| priorities = lib.mkMerge [ | ||
| "foo" | ||
| (lib.mkForce "bar") | ||
| ]; | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,6 +63,17 @@ merging is handled. | |
| ``` | ||
| ::: | ||
|
|
||
| `types.raw` | ||
|
|
||
| : 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. | ||
|
Comment on lines
+68
to
+75
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @roberth Does this sound good? |
||
|
|
||
| `types.attrs` | ||
|
|
||
| : A free-form attribute set. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 itstypeattr before returning it is a cheap and one-time operation.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I don't think we should trade the ability to
mkForcein_module.argsfor arguably no benefit.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #160489 (comment),
mkForceand co. still work on the spineThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the confusion comes from #132448 where
types.raworiginally 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