Release NixOS 23.11
[NixPkgs.git] / lib / tests / modules / alias-with-priority.nix
bloba35a06fc6974931ffee770d742afd2d1be2f8ee1
1 # This is a test to show that mkAliasOptionModule sets the priority correctly
2 # for aliased options.
4 # This test shows that an alias with a low priority is able to be overridden
5 # with a non-aliased option.
7 { config, lib, ... }:
9 with lib;
12   options = {
13     # A simple boolean option that can be enabled or disabled.
14     enable = lib.mkOption {
15       type = types.nullOr types.bool;
16       default = null;
17       example = true;
18       description = ''
19         Some descriptive text
20       '';
21     };
23     # mkAliasOptionModule sets warnings, so this has to be defined.
24     warnings = mkOption {
25       internal = true;
26       default = [];
27       type = types.listOf types.str;
28       example = [ "The `foo' service is deprecated and will go away soon!" ];
29       description = ''
30         This option allows modules to show warnings to users during
31         the evaluation of the system configuration.
32       '';
33     };
34   };
36   imports = [
37     # Create an alias for the "enable" option.
38     (mkAliasOptionModule [ "enableAlias" ] [ "enable" ])
40     # Disable the aliased option, but with a default (low) priority so it
41     # should be able to be overridden by the next import.
42     ( { config, lib, ... }:
43       {
44         enableAlias = lib.mkDefault false;
45       }
46     )
48     # Enable the normal (non-aliased) option.
49     ( { config, lib, ... }:
50       {
51         enable = true;
52       }
53     )
54   ];