1# This is a test to show that mkAliasOptionModule sets the priority correctly
2# for aliased options.
3#
4# This test shows that an alias with a high priority is able to override
5# a non-aliased option.
6
7{ config, lib, ... }:
8
9let
10 inherit (lib)
11 mkAliasOptionModule
12 mkForce
13 mkOption
14 types
15 ;
16in
17
18{
19 options = {
20 # A simple boolean option that can be enabled or disabled.
21 enable = mkOption {
22 type = types.nullOr types.bool;
23 default = null;
24 example = true;
25 description = ''
26 Some descriptive text
27 '';
28 };
29
30 # mkAliasOptionModule sets warnings, so this has to be defined.
31 warnings = mkOption {
32 internal = true;
33 default = [ ];
34 type = types.listOf types.str;
35 example = [ "The `foo' service is deprecated and will go away soon!" ];
36 description = ''
37 This option allows modules to show warnings to users during
38 the evaluation of the system configuration.
39 '';
40 };
41 };
42
43 imports = [
44 # Create an alias for the "enable" option.
45 (mkAliasOptionModule [ "enableAlias" ] [ "enable" ])
46
47 # Disable the aliased option with a high priority so it
48 # should override the next import.
49 (
50 { config, lib, ... }:
51 {
52 enableAlias = mkForce false;
53 }
54 )
55
56 # Enable the normal (non-aliased) option.
57 (
58 { config, lib, ... }:
59 {
60 enable = true;
61 }
62 )
63 ];
64}