2019-01-06 10:10:03 +01:00
|
|
|
# This is a test to show that mkAliasOptionModule sets the priority correctly
|
|
|
|
# for aliased options.
|
2019-02-07 02:33:48 +01:00
|
|
|
#
|
|
|
|
# This test shows that an alias with a high priority is able to override
|
|
|
|
# a non-aliased option.
|
2019-01-06 10:10:03 +01:00
|
|
|
|
|
|
|
{ config, lib, ... }:
|
|
|
|
|
2024-03-11 16:37:31 +01:00
|
|
|
let
|
|
|
|
inherit (lib)
|
|
|
|
mkAliasOptionModule
|
|
|
|
mkForce
|
|
|
|
mkOption
|
|
|
|
types
|
|
|
|
;
|
|
|
|
in
|
2019-01-06 10:10:03 +01:00
|
|
|
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
# A simple boolean option that can be enabled or disabled.
|
2024-03-11 16:37:31 +01:00
|
|
|
enable = mkOption {
|
2019-01-06 10:10:03 +01:00
|
|
|
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.
|
2019-01-24 04:58:33 +01:00
|
|
|
(mkAliasOptionModule [ "enableAlias" ] [ "enable" ])
|
2019-01-06 10:10:03 +01:00
|
|
|
|
2019-02-07 02:33:48 +01:00
|
|
|
# Disable the aliased option with a high priority so it
|
|
|
|
# should override the next import.
|
2019-01-06 10:10:03 +01:00
|
|
|
( { config, lib, ... }:
|
|
|
|
{
|
2024-03-11 16:37:31 +01:00
|
|
|
enableAlias = mkForce false;
|
2019-01-06 10:10:03 +01:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
# Enable the normal (non-aliased) option.
|
|
|
|
( { config, lib, ... }:
|
|
|
|
{
|
|
|
|
enable = true;
|
|
|
|
}
|
|
|
|
)
|
|
|
|
];
|
|
|
|
}
|