diff options
author | Robert Hensing <robert@roberthensing.nl> | 2020-03-17 20:21:10 +0100 |
---|---|---|
committer | Robert Hensing <robert@roberthensing.nl> | 2020-03-17 20:21:10 +0100 |
commit | 31206e44e128926cb04a6e1c023f07c41541ee7f (patch) | |
tree | 34af6b62a7baa6c8abfd19cfd25c442c384b782f /lib/tests/modules | |
parent | b6a5079800f520c3e30bd285c84d67643c973f42 (diff) | |
download | nixpkgs-31206e44e128926cb04a6e1c023f07c41541ee7f.tar nixpkgs-31206e44e128926cb04a6e1c023f07c41541ee7f.tar.gz nixpkgs-31206e44e128926cb04a6e1c023f07c41541ee7f.tar.bz2 nixpkgs-31206e44e128926cb04a6e1c023f07c41541ee7f.tar.lz nixpkgs-31206e44e128926cb04a6e1c023f07c41541ee7f.tar.xz nixpkgs-31206e44e128926cb04a6e1c023f07c41541ee7f.tar.zst nixpkgs-31206e44e128926cb04a6e1c023f07c41541ee7f.zip |
lib/modules: Test the ability for config to depend on options for compatibility
Diffstat (limited to 'lib/tests/modules')
-rw-r--r-- | lib/tests/modules/define-option-dependently.nix | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/tests/modules/define-option-dependently.nix b/lib/tests/modules/define-option-dependently.nix new file mode 100644 index 00000000000..6abce29366a --- /dev/null +++ b/lib/tests/modules/define-option-dependently.nix @@ -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 = { + value = if options ? enable then 360 else 7; + } + # Only define if possible. + // lib.optionalAttrs (options ? enable) { + enable = true; + }; + +} |