lib/modules: Add a function to create an option alias that respects the priority

This commit adds a function `mkAliasOptionModuleWithPriority`.  This
function will make an alias to an existing option and copy over the
priority.

This functionality is needed for PRs like #53041.  In that case
`nixos-generate-config` added an option to `hardware-configuration.nix`
with `mkDefault`.  That option was then changed and an alias created for
the old name.

The end user should be able to set the non-alias option in their
`configuration.nix` and have everything work correctly.  Without this
function, the priority for the option won't be copied over correctly
and the end-user will get a message saying they have the same option
set to two different values.
This commit is contained in:
(cdep)illabout
2019-01-03 23:15:01 +09:00
parent da00ec4b45
commit b81b3ad1b0
3 changed files with 29 additions and 5 deletions

View File

@@ -32,7 +32,7 @@ with lib;
imports = [
# Create an alias for the "enable" option.
(mkAliasOptionModule [ "enableAlias" ] [ "enable" ])
(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.