# 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; }; }