at 17.09-beta 4.4 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5{ 6 ###### interface 7 8 options = { 9 10 i18n = { 11 glibcLocales = mkOption { 12 type = types.path; 13 default = pkgs.glibcLocales.override { 14 allLocales = any (x: x == "all") config.i18n.supportedLocales; 15 locales = config.i18n.supportedLocales; 16 }; 17 example = literalExample "pkgs.glibcLocales"; 18 description = '' 19 Customized pkg.glibcLocales package. 20 21 Changing this option can disable handling of i18n.defaultLocale 22 and supportedLocale. 23 ''; 24 }; 25 26 defaultLocale = mkOption { 27 type = types.str; 28 default = "en_US.UTF-8"; 29 example = "nl_NL.UTF-8"; 30 description = '' 31 The default locale. It determines the language for program 32 messages, the format for dates and times, sort order, and so on. 33 It also determines the character set, such as UTF-8. 34 ''; 35 }; 36 37 supportedLocales = mkOption { 38 type = types.listOf types.str; 39 default = ["all"]; 40 example = ["en_US.UTF-8/UTF-8" "nl_NL.UTF-8/UTF-8" "nl_NL/ISO-8859-1"]; 41 description = '' 42 List of locales that the system should support. The value 43 <literal>"all"</literal> means that all locales supported by 44 Glibc will be installed. A full list of supported locales 45 can be found at <link 46 xlink:href="http://sourceware.org/cgi-bin/cvsweb.cgi/libc/localedata/SUPPORTED?cvsroot=glibc"/>. 47 ''; 48 }; 49 50 consolePackages = mkOption { 51 type = types.listOf types.package; 52 default = with pkgs.kbdKeymaps; [ dvp neo ]; 53 defaultText = ''with pkgs.kbdKeymaps; [ dvp neo ]''; 54 description = '' 55 List of additional packages that provide console fonts, keymaps and 56 other resources. 57 ''; 58 }; 59 60 consoleFont = mkOption { 61 type = types.str; 62 default = "Lat2-Terminus16"; 63 example = "LatArCyrHeb-16"; 64 description = '' 65 The font used for the virtual consoles. Leave empty to use 66 whatever the <command>setfont</command> program considers the 67 default font. 68 ''; 69 }; 70 71 consoleUseXkbConfig = mkOption { 72 type = types.bool; 73 default = false; 74 description = '' 75 If set, configure the console keymap from the xserver keyboard 76 settings. 77 ''; 78 }; 79 80 consoleKeyMap = mkOption { 81 type = mkOptionType { 82 name = "string or path"; 83 check = t: (isString t || types.path.check t); 84 }; 85 86 default = "us"; 87 example = "fr"; 88 description = '' 89 The keyboard mapping table for the virtual consoles. 90 ''; 91 }; 92 93 consoleColors = mkOption { 94 type = types.listOf types.str; 95 default = []; 96 example = [ 97 "002b36" "dc322f" "859900" "b58900" 98 "268bd2" "d33682" "2aa198" "eee8d5" 99 "002b36" "cb4b16" "586e75" "657b83" 100 "839496" "6c71c4" "93a1a1" "fdf6e3" 101 ]; 102 description = '' 103 The 16 colors palette used by the virtual consoles. 104 Leave empty to use the default colors. 105 Colors must be in hexadecimal format and listed in 106 order from color 0 to color 15. 107 ''; 108 }; 109 110 }; 111 112 }; 113 114 115 ###### implementation 116 117 config = { 118 119 i18n.consoleKeyMap = with config.services.xserver; 120 mkIf config.i18n.consoleUseXkbConfig 121 (pkgs.runCommand "xkb-console-keymap" { preferLocalBuild = true; } '' 122 '${pkgs.ckbcomp}/bin/ckbcomp' -model '${xkbModel}' -layout '${layout}' \ 123 -option '${xkbOptions}' -variant '${xkbVariant}' > "$out" 124 ''); 125 126 environment.systemPackages = 127 optional (config.i18n.supportedLocales != []) config.i18n.glibcLocales; 128 129 environment.sessionVariables = 130 { LANG = config.i18n.defaultLocale; 131 LOCALE_ARCHIVE = "/run/current-system/sw/lib/locale/locale-archive"; 132 }; 133 134 systemd.globalEnvironment = mkIf (config.i18n.supportedLocales != []) { 135 LOCALE_ARCHIVE = "${config.i18n.glibcLocales}/lib/locale/locale-archive"; 136 }; 137 138 # ‘/etc/locale.conf’ is used by systemd. 139 environment.etc = singleton 140 { target = "locale.conf"; 141 source = pkgs.writeText "locale.conf" 142 '' 143 LANG=${config.i18n.defaultLocale} 144 ''; 145 }; 146 147 }; 148}