-
-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib: Add beforeApply option attribute
See #299736 for the reasons.
- Loading branch information
Showing
3 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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 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,24 @@ | ||
{ options, lib, ... }: | ||
|
||
# Tests wheter a apply function properly generates the `beforeApply` option attribute | ||
|
||
{ | ||
options = { | ||
optionWithoutApply = lib.mkOption { | ||
default = false; | ||
type = lib.types.bool; | ||
}; | ||
|
||
optionWithApply = lib.mkOption { | ||
default = false; | ||
type = lib.types.bool; | ||
apply = x: !x; | ||
}; | ||
|
||
okChecks = lib.mkOption {}; | ||
}; | ||
config.okChecks = builtins.addErrorContext "while evaluating the assertions" ( | ||
assert options.optionWithoutApply.beforeApply == options.optionWithoutApply.value; | ||
assert options.optionWithApply.beforeApply == !options.optionWithApply.value; | ||
true); | ||
} |