mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-04-18 18:19:12 +00:00
profiles/i18n: refactor module
This commit is contained in:
parent
6d66f6645a
commit
9dc2df5397
@ -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; [
|
||||
|
@ -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";
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
@ -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";
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user