diff options
author | Silvan Mosberger <infinisil@icloud.com> | 2019-02-23 16:43:05 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-23 16:43:05 +0100 |
commit | d3216be6d9dc75bef896c5ef63e846a9bc0b01f4 (patch) | |
tree | 7c8686a8a14d4bf245c6d603c2c4ab003643a624 /lib | |
parent | 55adb547b4f1b831baf60c12be03551050d5cca0 (diff) | |
parent | dcbd13631964cc2977df7faead75deb3bee749a8 (diff) | |
download | nixpkgs-d3216be6d9dc75bef896c5ef63e846a9bc0b01f4.tar nixpkgs-d3216be6d9dc75bef896c5ef63e846a9bc0b01f4.tar.gz nixpkgs-d3216be6d9dc75bef896c5ef63e846a9bc0b01f4.tar.bz2 nixpkgs-d3216be6d9dc75bef896c5ef63e846a9bc0b01f4.tar.lz nixpkgs-d3216be6d9dc75bef896c5ef63e846a9bc0b01f4.tar.xz nixpkgs-d3216be6d9dc75bef896c5ef63e846a9bc0b01f4.tar.zst nixpkgs-d3216be6d9dc75bef896c5ef63e846a9bc0b01f4.zip |
Merge pull request #54528 from cdepillabout/module-alias-uses-priority
lib/modules: Change mkAliasOptionModule to use the priority for the alias
Diffstat (limited to 'lib')
-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 | 9 | ||||
-rw-r--r-- | lib/tests/modules/alias-with-priority.nix | 5 |
5 files changed, 16 insertions, 16 deletions
diff --git a/lib/default.nix b/lib/default.nix index d400907ebb0..dbb90081b2c 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 5c9d66d8f97..a41c9da610a 100644 --- a/lib/modules.nix +++ b/lib/modules.nix @@ -596,6 +596,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; @@ -690,16 +693,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 a72777cbf2a..eadaa0521b3 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 a6b26895f3a..9a18c9d9f61 100644 --- a/lib/tests/modules/alias-with-priority-can-override.nix +++ b/lib/tests/modules/alias-with-priority-can-override.nix @@ -1,5 +1,8 @@ # This is a test to show that mkAliasOptionModule sets the priority correctly # for aliased options. +# +# This test shows that an alias with a high priority is able to override +# a non-aliased option. { config, lib, ... }: @@ -32,10 +35,10 @@ 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. + # Disable the aliased option with a high priority so it + # should override the next import. ( { config, lib, ... }: { enableAlias = lib.mkForce false; diff --git a/lib/tests/modules/alias-with-priority.nix b/lib/tests/modules/alias-with-priority.nix index 923483684cb..a35a06fc697 100644 --- a/lib/tests/modules/alias-with-priority.nix +++ b/lib/tests/modules/alias-with-priority.nix @@ -1,5 +1,8 @@ # This is a test to show that mkAliasOptionModule sets the priority correctly # 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, ... }: @@ -32,7 +35,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. |