Merge pull request #54528 from cdepillabout/module-alias-uses-priority
lib/modules: Change mkAliasOptionModule to use the priority for the alias
This commit is contained in:
commit
d3216be6d9
@ -109,7 +109,7 @@ let
|
|||||||
mkFixStrictness mkOrder mkBefore mkAfter mkAliasDefinitions
|
mkFixStrictness mkOrder mkBefore mkAfter mkAliasDefinitions
|
||||||
mkAliasAndWrapDefinitions fixMergeModules mkRemovedOptionModule
|
mkAliasAndWrapDefinitions fixMergeModules mkRemovedOptionModule
|
||||||
mkRenamedOptionModule mkMergedOptionModule mkChangedOptionModule
|
mkRenamedOptionModule mkMergedOptionModule mkChangedOptionModule
|
||||||
mkAliasOptionModule mkAliasOptionModuleWithPriority doRename filterModules;
|
mkAliasOptionModule doRename filterModules;
|
||||||
inherit (options) isOption mkEnableOption mkSinkUndeclaredOptions
|
inherit (options) isOption mkEnableOption mkSinkUndeclaredOptions
|
||||||
mergeDefaultOption mergeOneOption mergeEqualOption getValues
|
mergeDefaultOption mergeOneOption mergeEqualOption getValues
|
||||||
getFiles optionAttrSetToDocList optionAttrSetToDocList'
|
getFiles optionAttrSetToDocList optionAttrSetToDocList'
|
||||||
|
@ -596,6 +596,9 @@ rec {
|
|||||||
|
|
||||||
forwards any definitions of boot.copyKernels to
|
forwards any definitions of boot.copyKernels to
|
||||||
boot.loader.grub.copyKernels while printing a warning.
|
boot.loader.grub.copyKernels while printing a warning.
|
||||||
|
|
||||||
|
This also copies over the priority from the aliased option to the
|
||||||
|
non-aliased option.
|
||||||
*/
|
*/
|
||||||
mkRenamedOptionModule = from: to: doRename {
|
mkRenamedOptionModule = from: to: doRename {
|
||||||
inherit from to;
|
inherit from to;
|
||||||
@ -690,16 +693,7 @@ rec {
|
|||||||
use = id;
|
use = id;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Like ‘mkAliasOptionModule’, but copy over the priority of the option as well. */
|
doRename = { from, to, visible, warn, use, withPriority ? true }:
|
||||||
mkAliasOptionModuleWithPriority = from: to: doRename {
|
|
||||||
inherit from to;
|
|
||||||
visible = true;
|
|
||||||
warn = false;
|
|
||||||
use = id;
|
|
||||||
withPriority = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
doRename = { from, to, visible, warn, use, withPriority ? false }:
|
|
||||||
{ config, options, ... }:
|
{ config, options, ... }:
|
||||||
let
|
let
|
||||||
fromOpt = getAttrFromPath from options;
|
fromOpt = getAttrFromPath from options;
|
||||||
|
@ -149,7 +149,7 @@ checkConfigOutput "1 2 3 4 5 6 7 8 9 10" config.result ./loaOf-with-long-list.ni
|
|||||||
# Check loaOf with many merges of lists.
|
# Check loaOf with many merges of lists.
|
||||||
checkConfigOutput "1 2 3 4 5 6 7 8 9 10" config.result ./loaOf-with-many-list-merges.nix
|
checkConfigOutput "1 2 3 4 5 6 7 8 9 10" config.result ./loaOf-with-many-list-merges.nix
|
||||||
|
|
||||||
# Check mkAliasOptionModuleWithPriority.
|
# Check mkAliasOptionModule.
|
||||||
checkConfigOutput "true" config.enable ./alias-with-priority.nix
|
checkConfigOutput "true" config.enable ./alias-with-priority.nix
|
||||||
checkConfigOutput "true" config.enableAlias ./alias-with-priority.nix
|
checkConfigOutput "true" config.enableAlias ./alias-with-priority.nix
|
||||||
checkConfigOutput "false" config.enable ./alias-with-priority-can-override.nix
|
checkConfigOutput "false" config.enable ./alias-with-priority-can-override.nix
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
# This is a test to show that mkAliasOptionModule sets the priority correctly
|
# This is a test to show that mkAliasOptionModule sets the priority correctly
|
||||||
# for aliased options.
|
# for aliased options.
|
||||||
|
#
|
||||||
|
# This test shows that an alias with a high priority is able to override
|
||||||
|
# a non-aliased option.
|
||||||
|
|
||||||
{ config, lib, ... }:
|
{ config, lib, ... }:
|
||||||
|
|
||||||
@ -32,10 +35,10 @@ with lib;
|
|||||||
|
|
||||||
imports = [
|
imports = [
|
||||||
# Create an alias for the "enable" option.
|
# Create an alias for the "enable" option.
|
||||||
(mkAliasOptionModuleWithPriority [ "enableAlias" ] [ "enable" ])
|
(mkAliasOptionModule [ "enableAlias" ] [ "enable" ])
|
||||||
|
|
||||||
# Disable the aliased option, but with a default (low) priority so it
|
# Disable the aliased option with a high priority so it
|
||||||
# should be able to be overridden by the next import.
|
# should override the next import.
|
||||||
( { config, lib, ... }:
|
( { config, lib, ... }:
|
||||||
{
|
{
|
||||||
enableAlias = lib.mkForce false;
|
enableAlias = lib.mkForce false;
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
# This is a test to show that mkAliasOptionModule sets the priority correctly
|
# This is a test to show that mkAliasOptionModule sets the priority correctly
|
||||||
# for aliased options.
|
# for aliased options.
|
||||||
|
#
|
||||||
|
# This test shows that an alias with a low priority is able to be overridden
|
||||||
|
# with a non-aliased option.
|
||||||
|
|
||||||
{ config, lib, ... }:
|
{ config, lib, ... }:
|
||||||
|
|
||||||
@ -32,7 +35,7 @@ with lib;
|
|||||||
|
|
||||||
imports = [
|
imports = [
|
||||||
# Create an alias for the "enable" option.
|
# Create an alias for the "enable" option.
|
||||||
(mkAliasOptionModuleWithPriority [ "enableAlias" ] [ "enable" ])
|
(mkAliasOptionModule [ "enableAlias" ] [ "enable" ])
|
||||||
|
|
||||||
# Disable the aliased option, but with a default (low) priority so it
|
# Disable the aliased option, but with a default (low) priority so it
|
||||||
# should be able to be overridden by the next import.
|
# should be able to be overridden by the next import.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user