Skip to content

Commit b94a794

Browse files
committed
nixos/i18n: support "all" for extraLocales
1 parent 97e6d41 commit b94a794

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

nixos/modules/config/i18n.nix

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
}:
77
let
88
aggregatedLocales =
9-
builtins.map
9+
(builtins.map
1010
(l: (lib.replaceStrings [ "utf8" "utf-8" "UTF8" ] [ "UTF-8" "UTF-8" "UTF-8" ] l) + "/UTF-8")
1111
(
1212
[ config.i18n.defaultLocale ]
13-
++ config.i18n.extraLocales
13+
++ (lib.optionals (builtins.isList config.i18n.extraLocales) config.i18n.extraLocales)
1414
++ (lib.attrValues (lib.filterAttrs (n: v: n != "LANGUAGE") config.i18n.extraLocaleSettings))
15-
);
15+
)
16+
)
17+
++ (lib.optional (builtins.isString config.i18n.extraLocales) config.i18n.extraLocales);
1618
in
1719
{
1820
###### interface
@@ -53,13 +55,14 @@ in
5355
};
5456

5557
extraLocales = lib.mkOption {
56-
type = lib.types.listOf lib.types.str;
58+
type = lib.types.either (lib.types.listOf lib.types.str) (lib.types.enum [ "all" ]);
5759
default = [ ];
5860
example = [ "nl_NL.UTF-8" ];
5961
description = ''
6062
Additional locales that the system should support, besides the ones
6163
configured with {option}`i18n.defaultLocale` and
6264
{option}`i18n.extraLocaleSettings`.
65+
Set this to `"all"` to install all available locales.
6366
'';
6467
};
6568

@@ -108,7 +111,13 @@ in
108111

109112
config = {
110113
warnings =
111-
lib.optional ((lib.subtractLists config.i18n.supportedLocales aggregatedLocales) != [ ])
114+
lib.optional
115+
(
116+
!(
117+
(lib.subtractLists config.i18n.supportedLocales aggregatedLocales) == [ ]
118+
|| lib.any (x: x == "all") config.i18n.supportedLocales
119+
)
120+
)
112121
''
113122
`i18n.supportedLocales` is deprecated in favor of `i18n.extraLocales`,
114123
and it seems you are using `i18n.supportedLocales` and forgot to

0 commit comments

Comments
 (0)