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/webcam/facetimehd.nix
./i18n/inputMethod/fcitx.nix
./i18n/inputMethod/ibus.nix
./installer/tools/auto-upgrade.nix
./installer/tools/nixos-checkout.nix
./installer/tools/tools.nix
@ -67,7 +68,6 @@
./programs/environment.nix
./programs/freetds.nix
./programs/fish.nix
./programs/ibus.nix
./programs/kbdlight.nix
./programs/light.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
(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
(mkRenamedOptionModule [ "nix" "proxy" ] [ "networking" "proxy" "default" ])

View File

@ -6,11 +6,12 @@ stdenv.mkDerivation rec {
version = "1.5.8";
meta = with stdenv.lib; {
description = "IBus interface to the anthy input method";
homepage = http://wiki.github.com/fujiwarat/ibus-anthy;
license = licenses.gpl2Plus;
platforms = platforms.linux;
maintainers = with maintainers; [ gebner ericsagnes ];
isIbusEngine = true;
description = "IBus interface to the anthy input method";
homepage = http://wiki.github.com/fujiwarat/ibus-anthy;
license = licenses.gpl2Plus;
platforms = platforms.linux;
maintainers = with maintainers; [ gebner ericsagnes ];
};
preConfigure = "./autogen.sh --prefix=$out";

View File

@ -29,10 +29,11 @@ stdenv.mkDerivation rec {
'';
meta = with stdenv.lib; {
description = "Ibus Hangul engine.";
homepage = https://github.com/choehwanjin/ibus-hangul;
license = licenses.gpl2;
platforms = platforms.linux;
maintainers = with maintainers; [ ericsagnes ];
isIbusEngine = true;
description = "Ibus Hangul engine.";
homepage = https://github.com/choehwanjin/ibus-hangul;
license = licenses.gpl2;
platforms = platforms.linux;
maintainers = with maintainers; [ ericsagnes ];
};
}

View File

@ -11,11 +11,12 @@ in clangStdenv.mkDerivation rec {
version = "2.17.2313.102";
meta = with clangStdenv.lib; {
description = "Japanese input method from Google";
homepage = http://code.google.com/p/mozc/;
license = licenses.free;
platforms = platforms.linux;
maintainers = with maintainers; [ gebner ericsagnes ];
isIbusEngine = true;
description = "Japanese input method from Google";
homepage = http://code.google.com/p/mozc/;
license = licenses.free;
platforms = platforms.linux;
maintainers = with maintainers; [ gebner ericsagnes ];
};
nativeBuildInputs = [ gyp which ninja python pkgconfig ];

View File

@ -20,10 +20,11 @@ stdenv.mkDerivation rec {
'';
meta = with stdenv.lib; {
description = "Various table-based input methods for IBus";
homepage = https://github.com/moebiuscurve/ibus-table-others;
license = licenses.gpl3;
platforms = platforms.linux;
maintainers = with maintainers; [ mudri ];
isIbusEngine = true;
description = "Various table-based input methods for IBus";
homepage = https://github.com/moebiuscurve/ibus-table-others;
license = licenses.gpl3;
platforms = platforms.linux;
maintainers = with maintainers; [ mudri ];
};
}

View File

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