Unverified Commit 708480f8 authored by Doron Behar's avatar Doron Behar Committed by GitHub
Browse files

nixos/i18n: add `extraLocales` option (#356477)

parents 360e50e1 07dde5f4
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -360,6 +360,11 @@

## Other Notable Changes {#sec-nixpkgs-release-25.05-notable-changes}

- `i18n` module improvements:
  - `i18n.extraLocales` should now be the preferred way to install additional locales.
  - `i18n.supportedLocales` is now considered an implementation detail and will be hidden from the documentation. But the option will still continue to work.
  - `i18n.supportedLocales` will now trigger a warning when it omits any locale set in `i18n.defaultLocale`, `i18n.extraLocales` or `i18n.extraLocaleSettings`.

- `titaniumenv`, `titanium`, and `titanium-alloy` have been removed due to lack of maintenance in Nixpkgs []{#sec-nixpkgs-release-25.05-incompatibilities-titanium-removed}.

- androidenv has been improved:
+1 −1
Original line number Diff line number Diff line
# Minimal {#sec-profile-minimal}

This profile defines a small NixOS configuration. It does not contain any
graphical stuff. It's a very short file that sets [](#opt-i18n.supportedLocales)
graphical stuff. It's a very short file that sets the supported locales
to only support the user-selected locale, and
[disables packages' documentation](#opt-documentation.enable).
+39 −20
Original line number Diff line number Diff line
@@ -4,6 +4,16 @@
  pkgs,
  ...
}:
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

@@ -42,6 +52,17 @@
        '';
      };

      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`.
        '';
      };

      extraLocaleSettings = lib.mkOption {
        type = lib.types.attrsOf lib.types.str;
        default = { };
@@ -58,28 +79,14 @@

      supportedLocales = lib.mkOption {
        type = lib.types.listOf lib.types.str;
        visible = false;
        default = lib.unique (
          builtins.map
            (l: (lib.replaceStrings [ "utf8" "utf-8" "UTF8" ] [ "UTF-8" "UTF-8" "UTF-8" ] l) + "/UTF-8")
            (
          [
                "C.UTF-8"
                "en_US.UTF-8"
                config.i18n.defaultLocale
            "C.UTF-8/UTF-8"
            "en_US.UTF-8/UTF-8"
          ]
              ++ (lib.attrValues (lib.filterAttrs (n: v: n != "LANGUAGE") config.i18n.extraLocaleSettings))
            )
          ++ aggregatedLocales
        );
        defaultText = lib.literalExpression ''
          lib.unique
            (builtins.map (l: (lib.replaceStrings [ "utf8" "utf-8" "UTF8" ] [ "UTF-8" "UTF-8" "UTF-8" ] l) + "/UTF-8") (
              [
                "C.UTF-8"
                "en_US.UTF-8"
                config.i18n.defaultLocale
              ] ++ (lib.attrValues (lib.filterAttrs (n: v: n != "LANGUAGE") config.i18n.extraLocaleSettings))
            ))
        '';
        example = [
          "en_US.UTF-8/UTF-8"
          "nl_NL.UTF-8/UTF-8"
@@ -100,6 +107,18 @@
  ###### implementation

  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
          include some locales specified in `i18n.defaultLocale`,
          `i18n.extraLocales` or `i18n.extraLocaleSettings`.

          If you're trying to install additional locales not specified in
          `i18n.defaultLocale` or `i18n.extraLocaleSettings`, consider adding
          only those locales to `i18n.extraLocales`.
        '';

    environment.systemPackages =
      # We increase the priority a little, so that plain glibc in systemPackages can't win.