From 3f767068d2e5c4aa09519342970ad548b7053561 Mon Sep 17 00:00:00 2001 From: Jo Date: Sat, 7 Sep 2024 08:58:12 +0200 Subject: [PATCH] refactor(module): move locale config to own nixos module --- .../nixos/archetypes/workstation/default.nix | 1 + modules/nixos/common/locale/default.nix | 57 +++++++++++++++++++ systems/x86_64-linux/puzzlevision/default.nix | 20 ------- 3 files changed, 58 insertions(+), 20 deletions(-) create mode 100644 modules/nixos/common/locale/default.nix diff --git a/modules/nixos/archetypes/workstation/default.nix b/modules/nixos/archetypes/workstation/default.nix index a4d0761..6f1d872 100644 --- a/modules/nixos/archetypes/workstation/default.nix +++ b/modules/nixos/archetypes/workstation/default.nix @@ -28,6 +28,7 @@ in { hardware.enable = true; # Common hardware support and tweaks fonts.enable = true; # Common fonts and font management tweaks audio.enable = true; # Audio setup + locale.enable = true; # Locale settings }; desktop.gnome.enable = true; diff --git a/modules/nixos/common/locale/default.nix b/modules/nixos/common/locale/default.nix new file mode 100644 index 0000000..7f1b7d2 --- /dev/null +++ b/modules/nixos/common/locale/default.nix @@ -0,0 +1,57 @@ +{ + lib, + inputs, + namespace, + config, + ... +}: with lib; with lib.${namespace}; +let + cfg = config.${namespace}.common.locale; +in { + options.${namespace}.common.locale = { + enable = mkEnableOption "whether to enable common locale tweaks"; + + language = mkOption { + type = types.str; + default = "en_US"; + example = "en_US"; + description = "Sets the language for most text, doesn't include monetary or measurement settings"; + }; + + country = mkOption { + type = types.str; + default = "de_DE"; + example = "de_DE"; + description = "Sets the language used for monetary or measurement settings (USD vs Euro, etc...)"; + }; + + keymap = mkOption { + type = types.str; + default = "de"; + example = "de"; + description = "Sets the keymap to be used by the system"; + }; + }; + + config = mkIf cfg.enable { + # Internationalisation properties. + i18n.defaultLocale = "${cfg.language}.UTF-8"; + i18n.extraLocaleSettings = { + LC_ADDRESS = "${cfg.country}.UTF-8"; + LC_IDENTIFICATION = "${cfg.country}.UTF-8"; + LC_MEASUREMENT = "${cfg.country}.UTF-8"; + LC_MONETARY = "${cfg.country}.UTF-8"; + LC_NAME = "${cfg.country}.UTF-8"; + LC_NUMERIC = "${cfg.country}.UTF-8"; + LC_PAPER = "${cfg.country}.UTF-8"; + LC_TELEPHONE = "${cfg.country}.UTF-8"; + LC_TIME = "${cfg.country}.UTF-8"; + }; + + # Set console keymap. + console.keyMap = ${cfg.keymap}; + services.xserver = { + xkb.layout = ${cfg.keymap}; + }; + }; +} diff --git a/systems/x86_64-linux/puzzlevision/default.nix b/systems/x86_64-linux/puzzlevision/default.nix index 83d694c..14b89d9 100644 --- a/systems/x86_64-linux/puzzlevision/default.nix +++ b/systems/x86_64-linux/puzzlevision/default.nix @@ -34,26 +34,6 @@ with lib.${namespace}; # Set timezone. time.timeZone = "Europe/Berlin"; - # Internationalisation properties. - i18n.defaultLocale = "en_US.UTF-8"; - i18n.extraLocaleSettings = { - LC_ADDRESS = "de_DE.UTF-8"; - LC_IDENTIFICATION = "de_DE.UTF-8"; - LC_MEASUREMENT = "de_DE.UTF-8"; - LC_MONETARY = "de_DE.UTF-8"; - LC_NAME = "de_DE.UTF-8"; - LC_NUMERIC = "de_DE.UTF-8"; - LC_PAPER = "de_DE.UTF-8"; - LC_TELEPHONE = "de_DE.UTF-8"; - LC_TIME = "de_DE.UTF-8"; - }; - - # Set console keymap. - console.keyMap = "de"; - services.xserver = { - xkb.layout = "de"; - }; - # Enable the power-profiles-daemon service for improved battery management. services.power-profiles-daemon.enable = true;