lol

lib/tests: Check for nested option-dependent definitions

+42
+3
lib/tests/modules.sh
··· 189 189 checkConfigOutput true config.enable ./define-option-dependently.nix ./declare-enable.nix ./declare-int-positive-value.nix 190 190 checkConfigOutput 360 config.value ./define-option-dependently.nix ./declare-enable.nix ./declare-int-positive-value.nix 191 191 checkConfigOutput 7 config.value ./define-option-dependently.nix ./declare-int-positive-value.nix 192 + checkConfigOutput true config.set.enable ./define-option-dependently-nested.nix ./declare-enable-nested.nix ./declare-int-positive-value-nested.nix 193 + checkConfigOutput 360 config.set.value ./define-option-dependently-nested.nix ./declare-enable-nested.nix ./declare-int-positive-value-nested.nix 194 + checkConfigOutput 7 config.set.value ./define-option-dependently-nested.nix ./declare-int-positive-value-nested.nix 192 195 193 196 # Check attrsOf and lazyAttrsOf. Only lazyAttrsOf should be lazy, and only 194 197 # attrsOf should work with conditional definitions
+14
lib/tests/modules/declare-enable-nested.nix
··· 1 + { lib, ... }: 2 + 3 + { 4 + options.set = { 5 + enable = lib.mkOption { 6 + default = false; 7 + example = true; 8 + type = lib.types.bool; 9 + description = '' 10 + Some descriptive text 11 + ''; 12 + }; 13 + }; 14 + }
+9
lib/tests/modules/declare-int-positive-value-nested.nix
··· 1 + { lib, ... }: 2 + 3 + { 4 + options.set = { 5 + value = lib.mkOption { 6 + type = lib.types.ints.positive; 7 + }; 8 + }; 9 + }
+16
lib/tests/modules/define-option-dependently-nested.nix
··· 1 + { lib, options, ... }: 2 + 3 + # Some modules may be distributed separately and need to adapt to other modules 4 + # that are distributed and versioned separately. 5 + { 6 + 7 + # Always defined, but the value depends on the presence of an option. 8 + config.set = { 9 + value = if options ? set.enable then 360 else 7; 10 + } 11 + # Only define if possible. 12 + // lib.optionalAttrs (options ? set.enable) { 13 + enable = true; 14 + }; 15 + 16 + }