diff options
author | Simon Parri <simonparri@ganzeria.com> | 2025-05-09 17:54:45 -0500 |
---|---|---|
committer | Simon Parri <simonparri@ganzeria.com> | 2025-05-09 17:54:45 -0500 |
commit | 4ea08b3976188eb01a74548d68b227a7794b4caa (patch) | |
tree | 505c0df98ed00ed592be15895b8ed3eb7aa9e2c3 /modules/locales.nix | |
download | nixos-config-4ea08b3976188eb01a74548d68b227a7794b4caa.tar.gz nixos-config-4ea08b3976188eb01a74548d68b227a7794b4caa.zip |
Add current configuration
Diffstat (limited to 'modules/locales.nix')
-rw-r--r-- | modules/locales.nix | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/modules/locales.nix b/modules/locales.nix new file mode 100644 index 0000000..73627f8 --- /dev/null +++ b/modules/locales.nix @@ -0,0 +1,60 @@ +{ lib, config, pkgs, ... }: + +let localeMap = { + c = "C.UTF-8"; + us = "en_US.UTF-8"; + it = "it_IT.UTF-8"; + jp = "ja_JP.UTF-8"; + }; + + dictOverlay = with pkgs.aspellDicts; { + us = en; + }; + dicts = pkgs.aspellDicts // dictOverlay; + + getSafe' = with builtins; + (key: attrs: if hasAttr key attrs then [(getAttr key attrs)] else []); + + inherit (lib) types; + cfg = config.this.locales; +in +{ + options = { + this.locales = { + default = lib.mkOption { + type = types.str; + default = "us"; + }; + extra = lib.mkOption { + type = types.listOf types.str; + default = []; + }; + dictionaries = { + enable = lib.mkEnableOption "dictionaries"; + extra = lib.mkOption { + type = types.listOf types.str; + default = []; + }; + }; + + all = lib.mkOption { + description = "READ-ONLY!"; + default = ["c" cfg.default] ++ cfg.extra; + }; + }; + }; + + config = { + i18n = { + defaultLocale = localeMap.${cfg.default}; + supportedLocales = + builtins.map (l: localeMap.${l} + "/UTF-8") cfg.all; + }; + + environment.systemPackages = + (lib.optionals cfg.dictionaries.enable + (builtins.concatMap (l: getSafe' l dicts) + cfg.all)) + ++ builtins.map (d: pkgs.aspellDicts.${d}) cfg.dictionaries.extra; + }; +} |