mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-04-24 12: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 = {
|
options.profiles.i18n = {
|
||||||
enable = lib.mkEnableOption "main i18n config";
|
enable = lib.mkEnableOption "main i18n config";
|
||||||
ibus.enable = lib.mkEnableOption "i18n config with ibus";
|
setup = lib.mkOption {
|
||||||
fcitx5.enable = lib.mkEnableOption "i18n config with fcitx5";
|
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 [
|
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
|
# I don't speak all of the languages. It's just nice to have some
|
||||||
# additional language packs for it. ;p
|
# additional language packs for it. ;p
|
||||||
i18n.supportedLocales = lib.mkForce [ "all" ];
|
i18n.supportedLocales = lib.mkForce [ "all" ];
|
||||||
@ -47,7 +46,7 @@ in
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
(lib.mkIf cfg.ibus.enable {
|
(lib.mkIf (cfg.setup == "ibus") {
|
||||||
i18n.inputMethod = {
|
i18n.inputMethod = {
|
||||||
enabled = "ibus";
|
enabled = "ibus";
|
||||||
ibus.engines = with pkgs.ibus-engines; [
|
ibus.engines = with pkgs.ibus-engines; [
|
||||||
@ -62,7 +61,7 @@ in
|
|||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
(lib.mkIf cfg.fcitx5.enable {
|
(lib.mkIf (cfg.setup == "fcitx5") {
|
||||||
i18n.inputMethod = {
|
i18n.inputMethod = {
|
||||||
enabled = "fcitx5";
|
enabled = "fcitx5";
|
||||||
fcitx5.addons = with pkgs; [
|
fcitx5.addons = with pkgs; [
|
||||||
|
@ -156,10 +156,7 @@ in
|
|||||||
|
|
||||||
# Check whether this is inside of my personal configuration or nah.
|
# Check whether this is inside of my personal configuration or nah.
|
||||||
(lib.mkIf (attrs ? _isfoodogsquaredcustom && attrs._isfoodogsquaredcustom) {
|
(lib.mkIf (attrs ? _isfoodogsquaredcustom && attrs._isfoodogsquaredcustom) {
|
||||||
profiles.i18n = lib.mkDefault {
|
profiles.i18n.setup = "ibus";
|
||||||
enable = true;
|
|
||||||
ibus.enable = true;
|
|
||||||
};
|
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -183,10 +183,7 @@ in
|
|||||||
# of the flake input, this shouldn't be applied nor be used in the first
|
# of the flake input, this shouldn't be applied nor be used in the first
|
||||||
# place.
|
# place.
|
||||||
(lib.mkIf (attrs ? _isfoodogsquaredcustom && attrs._isfoodogsquaredcustom) {
|
(lib.mkIf (attrs ? _isfoodogsquaredcustom && attrs._isfoodogsquaredcustom) {
|
||||||
profiles.i18n = {
|
profiles.i18n.setup = "ibus";
|
||||||
enable = true;
|
|
||||||
ibus.enable = true;
|
|
||||||
};
|
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user