1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6
7 glibcLocales = pkgs.glibcLocales.override {
8 allLocales = any (x: x == "all") config.i18n.supportedLocales;
9 locales = config.i18n.supportedLocales;
10 };
11
12in
13
14{
15 ###### interface
16
17 options = {
18
19 i18n = {
20 defaultLocale = mkOption {
21 type = types.str;
22 default = "en_US.UTF-8";
23 example = "nl_NL.UTF-8";
24 description = ''
25 The default locale. It determines the language for program
26 messages, the format for dates and times, sort order, and so on.
27 It also determines the character set, such as UTF-8.
28 '';
29 };
30
31 supportedLocales = mkOption {
32 type = types.listOf types.str;
33 default = ["all"];
34 example = ["en_US.UTF-8/UTF-8" "nl_NL.UTF-8/UTF-8" "nl_NL/ISO-8859-1"];
35 description = ''
36 List of locales that the system should support. The value
37 <literal>"all"</literal> means that all locales supported by
38 Glibc will be installed. A full list of supported locales
39 can be found at <link
40 xlink:href="http://sourceware.org/cgi-bin/cvsweb.cgi/libc/localedata/SUPPORTED?cvsroot=glibc"/>.
41 '';
42 };
43
44 consoleFont = mkOption {
45 type = types.str;
46 default = "Lat2-Terminus16";
47 example = "LatArCyrHeb-16";
48 description = ''
49 The font used for the virtual consoles. Leave empty to use
50 whatever the <command>setfont</command> program considers the
51 default font.
52 '';
53 };
54
55 consoleKeyMap = mkOption {
56 type = mkOptionType {
57 name = "string or path";
58 check = t: (isString t || types.path.check t);
59 };
60
61 default = "us";
62 example = "fr";
63 description = ''
64 The keyboard mapping table for the virtual consoles.
65 '';
66 };
67
68 };
69
70 };
71
72
73 ###### implementation
74
75 config = {
76
77 environment.systemPackages =
78 optional (config.i18n.supportedLocales != []) glibcLocales;
79
80 environment.sessionVariables =
81 { LANG = config.i18n.defaultLocale;
82 LOCALE_ARCHIVE = "/run/current-system/sw/lib/locale/locale-archive";
83 };
84
85 systemd.globalEnvironment = mkIf (config.i18n.supportedLocales != []) {
86 LOCALE_ARCHIVE = "${glibcLocales}/lib/locale/locale-archive";
87 };
88
89 # ‘/etc/locale.conf’ is used by systemd.
90 environment.etc = singleton
91 { target = "locale.conf";
92 source = pkgs.writeText "locale.conf"
93 ''
94 LANG=${config.i18n.defaultLocale}
95 '';
96 };
97
98 };
99}