ibus service: refactoring

This commit is contained in:
Eric Sagnes 2016-02-10 16:10:35 +09:00
parent 7ec5dc9234
commit 52dd53373f
9 changed files with 87 additions and 77 deletions

View File

@ -0,0 +1,52 @@
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.i18n.inputMethod.ibus;
ibusPackage = pkgs.ibus-with-plugins.override { plugins = cfg.engines; };
ibusEngine = types.package // {
name = "ibus-engine";
check = x: (lib.types.package.check x) && (attrByPath ["meta" "isIbusEngine"] false x);
};
in
{
options = {
i18n.inputMethod.ibus = {
enable = mkOption {
type = types.bool;
default = false;
example = true;
description = ''
Enable IBus input method.
IBus can be used input of Chinese, Korean, Japanese and other special characters.
'';
};
engines = mkOption {
type = with types; listOf ibusEngine;
default = [];
example = literalExample "with pkgs.ibus-engines; [ mozc hangul ]";
description = ''
Enabled IBus engines.
Available engines can be found by running `nix-env "<nixpkgs>" . -qaP -A ibus-engines`.
'';
};
};
};
config = mkIf cfg.enable {
# Without dconf enabled it is impossible to use IBus
environment.systemPackages = [ ibusPackage pkgs.gnome3.dconf ];
gtkPlugins = [ pkgs.ibus ];
qtPlugins = [ pkgs.ibus-qt ];
environment.variables = {
GTK_IM_MODULE = "ibus";
QT_IM_MODULE = "ibus";
XMODIFIERS = "@im=ibus";
};
services.xserver.displayManager.sessionCommands = "${ibusPackage}/bin/ibus-daemon --daemonize --xim --cache=none";
};
}

View File

@ -44,6 +44,7 @@
./hardware/video/ati.nix ./hardware/video/ati.nix
./hardware/video/webcam/facetimehd.nix ./hardware/video/webcam/facetimehd.nix
./i18n/inputMethod/fcitx.nix ./i18n/inputMethod/fcitx.nix
./i18n/inputMethod/ibus.nix
./installer/tools/auto-upgrade.nix ./installer/tools/auto-upgrade.nix
./installer/tools/nixos-checkout.nix ./installer/tools/nixos-checkout.nix
./installer/tools/tools.nix ./installer/tools/tools.nix
@ -67,7 +68,6 @@
./programs/environment.nix ./programs/environment.nix
./programs/freetds.nix ./programs/freetds.nix
./programs/fish.nix ./programs/fish.nix
./programs/ibus.nix
./programs/kbdlight.nix ./programs/kbdlight.nix
./programs/light.nix ./programs/light.nix
./programs/man.nix ./programs/man.nix

View File

@ -1,51 +0,0 @@
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.programs.ibus;
in
{
options = {
programs.ibus = {
enable = mkOption {
type = types.bool;
default = false;
example = true;
description = "Enable IBus input method";
};
plugins = mkOption {
type = lib.types.listOf lib.types.path;
default = [];
description = ''
IBus plugin packages
'';
};
};
};
config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.ibus pkgs.gnome3.dconf ];
gtkPlugins = [ pkgs.ibus ];
qtPlugins = [ pkgs.ibus-qt ];
environment.variables =
let
env = pkgs.buildEnv {
name = "ibus-env";
paths = [ pkgs.ibus ] ++ cfg.plugins;
};
in {
GTK_IM_MODULE = "ibus";
QT_IM_MODULE = "ibus";
XMODIFIERS = "@im=ibus";
IBUS_COMPONENT_PATH = "${env}/share/ibus/component";
};
services.xserver.displayManager.sessionCommands = "${pkgs.ibus}/bin/ibus-daemon --daemonize --xim --cache=none";
};
}

View File

@ -59,6 +59,10 @@ with lib;
# Tarsnap # Tarsnap
(mkRenamedOptionModule [ "services" "tarsnap" "config" ] [ "services" "tarsnap" "archives" ]) (mkRenamedOptionModule [ "services" "tarsnap" "config" ] [ "services" "tarsnap" "archives" ])
# ibus
(mkRenamedOptionModule [ "programs" "ibus" "enable" ] [ "i18n" "inputMethod" "ibus" "enable" ])
(mkRenamedOptionModule [ "programs" "ibus" "plugins" ] [ "i18n" "inputMethod" "ibus" "engines" ])
# proxy # proxy
(mkRenamedOptionModule [ "nix" "proxy" ] [ "networking" "proxy" "default" ]) (mkRenamedOptionModule [ "nix" "proxy" ] [ "networking" "proxy" "default" ])

View File

@ -6,6 +6,7 @@ stdenv.mkDerivation rec {
version = "1.5.8"; version = "1.5.8";
meta = with stdenv.lib; { meta = with stdenv.lib; {
isIbusEngine = true;
description = "IBus interface to the anthy input method"; description = "IBus interface to the anthy input method";
homepage = http://wiki.github.com/fujiwarat/ibus-anthy; homepage = http://wiki.github.com/fujiwarat/ibus-anthy;
license = licenses.gpl2Plus; license = licenses.gpl2Plus;

View File

@ -29,6 +29,7 @@ stdenv.mkDerivation rec {
''; '';
meta = with stdenv.lib; { meta = with stdenv.lib; {
isIbusEngine = true;
description = "Ibus Hangul engine."; description = "Ibus Hangul engine.";
homepage = https://github.com/choehwanjin/ibus-hangul; homepage = https://github.com/choehwanjin/ibus-hangul;
license = licenses.gpl2; license = licenses.gpl2;

View File

@ -11,6 +11,7 @@ in clangStdenv.mkDerivation rec {
version = "2.17.2313.102"; version = "2.17.2313.102";
meta = with clangStdenv.lib; { meta = with clangStdenv.lib; {
isIbusEngine = true;
description = "Japanese input method from Google"; description = "Japanese input method from Google";
homepage = http://code.google.com/p/mozc/; homepage = http://code.google.com/p/mozc/;
license = licenses.free; license = licenses.free;

View File

@ -20,6 +20,7 @@ stdenv.mkDerivation rec {
''; '';
meta = with stdenv.lib; { meta = with stdenv.lib; {
isIbusEngine = true;
description = "Various table-based input methods for IBus"; description = "Various table-based input methods for IBus";
homepage = https://github.com/moebiuscurve/ibus-table-others; homepage = https://github.com/moebiuscurve/ibus-table-others;
license = licenses.gpl3; license = licenses.gpl3;

View File

@ -12,6 +12,7 @@ stdenv.mkDerivation rec {
buildInputs = [ ibus pkgconfig python3 pythonPackages.pygobject3 ]; buildInputs = [ ibus pkgconfig python3 pythonPackages.pygobject3 ];
meta = with stdenv.lib; { meta = with stdenv.lib; {
isIbusEngine = true;
description = "An IBus framework for table-based input methods"; description = "An IBus framework for table-based input methods";
homepage = https://github.com/kaio/ibus-table/wiki; homepage = https://github.com/kaio/ibus-table/wiki;
license = licenses.lgpl21; license = licenses.lgpl21;