summaryrefslogtreecommitdiff
path: root/modules/ibus.nix
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2022-03-11 13:49:58 +0100
committerGregor Kleen <gkleen@yggdrasil.li>2022-03-11 13:49:58 +0100
commit1f4ff029be789298f7732d6f2a153a234cbb5267 (patch)
tree68743b026e781c3ea21bdbf5fe7f64553a77b901 /modules/ibus.nix
parenta15e8ba52bcc079f1144cd9e532064d079a5e722 (diff)
downloadnixos-1f4ff029be789298f7732d6f2a153a234cbb5267.tar
nixos-1f4ff029be789298f7732d6f2a153a234cbb5267.tar.gz
nixos-1f4ff029be789298f7732d6f2a153a234cbb5267.tar.bz2
nixos-1f4ff029be789298f7732d6f2a153a234cbb5267.tar.xz
nixos-1f4ff029be789298f7732d6f2a153a234cbb5267.zip
ibus: ...
Diffstat (limited to 'modules/ibus.nix')
-rw-r--r--modules/ibus.nix79
1 files changed, 79 insertions, 0 deletions
diff --git a/modules/ibus.nix b/modules/ibus.nix
new file mode 100644
index 00000000..bb9b3765
--- /dev/null
+++ b/modules/ibus.nix
@@ -0,0 +1,79 @@
1{ config, pkgs, lib, ... }:
2
3with lib;
4
5let
6 cfg = config.i18n.inputMethod.ibus;
7 ibusPackage = pkgs.ibus-with-plugins.override { plugins = cfg.engines; };
8 ibusEngine = types.package // {
9 name = "ibus-engine";
10 check = x: (lib.types.package.check x) && (attrByPath ["meta" "isIbusEngine"] false x);
11 };
12in
13{
14 disabledModules = [ "i18n/input-method/ibus.nix" ];
15
16 imports = [
17 (mkRenamedOptionModule [ "programs" "ibus" "plugins" ] [ "i18n" "inputMethod" "ibus" "engines" ])
18 ];
19
20 options = {
21 i18n.inputMethod.ibus = {
22 engines = mkOption {
23 type = with types; listOf ibusEngine;
24 default = [];
25 example = literalExpression "with pkgs.ibus-engines; [ mozc hangul ]";
26 description =
27 let
28 enginesDrv = filterAttrs (const isDerivation) pkgs.ibus-engines;
29 engines = concatStringsSep ", "
30 (map (name: "<literal>${name}</literal>") (attrNames enginesDrv));
31 in
32 "Enabled IBus engines. Available engines are: ${engines}.";
33 };
34 panel = mkOption {
35 type = with types; nullOr path;
36 default = null;
37 example = literalExpression ''"''${pkgs.plasma5Packages.plasma-desktop}/lib/libexec/kimpanel-ibus-panel"'';
38 description = "Replace the IBus panel with another panel.";
39 };
40 };
41 };
42
43 config = mkIf (config.i18n.inputMethod.enabled == "ibus") {
44 i18n.inputMethod.package = ibusPackage;
45
46 # Without dconf enabled it is impossible to use IBus
47 programs.dconf.enable = true;
48
49 programs.dconf.packages = [ ibusPackage ];
50
51 environment.variables = {
52 GTK_IM_MODULE = "ibus";
53 QT_IM_MODULE = "ibus";
54 XMODIFIERS = "@im=ibus";
55 };
56
57 xdg.portal.extraPortals = mkIf config.xdg.portal.enable [
58 ibusPackage
59 ];
60
61 systemd.user.services.ibus = {
62 description = "Intelligent Input Bus";
63 documentation = ["man:ibus-daemon(1)"];
64 after = ["graphical-session-pre.target"];
65 wantedBy = ["graphical-session.target"];
66
67 serviceConfig = {
68 Type = "dbus";
69 BusName = "org.freedesktop.IBus";
70 ExecStart = "${ibusPackage}/bin/ibus-daemon --xim ${optionalString (cfg.panel != null) "--panel ${cfg.panel}"}";
71 ExecReload = "${ibusPackage}/bin/ibus restart";
72 ExecStop = "${ibusPackage}/bin/ibus exit";
73 };
74 };
75 };
76
77 # uses attributes of the linked package
78 meta.buildDocsInSandbox = false;
79}