diff options
author | (cdep)illabout <cdep.illabout@gmail.com> | 2019-01-24 12:58:33 +0900 |
---|---|---|
committer | (cdep)illabout <cdep.illabout@gmail.com> | 2019-01-24 13:02:16 +0900 |
commit | 81fa1e392be44585fe83e26921ce3bd720891def (patch) | |
tree | 7c551320ca703cc7684fa7d2e0f85d0f364d2053 | |
parent | 0abf1810668ec8df0321156b0675519610513100 (diff) |
lib/modules: Change mkAliasOptionModule to use the priority for the alias.
This commit changes the `mkAliasOptionModule` function to make sure that the priority for the aliased option is propagated to the non-aliased option. This also affects the `mkRenamedOptionModule` function in a similar fashion. This also removes the `mkAliasOptionModuleWithPriority` function, since its functionality is now subsumed by `mkAliasOptionModule`. This change was recommended by @nbp: https://github.com/NixOS/nixpkgs/pull/53397#discussion_r245487432
-rw-r--r-- | lib/default.nix | 2 | ||||
-rw-r--r-- | lib/modules.nix | 14 | ||||
-rwxr-xr-x | lib/tests/modules.sh | 2 | ||||
-rw-r--r-- | lib/tests/modules/alias-with-priority-can-override.nix | 2 | ||||
-rw-r--r-- | lib/tests/modules/alias-with-priority.nix | 2 |
5 files changed, 8 insertions, 14 deletions
diff --git a/lib/default.nix b/lib/default.nix index d400907ebb0cb..dbb90081b2c34 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -109,7 +109,7 @@ let mkFixStrictness mkOrder mkBefore mkAfter mkAliasDefinitions mkAliasAndWrapDefinitions fixMergeModules mkRemovedOptionModule mkRenamedOptionModule mkMergedOptionModule mkChangedOptionModule - mkAliasOptionModule mkAliasOptionModuleWithPriority doRename filterModules; + mkAliasOptionModule doRename filterModules; inherit (options) isOption mkEnableOption mkSinkUndeclaredOptions mergeDefaultOption mergeOneOption mergeEqualOption getValues getFiles optionAttrSetToDocList optionAttrSetToDocList' diff --git a/lib/modules.nix b/lib/modules.nix index 9f8e196ee0f73..a599f5f4d778a 100644 --- a/lib/modules.nix +++ b/lib/modules.nix @@ -609,6 +609,9 @@ rec { forwards any definitions of boot.copyKernels to 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 { inherit from to; @@ -703,16 +706,7 @@ rec { use = id; }; - /* Like ‘mkAliasOptionModule’, but copy over the priority of the option as well. */ - mkAliasOptionModuleWithPriority = from: to: doRename { - inherit from to; - visible = true; - warn = false; - use = id; - withPriority = true; - }; - - doRename = { from, to, visible, warn, use, withPriority ? false }: + doRename = { from, to, visible, warn, use, withPriority ? true }: { config, options, ... }: let fromOpt = getAttrFromPath from options; diff --git a/lib/tests/modules.sh b/lib/tests/modules.sh index a72777cbf2a68..eadaa0521b359 100755 --- a/lib/tests/modules.sh +++ b/lib/tests/modules.sh @@ -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. 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.enableAlias ./alias-with-priority.nix checkConfigOutput "false" config.enable ./alias-with-priority-can-override.nix diff --git a/lib/tests/modules/alias-with-priority-can-override.nix b/lib/tests/modules/alias-with-priority-can-override.nix index a6b26895f3a8d..ccb70b779a06a 100644 --- a/lib/tests/modules/alias-with-priority-can-override.nix +++ b/lib/tests/modules/alias-with-priority-can-override.nix @@ -32,7 +32,7 @@ with lib; imports = [ # 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 # should be able to be overridden by the next import. diff --git a/lib/tests/modules/alias-with-priority.nix b/lib/tests/modules/alias-with-priority.nix index 923483684cb16..ba25b527aa2dc 100644 --- a/lib/tests/modules/alias-with-priority.nix +++ b/lib/tests/modules/alias-with-priority.nix @@ -32,7 +32,7 @@ with lib; imports = [ # 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 # should be able to be overridden by the next import. |