nixos/i18n: support "all" for extraLocales (#403567)

Changed files
+14 -5
nixos
modules
config
+14 -5
nixos/modules/config/i18n.nix
···
}:
let
aggregatedLocales =
-
builtins.map
(l: (lib.replaceStrings [ "utf8" "utf-8" "UTF8" ] [ "UTF-8" "UTF-8" "UTF-8" ] l) + "/UTF-8")
(
[ config.i18n.defaultLocale ]
-
++ config.i18n.extraLocales
++ (lib.attrValues (lib.filterAttrs (n: v: n != "LANGUAGE") config.i18n.extraLocaleSettings))
-
);
in
{
###### interface
···
};
extraLocales = lib.mkOption {
-
type = lib.types.listOf lib.types.str;
default = [ ];
example = [ "nl_NL.UTF-8" ];
description = ''
Additional locales that the system should support, besides the ones
configured with {option}`i18n.defaultLocale` and
{option}`i18n.extraLocaleSettings`.
'';
};
···
config = {
warnings =
-
lib.optional ((lib.subtractLists config.i18n.supportedLocales aggregatedLocales) != [ ])
''
`i18n.supportedLocales` is deprecated in favor of `i18n.extraLocales`,
and it seems you are using `i18n.supportedLocales` and forgot to
···
}:
let
aggregatedLocales =
+
(builtins.map
(l: (lib.replaceStrings [ "utf8" "utf-8" "UTF8" ] [ "UTF-8" "UTF-8" "UTF-8" ] l) + "/UTF-8")
(
[ config.i18n.defaultLocale ]
+
++ (lib.optionals (builtins.isList config.i18n.extraLocales) config.i18n.extraLocales)
++ (lib.attrValues (lib.filterAttrs (n: v: n != "LANGUAGE") config.i18n.extraLocaleSettings))
+
)
+
)
+
++ (lib.optional (builtins.isString config.i18n.extraLocales) config.i18n.extraLocales);
in
{
###### interface
···
};
extraLocales = lib.mkOption {
+
type = lib.types.either (lib.types.listOf lib.types.str) (lib.types.enum [ "all" ]);
default = [ ];
example = [ "nl_NL.UTF-8" ];
description = ''
Additional locales that the system should support, besides the ones
configured with {option}`i18n.defaultLocale` and
{option}`i18n.extraLocaleSettings`.
+
Set this to `"all"` to install all available locales.
'';
};
···
config = {
warnings =
+
lib.optional
+
(
+
!(
+
(lib.subtractLists config.i18n.supportedLocales aggregatedLocales) == [ ]
+
|| lib.any (x: x == "all") config.i18n.supportedLocales
+
)
+
)
''
`i18n.supportedLocales` is deprecated in favor of `i18n.extraLocales`,
and it seems you are using `i18n.supportedLocales` and forgot to