-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
lib/types: Introduce lazyAttrsOf #70138
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
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
130a0c9
lib/modules: Move the isDefined check into mergedValue
infinisil d5a2922
nixos/doc: Note that attrsOf is strict in its values
infinisil 4268b4f
lib/types: Add emptyValue attribute to types
infinisil b48717d
lib/types: Introduce lazyAttrsOf
infinisil ab10e87
lib/tests: Add tests for attrsOf and lazyAttrsOf
infinisil 9e97e64
lib/modules: Switch _module.args from attrsOf to lazyAttrsOf
infinisil 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,7 @@ | ||
| { lib, config, ... }: { | ||
| options.conditionalWorks = lib.mkOption { | ||
| default = ! config.value ? foo; | ||
| }; | ||
|
|
||
| config.value.foo = lib.mkIf false "should not be defined"; | ||
| } |
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,7 @@ | ||
| { lib, config, ... }: { | ||
| options.isLazy = lib.mkOption { | ||
| default = ! config.value ? foo; | ||
| }; | ||
|
|
||
| config.value.bar = throw "is not lazy"; | ||
| } |
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,6 @@ | ||
| { lib, ... }: { | ||
| options.value = lib.mkOption { | ||
| type = lib.types.attrsOf lib.types.str; | ||
| default = {}; | ||
| }; | ||
| } |
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,6 @@ | ||
| { lib, ... }: { | ||
| options.value = lib.mkOption { | ||
| type = lib.types.lazyAttrsOf (lib.types.str // { emptyValue.value = "empty"; }); | ||
| default = {}; | ||
| }; | ||
| } |
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -352,6 +352,36 @@ | |||||
| An attribute set of where all the values are of | ||||||
| <replaceable>t</replaceable> type. Multiple definitions result in the | ||||||
| joined attribute set. | ||||||
| <note><para> | ||||||
| This type is <emphasis>strict</emphasis> in its values, which in turn | ||||||
| means attributes cannot depend on other attributes. See <varname> | ||||||
| types.lazyAttrsOf</varname> for a lazy version. | ||||||
| </para></note> | ||||||
| </para> | ||||||
| </listitem> | ||||||
| </varlistentry> | ||||||
| <varlistentry> | ||||||
| <term> | ||||||
| <varname>types.lazyAttrsOf</varname> <replaceable>t</replaceable> | ||||||
| </term> | ||||||
| <listitem> | ||||||
| <para> | ||||||
| An attribute set of where all the values are of | ||||||
| <replaceable>t</replaceable> type. Multiple definitions result in the | ||||||
| joined attribute set. This is the lazy version of <varname>types.attrsOf | ||||||
|
||||||
| joined attribute set. This is the lazy version of <varname>types.attrsOf | |
| merged attribute set where duplicate attributes are merged according to <replaceable>t</replaceable>. This is a lazy version of <varname>types.attrsOf |
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.
Uh oh!
There was an error while loading. Please reload this page.