refactor(module): move locale config to own nixos module

This commit is contained in:
Jo 2024-09-07 08:58:12 +02:00
parent 078657f1e2
commit 3f767068d2
3 changed files with 58 additions and 20 deletions

View file

@ -28,6 +28,7 @@ in {
hardware.enable = true; # Common hardware support and tweaks hardware.enable = true; # Common hardware support and tweaks
fonts.enable = true; # Common fonts and font management tweaks fonts.enable = true; # Common fonts and font management tweaks
audio.enable = true; # Audio setup audio.enable = true; # Audio setup
locale.enable = true; # Locale settings
}; };
desktop.gnome.enable = true; desktop.gnome.enable = true;

View file

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

View file

@ -34,26 +34,6 @@ with lib.${namespace};
# Set timezone. # Set timezone.
time.timeZone = "Europe/Berlin"; 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. # Enable the power-profiles-daemon service for improved battery management.
services.power-profiles-daemon.enable = true; services.power-profiles-daemon.enable = true;