1 { config, lib, pkgs, ... }:
11 glibcLocales = mkOption {
13 default = pkgs.glibcLocales.override {
14 allLocales = any (x: x == "all") config.i18n.supportedLocales;
15 locales = config.i18n.supportedLocales;
17 defaultText = literalExpression ''
18 pkgs.glibcLocales.override {
19 allLocales = any (x: x == "all") config.i18n.supportedLocales;
20 locales = config.i18n.supportedLocales;
23 example = literalExpression "pkgs.glibcLocales";
24 description = lib.mdDoc ''
25 Customized pkg.glibcLocales package.
27 Changing this option can disable handling of i18n.defaultLocale
32 defaultLocale = mkOption {
34 default = "en_US.UTF-8";
35 example = "nl_NL.UTF-8";
36 description = lib.mdDoc ''
37 The default locale. It determines the language for program
38 messages, the format for dates and times, sort order, and so on.
39 It also determines the character set, such as UTF-8.
43 extraLocaleSettings = mkOption {
44 type = types.attrsOf types.str;
46 example = { LC_MESSAGES = "en_US.UTF-8"; LC_TIME = "de_DE.UTF-8"; };
47 description = lib.mdDoc ''
48 A set of additional system-wide locale settings other than
49 `LANG` which can be configured with
50 {option}`i18n.defaultLocale`.
54 supportedLocales = mkOption {
55 type = types.listOf types.str;
57 (builtins.map (l: (replaceStrings [ "utf8" "utf-8" "UTF8" ] [ "UTF-8" "UTF-8" "UTF-8" ] l) + "/UTF-8") (
61 config.i18n.defaultLocale
62 ] ++ (attrValues (filterAttrs (n: v: n != "LANGUAGE") config.i18n.extraLocaleSettings))
64 defaultText = literalExpression ''
66 (builtins.map (l: (replaceStrings [ "utf8" "utf-8" "UTF8" ] [ "UTF-8" "UTF-8" "UTF-8" ] l) + "/UTF-8") (
69 config.i18n.defaultLocale
70 ] ++ (attrValues (filterAttrs (n: v: n != "LANGUAGE") config.i18n.extraLocaleSettings))
73 example = ["en_US.UTF-8/UTF-8" "nl_NL.UTF-8/UTF-8" "nl_NL/ISO-8859-1"];
74 description = lib.mdDoc ''
75 List of locales that the system should support. The value
76 `"all"` means that all locales supported by
77 Glibc will be installed. A full list of supported locales
78 can be found at <https://sourceware.org/git/?p=glibc.git;a=blob;f=localedata/SUPPORTED>.
91 environment.systemPackages =
92 # We increase the priority a little, so that plain glibc in systemPackages can't win.
93 optional (config.i18n.supportedLocales != []) (lib.setPrio (-1) config.i18n.glibcLocales);
95 environment.sessionVariables =
96 { LANG = config.i18n.defaultLocale;
97 LOCALE_ARCHIVE = "/run/current-system/sw/lib/locale/locale-archive";
98 } // config.i18n.extraLocaleSettings;
100 systemd.globalEnvironment = mkIf (config.i18n.supportedLocales != []) {
101 LOCALE_ARCHIVE = "${config.i18n.glibcLocales}/lib/locale/locale-archive";
104 # ‘/etc/locale.conf’ is used by systemd.
105 environment.etc."locale.conf".source = pkgs.writeText "locale.conf"
107 LANG=${config.i18n.defaultLocale}
108 ${concatStringsSep "\n" (mapAttrsToList (n: v: "${n}=${v}") config.i18n.extraLocaleSettings)}