diff options
Diffstat (limited to 'nixpkgs/nixos/modules/i18n/input-method/fcitx.nix')
-rw-r--r-- | nixpkgs/nixos/modules/i18n/input-method/fcitx.nix | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/nixpkgs/nixos/modules/i18n/input-method/fcitx.nix b/nixpkgs/nixos/modules/i18n/input-method/fcitx.nix new file mode 100644 index 000000000000..440f13b41522 --- /dev/null +++ b/nixpkgs/nixos/modules/i18n/input-method/fcitx.nix @@ -0,0 +1,43 @@ +{ config, pkgs, lib, ... }: + +with lib; + +let + cfg = config.i18n.inputMethod.fcitx; + fcitxPackage = pkgs.fcitx.override { plugins = cfg.engines; }; + fcitxEngine = types.package // { + name = "fcitx-engine"; + check = x: (lib.types.package.check x) && (attrByPath ["meta" "isFcitxEngine"] false x); + }; +in +{ + options = { + + i18n.inputMethod.fcitx = { + engines = mkOption { + type = with types; listOf fcitxEngine; + default = []; + example = literalExample "with pkgs.fcitx-engines; [ mozc hangul ]"; + description = + let + enginesDrv = filterAttrs (const isDerivation) pkgs.fcitx-engines; + engines = concatStringsSep ", " + (map (name: "<literal>${name}</literal>") (attrNames enginesDrv)); + in + "Enabled Fcitx engines. Available engines are: ${engines}."; + }; + }; + + }; + + config = mkIf (config.i18n.inputMethod.enabled == "fcitx") { + i18n.inputMethod.package = fcitxPackage; + + environment.variables = { + GTK_IM_MODULE = "fcitx"; + QT_IM_MODULE = "fcitx"; + XMODIFIERS = "@im=fcitx"; + }; + services.xserver.displayManager.sessionCommands = "${fcitxPackage}/bin/fcitx"; + }; +} |