Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)

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

+8 -14
+1 -1
lib/default.nix
··· 109 mkFixStrictness mkOrder mkBefore mkAfter mkAliasDefinitions 110 mkAliasAndWrapDefinitions fixMergeModules mkRemovedOptionModule 111 mkRenamedOptionModule mkMergedOptionModule mkChangedOptionModule 112 - mkAliasOptionModule mkAliasOptionModuleWithPriority doRename filterModules; 113 inherit (options) isOption mkEnableOption mkSinkUndeclaredOptions 114 mergeDefaultOption mergeOneOption mergeEqualOption getValues 115 getFiles optionAttrSetToDocList optionAttrSetToDocList'
··· 109 mkFixStrictness mkOrder mkBefore mkAfter mkAliasDefinitions 110 mkAliasAndWrapDefinitions fixMergeModules mkRemovedOptionModule 111 mkRenamedOptionModule mkMergedOptionModule mkChangedOptionModule 112 + mkAliasOptionModule doRename filterModules; 113 inherit (options) isOption mkEnableOption mkSinkUndeclaredOptions 114 mergeDefaultOption mergeOneOption mergeEqualOption getValues 115 getFiles optionAttrSetToDocList optionAttrSetToDocList'
+4 -10
lib/modules.nix
··· 609 610 forwards any definitions of boot.copyKernels to 611 boot.loader.grub.copyKernels while printing a warning. 612 */ 613 mkRenamedOptionModule = from: to: doRename { 614 inherit from to; ··· 703 use = id; 704 }; 705 706 - /* Like ‘mkAliasOptionModule’, but copy over the priority of the option as well. */ 707 - mkAliasOptionModuleWithPriority = from: to: doRename { 708 - inherit from to; 709 - visible = true; 710 - warn = false; 711 - use = id; 712 - withPriority = true; 713 - }; 714 - 715 - doRename = { from, to, visible, warn, use, withPriority ? false }: 716 { config, options, ... }: 717 let 718 fromOpt = getAttrFromPath from options;
··· 609 610 forwards any definitions of boot.copyKernels to 611 boot.loader.grub.copyKernels while printing a warning. 612 + 613 + This also copies over the priority from the aliased option to the 614 + non-aliased option. 615 */ 616 mkRenamedOptionModule = from: to: doRename { 617 inherit from to; ··· 706 use = id; 707 }; 708 709 + doRename = { from, to, visible, warn, use, withPriority ? true }: 710 { config, options, ... }: 711 let 712 fromOpt = getAttrFromPath from options;
+1 -1
lib/tests/modules.sh
··· 149 # Check loaOf with many merges of lists. 150 checkConfigOutput "1 2 3 4 5 6 7 8 9 10" config.result ./loaOf-with-many-list-merges.nix 151 152 - # Check mkAliasOptionModuleWithPriority. 153 checkConfigOutput "true" config.enable ./alias-with-priority.nix 154 checkConfigOutput "true" config.enableAlias ./alias-with-priority.nix 155 checkConfigOutput "false" config.enable ./alias-with-priority-can-override.nix
··· 149 # Check loaOf with many merges of lists. 150 checkConfigOutput "1 2 3 4 5 6 7 8 9 10" config.result ./loaOf-with-many-list-merges.nix 151 152 + # Check mkAliasOptionModule. 153 checkConfigOutput "true" config.enable ./alias-with-priority.nix 154 checkConfigOutput "true" config.enableAlias ./alias-with-priority.nix 155 checkConfigOutput "false" config.enable ./alias-with-priority-can-override.nix
+1 -1
lib/tests/modules/alias-with-priority-can-override.nix
··· 32 33 imports = [ 34 # Create an alias for the "enable" option. 35 - (mkAliasOptionModuleWithPriority [ "enableAlias" ] [ "enable" ]) 36 37 # Disable the aliased option, but with a default (low) priority so it 38 # should be able to be overridden by the next import.
··· 32 33 imports = [ 34 # Create an alias for the "enable" option. 35 + (mkAliasOptionModule [ "enableAlias" ] [ "enable" ]) 36 37 # Disable the aliased option, but with a default (low) priority so it 38 # should be able to be overridden by the next import.
+1 -1
lib/tests/modules/alias-with-priority.nix
··· 32 33 imports = [ 34 # Create an alias for the "enable" option. 35 - (mkAliasOptionModuleWithPriority [ "enableAlias" ] [ "enable" ]) 36 37 # Disable the aliased option, but with a default (low) priority so it 38 # should be able to be overridden by the next import.
··· 32 33 imports = [ 34 # Create an alias for the "enable" option. 35 + (mkAliasOptionModule [ "enableAlias" ] [ "enable" ]) 36 37 # Disable the aliased option, but with a default (low) priority so it 38 # should be able to be overridden by the next import.