mirror of
https://github.com/nix-community/home-manager
synced 2025-02-17 05:35:06 +01:00
fcitx5: add configurability of input methods
added option to configure input methods/groups in fcitx
This commit is contained in:
parent
04213d1ce4
commit
82a9746018
4 changed files with 125 additions and 0 deletions
|
@ -1,12 +1,61 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
|
||||
with lib;
|
||||
with types;
|
||||
|
||||
let
|
||||
im = config.i18n.inputMethod;
|
||||
cfg = im.fcitx5;
|
||||
fcitx5Package =
|
||||
pkgs.libsForQt5.fcitx5-with-addons.override { inherit (cfg) addons; };
|
||||
|
||||
inputItem = {
|
||||
options = {
|
||||
name = mkOption {
|
||||
type = str;
|
||||
description = ''
|
||||
Name of the input method
|
||||
'';
|
||||
};
|
||||
layout = mkOption {
|
||||
type = str;
|
||||
default = "";
|
||||
description = ''
|
||||
Override the group's default layout
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
inputGroup = {
|
||||
options = {
|
||||
name = mkOption {
|
||||
type = str;
|
||||
description = ''
|
||||
Name of this input group
|
||||
'';
|
||||
};
|
||||
defaultLayout = mkOption {
|
||||
type = str;
|
||||
description = ''
|
||||
Default keyboard layout for this group
|
||||
'';
|
||||
};
|
||||
defaultIm = mkOption {
|
||||
type = str;
|
||||
description = ''
|
||||
Default IM for this group
|
||||
'';
|
||||
};
|
||||
items = mkOption {
|
||||
type = listOf (submodule inputItem);
|
||||
description = ''
|
||||
List of individual input methods
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
in {
|
||||
options = {
|
||||
i18n.inputMethod.fcitx5 = {
|
||||
|
@ -18,12 +67,48 @@ in {
|
|||
Enabled Fcitx5 addons.
|
||||
'';
|
||||
};
|
||||
|
||||
inputs = mkOption {
|
||||
type = listOf (submodule inputGroup);
|
||||
description = ''
|
||||
List of input groups
|
||||
'';
|
||||
example = [{
|
||||
name = "Default";
|
||||
defaultLayout = "us";
|
||||
defaultIm = "mozc";
|
||||
items = [ { name = "keyboard-us"; } { name = "mozc"; } ];
|
||||
}];
|
||||
default = [ ];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf (im.enabled == "fcitx5") {
|
||||
i18n.inputMethod.package = fcitx5Package;
|
||||
|
||||
xdg.configFile."fcitx5/profile" = mkIf (im.fcitx5.inputs != [ ]) {
|
||||
text = ''
|
||||
${concatStrings (lists.imap0 (i: v: ''
|
||||
[Groups/${toString i}]
|
||||
Name=${v.name}
|
||||
Default Layout=${v.defaultLayout}
|
||||
DefaultIM=${v.defaultIm}
|
||||
|
||||
${
|
||||
concatStrings (lists.imap0 (i2: v2: ''
|
||||
[Groups/${toString i}/Items/${toString i2}]
|
||||
Name=${v2.name}
|
||||
Layout=${v2.layout}
|
||||
'') v.items)
|
||||
} '') im.fcitx5.inputs)}
|
||||
[GroupOrder]
|
||||
${concatStrings (lists.imap0 (i: v: ''
|
||||
${toString i}=${v.name}
|
||||
'') im.fcitx5.inputs)}
|
||||
'';
|
||||
};
|
||||
|
||||
home.sessionVariables = {
|
||||
GLFW_IM_MODULE = "ibus"; # IME support in kitty
|
||||
GTK_IM_MODULE = "fcitx";
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
input-method-fcitx5-configuration = ./fcitx5-configuration.nix;
|
||||
input-method-fcitx5-configuration-full = ./fcitx5-configuration-full.nix;
|
||||
input-method-kime-configuration = ./kime-configuration.nix;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
imports = [ ./fcitx5-stubs.nix ];
|
||||
|
||||
i18n.inputMethod = {
|
||||
enabled = "fcitx5";
|
||||
fcitx5 = {
|
||||
addons = with pkgs; [ fcitx5-mozc ];
|
||||
|
||||
inputs = [{
|
||||
name = "Default";
|
||||
defaultLayout = "us";
|
||||
defaultIm = "mozc";
|
||||
items = [ { name = "keyboard-us"; } { name = "mozc"; } ];
|
||||
}];
|
||||
};
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContent \
|
||||
home-files/.config/fcitx5/profile \
|
||||
${./fcitx5-profile}
|
||||
'';
|
||||
}
|
14
tests/modules/i18n/input-method/fcitx5-profile
Normal file
14
tests/modules/i18n/input-method/fcitx5-profile
Normal file
|
@ -0,0 +1,14 @@
|
|||
[Groups/0]
|
||||
Name=Default
|
||||
Default Layout=us
|
||||
DefaultIM=mozc
|
||||
|
||||
[Groups/0/Items/0]
|
||||
Name=keyboard-us
|
||||
Layout=
|
||||
[Groups/0/Items/1]
|
||||
Name=mozc
|
||||
Layout=
|
||||
|
||||
[GroupOrder]
|
||||
0=Default
|
Loading…
Add table
Reference in a new issue