Merge pull request #36424 from jfrankenau/i18n-extra-locale

nixos/i18n: add option for extra locale settings
This commit is contained in:
Maximilian Bosch 2018-11-29 16:22:34 +01:00 committed by GitHub
commit 45c6794573
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -34,6 +34,17 @@ with lib;
'';
};
extraLocaleSettings = mkOption {
type = types.attrsOf types.str;
default = {};
example = { LC_MESSAGES = "en_US.UTF-8"; LC_TIME = "de_DE.UTF-8"; };
description = ''
A set of additional system-wide locale settings other than
<literal>LANG</literal> which can be configured with
<option>i18n.defaultLocale</option>.
'';
};
supportedLocales = mkOption {
type = types.listOf types.str;
default = ["all"];
@ -129,7 +140,7 @@ with lib;
environment.sessionVariables =
{ LANG = config.i18n.defaultLocale;
LOCALE_ARCHIVE = "/run/current-system/sw/lib/locale/locale-archive";
};
} // config.i18n.extraLocaleSettings;
systemd.globalEnvironment = mkIf (config.i18n.supportedLocales != []) {
LOCALE_ARCHIVE = "${config.i18n.glibcLocales}/lib/locale/locale-archive";
@ -141,6 +152,7 @@ with lib;
source = pkgs.writeText "locale.conf"
''
LANG=${config.i18n.defaultLocale}
${concatStringsSep "\n" (mapAttrsToList (n: v: ''${n}=${v}'') config.i18n.extraLocaleSettings)}
'';
};