lib/tests: Check for nested option-dependent definitions
This commit is contained in:
parent
9eecf2d057
commit
742e3fc002
|
@ -189,6 +189,9 @@ checkConfigOutput "true" config.enable ./import-from-store.nix
|
|||
checkConfigOutput true config.enable ./define-option-dependently.nix ./declare-enable.nix ./declare-int-positive-value.nix
|
||||
checkConfigOutput 360 config.value ./define-option-dependently.nix ./declare-enable.nix ./declare-int-positive-value.nix
|
||||
checkConfigOutput 7 config.value ./define-option-dependently.nix ./declare-int-positive-value.nix
|
||||
checkConfigOutput true config.set.enable ./define-option-dependently-nested.nix ./declare-enable-nested.nix ./declare-int-positive-value-nested.nix
|
||||
checkConfigOutput 360 config.set.value ./define-option-dependently-nested.nix ./declare-enable-nested.nix ./declare-int-positive-value-nested.nix
|
||||
checkConfigOutput 7 config.set.value ./define-option-dependently-nested.nix ./declare-int-positive-value-nested.nix
|
||||
|
||||
# Check attrsOf and lazyAttrsOf. Only lazyAttrsOf should be lazy, and only
|
||||
# attrsOf should work with conditional definitions
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
{ lib, ... }:
|
||||
|
||||
{
|
||||
options.set = {
|
||||
enable = lib.mkOption {
|
||||
default = false;
|
||||
example = true;
|
||||
type = lib.types.bool;
|
||||
description = ''
|
||||
Some descriptive text
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
{ lib, ... }:
|
||||
|
||||
{
|
||||
options.set = {
|
||||
value = lib.mkOption {
|
||||
type = lib.types.ints.positive;
|
||||
};
|
||||
};
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
{ lib, options, ... }:
|
||||
|
||||
# Some modules may be distributed separately and need to adapt to other modules
|
||||
# that are distributed and versioned separately.
|
||||
{
|
||||
|
||||
# Always defined, but the value depends on the presence of an option.
|
||||
config.set = {
|
||||
value = if options ? set.enable then 360 else 7;
|
||||
}
|
||||
# Only define if possible.
|
||||
// lib.optionalAttrs (options ? set.enable) {
|
||||
enable = true;
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in New Issue