1 { config, lib, pkgs, ... }:
8 glibcLocales = lib.mkOption {
10 default = pkgs.glibcLocales.override {
11 allLocales = lib.any (x: x == "all") config.i18n.supportedLocales;
12 locales = config.i18n.supportedLocales;
14 defaultText = lib.literalExpression ''
15 pkgs.glibcLocales.override {
16 allLocales = lib.any (x: x == "all") config.i18n.supportedLocales;
17 locales = config.i18n.supportedLocales;
20 example = lib.literalExpression "pkgs.glibcLocales";
22 Customized pkg.glibcLocales package.
24 Changing this option can disable handling of i18n.defaultLocale
29 defaultLocale = lib.mkOption {
31 default = "en_US.UTF-8";
32 example = "nl_NL.UTF-8";
34 The default locale. It determines the language for program
35 messages, the format for dates and times, sort order, and so on.
36 It also determines the character set, such as UTF-8.
40 extraLocaleSettings = lib.mkOption {
41 type = lib.types.attrsOf lib.types.str;
43 example = { LC_MESSAGES = "en_US.UTF-8"; LC_TIME = "de_DE.UTF-8"; };
45 A set of additional system-wide locale settings other than
46 `LANG` which can be configured with
47 {option}`i18n.defaultLocale`.
51 supportedLocales = lib.mkOption {
52 type = lib.types.listOf lib.types.str;
54 (builtins.map (l: (lib.replaceStrings [ "utf8" "utf-8" "UTF8" ] [ "UTF-8" "UTF-8" "UTF-8" ] l) + "/UTF-8") (
58 config.i18n.defaultLocale
59 ] ++ (lib.attrValues (lib.filterAttrs (n: v: n != "LANGUAGE") config.i18n.extraLocaleSettings))
61 defaultText = lib.literalExpression ''
63 (builtins.map (l: (lib.replaceStrings [ "utf8" "utf-8" "UTF8" ] [ "UTF-8" "UTF-8" "UTF-8" ] l) + "/UTF-8") (
67 config.i18n.defaultLocale
68 ] ++ (lib.attrValues (lib.filterAttrs (n: v: n != "LANGUAGE") config.i18n.extraLocaleSettings))
71 example = ["en_US.UTF-8/UTF-8" "nl_NL.UTF-8/UTF-8" "nl_NL/ISO-8859-1"];
73 List of locales that the system should support. The value
74 `"all"` means that all locales supported by
75 Glibc will be installed. A full list of supported locales
76 can be found at <https://sourceware.org/git/?p=glibc.git;a=blob;f=localedata/SUPPORTED>.
89 environment.systemPackages =
90 # We increase the priority a little, so that plain glibc in systemPackages can't win.
91 lib.optional (config.i18n.supportedLocales != []) (lib.setPrio (-1) config.i18n.glibcLocales);
93 environment.sessionVariables =
94 { LANG = config.i18n.defaultLocale;
95 LOCALE_ARCHIVE = "/run/current-system/sw/lib/locale/locale-archive";
96 } // config.i18n.extraLocaleSettings;
98 systemd.globalEnvironment = lib.mkIf (config.i18n.supportedLocales != []) {
99 LOCALE_ARCHIVE = "${config.i18n.glibcLocales}/lib/locale/locale-archive";
102 # ‘/etc/locale.conf’ is used by systemd.
103 environment.etc."locale.conf".source = pkgs.writeText "locale.conf"
105 LANG=${config.i18n.defaultLocale}
106 ${lib.concatStringsSep "\n" (lib.mapAttrsToList (n: v: "${n}=${v}") config.i18n.extraLocaleSettings)}