diff options
author | linsui <linsui555@gmail.com> | 2023-07-23 14:24:08 +0800 |
---|---|---|
committer | linsui <linsui@inbox.lv> | 2023-08-14 16:25:17 +0800 |
commit | 30bb15152e0ee83d9be9be77b08af267966bb31c (patch) | |
tree | 4ccb8f10a0be90b5abbbe5febcd22fd7204fa385 /nixos | |
parent | 450d6437aeda4c90bb948f6f1f7d25a005ab9bb2 (diff) | |
download | nixpkgs-30bb15152e0ee83d9be9be77b08af267966bb31c.tar nixpkgs-30bb15152e0ee83d9be9be77b08af267966bb31c.tar.gz nixpkgs-30bb15152e0ee83d9be9be77b08af267966bb31c.tar.bz2 nixpkgs-30bb15152e0ee83d9be9be77b08af267966bb31c.tar.lz nixpkgs-30bb15152e0ee83d9be9be77b08af267966bb31c.tar.xz nixpkgs-30bb15152e0ee83d9be9be77b08af267966bb31c.tar.zst nixpkgs-30bb15152e0ee83d9be9be77b08af267966bb31c.zip |
nixos/fcitx5: add settings
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/i18n/input-method/fcitx5.nix | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/nixos/modules/i18n/input-method/fcitx5.nix b/nixos/modules/i18n/input-method/fcitx5.nix index b72f4be9b57..36022b2af82 100644 --- a/nixos/modules/i18n/input-method/fcitx5.nix +++ b/nixos/modules/i18n/input-method/fcitx5.nix @@ -6,6 +6,7 @@ let im = config.i18n.inputMethod; cfg = im.fcitx5; fcitx5Package = pkgs.fcitx5-with-addons.override { inherit (cfg) addons; }; + settingsFormat = pkgs.formats.ini { }; in { options = { @@ -40,6 +41,44 @@ in ''; description = lib.mdDoc "Quick phrase files."; }; + settings = { + globalOptions = lib.mkOption { + type = lib.types.submodule { + freeformType = settingsFormat.type; + }; + default = { }; + description = lib.mdDoc '' + The global options in `config` file in ini format. + ''; + }; + inputMethod = lib.mkOption { + type = lib.types.submodule { + freeformType = settingsFormat.type; + }; + default = { }; + description = lib.mdDoc '' + The input method configure in `profile` file in ini format. + ''; + }; + addons = lib.mkOption { + type = with lib.types; (attrsOf anything); + default = { }; + description = lib.mdDoc '' + The addon configures in `conf` folder in ini format with global sections. + Each item is written to the corresponding file. + ''; + example = literalExpression "{ pinyin.globalSection.EmojiEnabled = \"True\"; }"; + }; + }; + ignoreUserConfig = lib.mkOption { + type = lib.types.bool; + default = false; + description = lib.mdDoc '' + Ignore the user configures. **Warning**: When this is enabled, the + user config files are totally ignored and the user dict can't be saved + and loaded. + ''; + }; }; }; @@ -61,12 +100,30 @@ in (name: value: lib.nameValuePair ("share/fcitx5/data/quickphrase.d/${name}.mb") value) cfg.quickPhraseFiles)) ]; + environment.etc = + let + optionalFile = p: f: v: lib.optionalAttrs (v != { }) { + "xdg/fcitx5/${p}".text = f v; + }; + in + lib.attrsets.mergeAttrsList [ + (optionalFile "config" (lib.generators.toINI { }) sts.globalOptions) + (optionalFile "profile" (lib.generators.toINI { }) sts.inputMethod) + (lib.concatMapAttrs + (name: value: optionalFile + "conf/${name}.conf" + (lib.generators.toINIWithGlobalSection { }) + value) + sts.addons) + ]; environment.variables = { GTK_IM_MODULE = "fcitx"; QT_IM_MODULE = "fcitx"; XMODIFIERS = "@im=fcitx"; QT_PLUGIN_PATH = [ "${fcitx5Package}/${pkgs.qt6.qtbase.qtPluginPrefix}" ]; + } // lib.optionalAttrs cfg.ignoreUserConfig { + SKIP_FCITX_USER_PATH = "1"; }; }; } |