Files
NixOsConfig/modules/nixos/core/locale.nix
T
2026-10-12 18:15:38 +03:00

58 lines
1.4 KiB
Nix
Executable File

# Time zone, locale and keyboard layout (also used by the console and by the
# home-manager Hyprland module through osConfig).
{ config, lib, ... }:
let
cfg = config.my.locale;
inherit (lib) mkOption types;
in
{
options.my.locale = {
timeZone = mkOption {
type = types.str;
example = "Europe/Moscow";
description = "IANA time zone name.";
};
defaultLocale = mkOption {
type = types.str;
default = "en_US.UTF-8";
description = "Default system locale (LANG).";
};
keyboardLayouts = mkOption {
type = types.listOf types.str;
default = [ "us" ];
example = [
"us"
"ru"
];
description = "XKB layouts, in switching order.";
};
keyboardOptions = mkOption {
type = types.listOf types.str;
default = [ ];
example = [ "grp:alt_shift_toggle" ];
description = "XKB options such as the layout toggle shortcut.";
};
};
config = {
time.timeZone = cfg.timeZone;
i18n = {
inherit (cfg) defaultLocale;
# Russian stays available for apps and games even with an English UI.
extraLocales = [ "ru_RU.UTF-8/UTF-8" ];
};
services.xserver.xkb = {
layout = lib.concatStringsSep "," cfg.keyboardLayouts;
options = lib.concatStringsSep "," cfg.keyboardOptions;
};
# TTY and initrd keymap follow the XKB layout above.
console.useXkbConfig = true;
};
}