diff options
author | (cdep)illabout <cdep.illabout@gmail.com> | 2019-01-04 16:34:59 +0900 |
---|---|---|
committer | (cdep)illabout <cdep.illabout@gmail.com> | 2019-01-04 18:34:09 +0900 |
commit | da00ec4b45f5cfc5b47825818b57db1d1950757d (patch) | |
tree | e80d02ce5915077c39c1a332ab0261f88e02823e /lib | |
parent | d4910911e28cfea443da86c7fec823b7298468a1 (diff) | |
download | nixpkgs-da00ec4b45f5cfc5b47825818b57db1d1950757d.tar nixpkgs-da00ec4b45f5cfc5b47825818b57db1d1950757d.tar.gz nixpkgs-da00ec4b45f5cfc5b47825818b57db1d1950757d.tar.bz2 nixpkgs-da00ec4b45f5cfc5b47825818b57db1d1950757d.tar.lz nixpkgs-da00ec4b45f5cfc5b47825818b57db1d1950757d.tar.xz nixpkgs-da00ec4b45f5cfc5b47825818b57db1d1950757d.tar.zst nixpkgs-da00ec4b45f5cfc5b47825818b57db1d1950757d.zip |
Add a failing test for mkAliasOptionModule.
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/tests/modules.sh | 3 | ||||
-rw-r--r-- | lib/tests/modules/alias-with-priority.nix | 52 |
2 files changed, 55 insertions, 0 deletions
diff --git a/lib/tests/modules.sh b/lib/tests/modules.sh index b83e1eb7d82..45f39178522 100755 --- a/lib/tests/modules.sh +++ b/lib/tests/modules.sh @@ -149,6 +149,9 @@ checkConfigOutput "1 2 3 4 5 6 7 8 9 10" config.result ./loaOf-with-long-list.ni # Check loaOf with many merges of lists. checkConfigOutput "1 2 3 4 5 6 7 8 9 10" config.result ./loaOf-with-many-list-merges.nix +# Check mkAliasOptionModuleWithPriority. +checkConfigOutput "true" config.enable ./alias-with-priority.nix + cat <<EOF ====== module tests ====== $pass Pass diff --git a/lib/tests/modules/alias-with-priority.nix b/lib/tests/modules/alias-with-priority.nix new file mode 100644 index 00000000000..ba25b527aa2 --- /dev/null +++ b/lib/tests/modules/alias-with-priority.nix @@ -0,0 +1,52 @@ +# This is a test to show that mkAliasOptionModule sets the priority correctly +# for aliased options. + +{ config, lib, ... }: + +with lib; + +{ + options = { + # A simple boolean option that can be enabled or disabled. + enable = lib.mkOption { + type = types.nullOr types.bool; + default = null; + example = true; + description = '' + Some descriptive text + ''; + }; + + # mkAliasOptionModule sets warnings, so this has to be defined. + warnings = mkOption { + internal = true; + default = []; + type = types.listOf types.str; + example = [ "The `foo' service is deprecated and will go away soon!" ]; + description = '' + This option allows modules to show warnings to users during + the evaluation of the system configuration. + ''; + }; + }; + + imports = [ + # Create an alias for the "enable" option. + (mkAliasOptionModule [ "enableAlias" ] [ "enable" ]) + + # Disable the aliased option, but with a default (low) priority so it + # should be able to be overridden by the next import. + ( { config, lib, ... }: + { + enableAlias = lib.mkDefault false; + } + ) + + # Enable the normal (non-aliased) option. + ( { config, lib, ... }: + { + enable = true; + } + ) + ]; +} |