diff options
author | (cdep)illabout <cdep.illabout@gmail.com> | 2019-01-06 18:10:03 +0900 |
---|---|---|
committer | (cdep)illabout <cdep.illabout@gmail.com> | 2019-01-06 18:10:03 +0900 |
commit | 7314d885a1547d3db6b0447fbeb3bcb1ff7f13de (patch) | |
tree | 3bb96a64cce1c70ed6e6c321a3b4d01b48a852fd /lib/tests/modules | |
parent | f24e2d0721c99acf84220d8ba56c66e422687669 (diff) |
Add test that shows that the aliases are able to override options.
Diffstat (limited to 'lib/tests/modules')
-rw-r--r-- | lib/tests/modules/alias-with-priority-can-override.nix | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/lib/tests/modules/alias-with-priority-can-override.nix b/lib/tests/modules/alias-with-priority-can-override.nix new file mode 100644 index 000000000000..a6b26895f3a8 --- /dev/null +++ b/lib/tests/modules/alias-with-priority-can-override.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. + (mkAliasOptionModuleWithPriority [ "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.mkForce false; + } + ) + + # Enable the normal (non-aliased) option. + ( { config, lib, ... }: + { + enable = true; + } + ) + ]; +} |