at 24.11-pre 1.5 kB view raw
1# This is a test to show that mkAliasOptionModule sets the priority correctly 2# for aliased options. 3# 4# This test shows that an alias with a low priority is able to be overridden 5# with a non-aliased option. 6 7{ config, lib, ... }: 8 9let 10 inherit (lib) 11 mkAliasOptionModule 12 mkDefault 13 mkOption 14 types 15 ; 16in 17 18{ 19 options = { 20 # A simple boolean option that can be enabled or disabled. 21 enable = mkOption { 22 type = types.nullOr types.bool; 23 default = null; 24 example = true; 25 description = '' 26 Some descriptive text 27 ''; 28 }; 29 30 # mkAliasOptionModule sets warnings, so this has to be defined. 31 warnings = mkOption { 32 internal = true; 33 default = []; 34 type = types.listOf types.str; 35 example = [ "The `foo' service is deprecated and will go away soon!" ]; 36 description = '' 37 This option allows modules to show warnings to users during 38 the evaluation of the system configuration. 39 ''; 40 }; 41 }; 42 43 imports = [ 44 # Create an alias for the "enable" option. 45 (mkAliasOptionModule [ "enableAlias" ] [ "enable" ]) 46 47 # Disable the aliased option, but with a default (low) priority so it 48 # should be able to be overridden by the next import. 49 ( { config, lib, ... }: 50 { 51 enableAlias = mkDefault false; 52 } 53 ) 54 55 # Enable the normal (non-aliased) option. 56 ( { config, lib, ... }: 57 { 58 enable = true; 59 } 60 ) 61 ]; 62}