aboutsummaryrefslogtreecommitdiff
path: root/lib/tests/modules
diff options
context:
space:
mode:
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
commitda00ec4b45f5cfc5b47825818b57db1d1950757d (patch)
treee80d02ce5915077c39c1a332ab0261f88e02823e /lib/tests/modules
parentd4910911e28cfea443da86c7fec823b7298468a1 (diff)
Add a failing test for mkAliasOptionModule.
Diffstat (limited to 'lib/tests/modules')
-rw-r--r--lib/tests/modules/alias-with-priority.nix52
1 files changed, 52 insertions, 0 deletions
diff --git a/lib/tests/modules/alias-with-priority.nix b/lib/tests/modules/alias-with-priority.nix
new file mode 100644
index 000000000000..ba25b527aa2d
--- /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;
+ }
+ )
+ ];
+}