summaryrefslogtreecommitdiff
path: root/modules/localization.nix
blob: 49933fa413a6e25e41c952ec44562e6967b241a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
{ config, lib, ... }:
let
  cfg = config.os.core.locale;
in
{
  options.os.core.locale = {
    enable = lib.mkEnableOption "system localization (timezone and language)";

    timeZone = lib.mkOption {
      type = lib.types.str;
      default = "Europe/Warsaw";
      description = "the system timezone.";
    };

    format = lib.mkOption {
      type = lib.types.str;
      default = "pl_PL.UTF-8";
      description = "the locale used for numbers, time, and measurements.";
    };
  };
  config = lib.mkIf cfg.enable {
    time.timeZone = cfg.timeZone;

    i18n = {
      defaultLocale = "en_US.UTF-8";

      extraLocaleSettings = {
        LC_TIME = cfg.format;
        LC_NUMERIC = cfg.format;
        LC_MONETARY = cfg.format;
        LC_PAPER = cfg.format;
        LC_MEASUREMENT = cfg.format;
        LC_COLLATE = cfg.format;
        LC_NAME = cfg.format;
        LC_ADDRESS = cfg.format;
        LC_TELEPHONE = cfg.format;
        LC_IDENTIFICATION = cfg.format;
      };
    };
  };
}