profiles/i18n: refactor module

This commit is contained in:
Gabriel Arazas 2023-12-13 11:24:04 +08:00
parent 6d66f6645a
commit 9dc2df5397
No known key found for this signature in database
GPG Key ID: ADE0C41DAB221FCC
3 changed files with 13 additions and 20 deletions

View File

@ -9,20 +9,19 @@ in
{
options.profiles.i18n = {
enable = lib.mkEnableOption "main i18n config";
ibus.enable = lib.mkEnableOption "i18n config with ibus";
fcitx5.enable = lib.mkEnableOption "i18n config with fcitx5";
setup = lib.mkOption {
type = lib.types.enum [ "fcitx5" "ibus" ];
description = ''
The primary input method engine to be used and its related
configuration and setup.
'';
default = "fcitx5";
example = "ibus";
};
};
config = lib.mkIf cfg.enable (lib.mkMerge [
{
assertions = let enabledi18nConfigs = lib.countAttrs (_: setup: lib.isAttrs setup && setup.enable) cfg; in
[{
assertion = enabledi18nConfigs <= 1;
message = ''
Only one i18n setup should be enabled at any given time.
'';
}];
# I don't speak all of the languages. It's just nice to have some
# additional language packs for it. ;p
i18n.supportedLocales = lib.mkForce [ "all" ];
@ -47,7 +46,7 @@ in
];
}
(lib.mkIf cfg.ibus.enable {
(lib.mkIf (cfg.setup == "ibus") {
i18n.inputMethod = {
enabled = "ibus";
ibus.engines = with pkgs.ibus-engines; [
@ -62,7 +61,7 @@ in
};
})
(lib.mkIf cfg.fcitx5.enable {
(lib.mkIf (cfg.setup == "fcitx5") {
i18n.inputMethod = {
enabled = "fcitx5";
fcitx5.addons = with pkgs; [

View File

@ -156,10 +156,7 @@ in
# Check whether this is inside of my personal configuration or nah.
(lib.mkIf (attrs ? _isfoodogsquaredcustom && attrs._isfoodogsquaredcustom) {
profiles.i18n = lib.mkDefault {
enable = true;
ibus.enable = true;
};
profiles.i18n.setup = "ibus";
})
]);
}

View File

@ -183,10 +183,7 @@ in
# of the flake input, this shouldn't be applied nor be used in the first
# place.
(lib.mkIf (attrs ? _isfoodogsquaredcustom && attrs._isfoodogsquaredcustom) {
profiles.i18n = {
enable = true;
ibus.enable = true;
};
profiles.i18n.setup = "ibus";
})
]);
}