From 52dd53373f7fa134b0e697a0f102490f3f4ade87 Mon Sep 17 00:00:00 2001 From: Eric Sagnes Date: Wed, 10 Feb 2016 16:10:35 +0900 Subject: [PATCH] ibus service: refactoring --- nixos/modules/i18n/inputMethod/ibus.nix | 52 +++++++++++++++++++ nixos/modules/module-list.nix | 2 +- nixos/modules/programs/ibus.nix | 51 ------------------ nixos/modules/rename.nix | 4 ++ .../ibus-engines/ibus-anthy/default.nix | 11 ++-- .../ibus-engines/ibus-hangul/default.nix | 11 ++-- .../ibus-engines/ibus-mozc/default.nix | 11 ++-- .../ibus-table-others/default.nix | 11 ++-- .../ibus-engines/ibus-table/default.nix | 11 ++-- 9 files changed, 87 insertions(+), 77 deletions(-) create mode 100644 nixos/modules/i18n/inputMethod/ibus.nix delete mode 100644 nixos/modules/programs/ibus.nix diff --git a/nixos/modules/i18n/inputMethod/ibus.nix b/nixos/modules/i18n/inputMethod/ibus.nix new file mode 100644 index 000000000000..e4bc15cf8912 --- /dev/null +++ b/nixos/modules/i18n/inputMethod/ibus.nix @@ -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"; + }; +} diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 7375dcde5c5c..3df4e08e24bc 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -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 diff --git a/nixos/modules/programs/ibus.nix b/nixos/modules/programs/ibus.nix deleted file mode 100644 index a42753a292b2..000000000000 --- a/nixos/modules/programs/ibus.nix +++ /dev/null @@ -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"; - }; -} diff --git a/nixos/modules/rename.nix b/nixos/modules/rename.nix index 6e10b47f03cc..698c28f37c8e 100644 --- a/nixos/modules/rename.nix +++ b/nixos/modules/rename.nix @@ -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" ]) diff --git a/pkgs/tools/inputmethods/ibus-engines/ibus-anthy/default.nix b/pkgs/tools/inputmethods/ibus-engines/ibus-anthy/default.nix index 4bdee391880b..89039745fd99 100644 --- a/pkgs/tools/inputmethods/ibus-engines/ibus-anthy/default.nix +++ b/pkgs/tools/inputmethods/ibus-engines/ibus-anthy/default.nix @@ -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"; diff --git a/pkgs/tools/inputmethods/ibus-engines/ibus-hangul/default.nix b/pkgs/tools/inputmethods/ibus-engines/ibus-hangul/default.nix index 5a6af4608c0f..b682196d5d08 100644 --- a/pkgs/tools/inputmethods/ibus-engines/ibus-hangul/default.nix +++ b/pkgs/tools/inputmethods/ibus-engines/ibus-hangul/default.nix @@ -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 ]; }; } diff --git a/pkgs/tools/inputmethods/ibus-engines/ibus-mozc/default.nix b/pkgs/tools/inputmethods/ibus-engines/ibus-mozc/default.nix index 9ab640990b16..e06d2b004ee9 100644 --- a/pkgs/tools/inputmethods/ibus-engines/ibus-mozc/default.nix +++ b/pkgs/tools/inputmethods/ibus-engines/ibus-mozc/default.nix @@ -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 ]; diff --git a/pkgs/tools/inputmethods/ibus-engines/ibus-table-others/default.nix b/pkgs/tools/inputmethods/ibus-engines/ibus-table-others/default.nix index f356bcdee85d..13d9df5de081 100644 --- a/pkgs/tools/inputmethods/ibus-engines/ibus-table-others/default.nix +++ b/pkgs/tools/inputmethods/ibus-engines/ibus-table-others/default.nix @@ -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 ]; }; } diff --git a/pkgs/tools/inputmethods/ibus-engines/ibus-table/default.nix b/pkgs/tools/inputmethods/ibus-engines/ibus-table/default.nix index 58b890b0c929..244169cf46b6 100644 --- a/pkgs/tools/inputmethods/ibus-engines/ibus-table/default.nix +++ b/pkgs/tools/inputmethods/ibus-engines/ibus-table/default.nix @@ -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 ]; }; }