From 850be632a071c2d7dd2f9bdb333d1fdffbec3340 Mon Sep 17 00:00:00 2001 From: Eric Sagnes Date: Wed, 25 Nov 2015 16:29:50 +0900 Subject: [PATCH] fcitx service: init --- nixos/modules/i18n/inputMethod/fcitx.nix | 51 +++++++++++++++++++ nixos/modules/module-list.nix | 1 + .../fcitx-engines/fcitx-anthy/default.nix | 9 ++-- .../fcitx-engines/fcitx-chewing/default.nix | 13 ++--- .../fcitx-engines/fcitx-hangul/default.nix | 13 ++--- .../fcitx-engines/fcitx-mozc/default.nix | 13 ++--- .../fcitx-table-other/default.nix | 13 ++--- pkgs/top-level/all-packages.nix | 18 ++++--- 8 files changed, 96 insertions(+), 35 deletions(-) create mode 100644 nixos/modules/i18n/inputMethod/fcitx.nix diff --git a/nixos/modules/i18n/inputMethod/fcitx.nix b/nixos/modules/i18n/inputMethod/fcitx.nix new file mode 100644 index 00000000000..16fa8c764a8 --- /dev/null +++ b/nixos/modules/i18n/inputMethod/fcitx.nix @@ -0,0 +1,51 @@ +{ config, pkgs, lib, ... }: + +with lib; + +let + cfg = config.i18n.inputMethod.fcitx; + fcitxPackage = pkgs.fcitx-with-plugins.override { plugins = cfg.engines; }; + fcitxEngine = types.package // { + name = "fcitx-engine"; + check = x: (lib.types.package.check x) && (attrByPath ["meta" "isFcitxEngine"] false x); + }; +in +{ + options = { + + i18n.inputMethod.fcitx = { + enable = mkOption { + type = types.bool; + default = false; + example = true; + description = '' + Enable Fcitx input method. + Fcitx can be used to input of Chinese, Korean, Japanese and other special characters. + ''; + }; + engines = mkOption { + type = with types; listOf fcitxEngine; + default = []; + example = literalExample "with pkgs.fcitx-engines; [ mozc hangul ]"; + description = '' + Enabled Fcitx engines. + Available engines can be found by running `nix-env "<nixpkgs>" . -qaP -A fcitx-engines`. + ''; + }; + }; + + }; + + config = mkIf cfg.enable { + environment.systemPackages = [ fcitxPackage ]; + gtkPlugins = [ fcitxPackage ]; + qtPlugins = [ fcitxPackage pkgs.kde5.fcitx-qt5 ]; + + environment.variables = { + GTK_IM_MODULE = "fcitx"; + QT_IM_MODULE = "fcitx"; + XMODIFIERS = "@im=fcitx"; + }; + services.xserver.displayManager.sessionCommands = "${fcitxPackage}/bin/fcitx"; + }; +} diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 8254cdd6f5e..7375dcde5c5 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -43,6 +43,7 @@ ./hardware/video/nvidia.nix ./hardware/video/ati.nix ./hardware/video/webcam/facetimehd.nix + ./i18n/inputMethod/fcitx.nix ./installer/tools/auto-upgrade.nix ./installer/tools/nixos-checkout.nix ./installer/tools/tools.nix diff --git a/pkgs/tools/inputmethods/fcitx-engines/fcitx-anthy/default.nix b/pkgs/tools/inputmethods/fcitx-engines/fcitx-anthy/default.nix index c1cb76d3a68..88ba436207c 100644 --- a/pkgs/tools/inputmethods/fcitx-engines/fcitx-anthy/default.nix +++ b/pkgs/tools/inputmethods/fcitx-engines/fcitx-anthy/default.nix @@ -17,10 +17,11 @@ stdenv.mkDerivation rec { ''; meta = with stdenv.lib; { - description = "Fcitx Wrapper for anthy"; - license = licenses.gpl2Plus; - platforms = platforms.linux; - maintainers = with maintainers; [ iyzsong ericsagnes ]; + isFcitxEngine = true; + description = "Fcitx Wrapper for anthy"; + license = licenses.gpl2Plus; + platforms = platforms.linux; + maintainers = with maintainers; [ iyzsong ericsagnes ]; }; } diff --git a/pkgs/tools/inputmethods/fcitx-engines/fcitx-chewing/default.nix b/pkgs/tools/inputmethods/fcitx-engines/fcitx-chewing/default.nix index eb8897b9d5e..58695434cb6 100644 --- a/pkgs/tools/inputmethods/fcitx-engines/fcitx-chewing/default.nix +++ b/pkgs/tools/inputmethods/fcitx-engines/fcitx-chewing/default.nix @@ -19,12 +19,13 @@ stdenv.mkDerivation rec { ''; meta = with stdenv.lib; { - homepage = "https://github.com/fcitx/fcitx-chewing"; - downloadPage = "http://download.fcitx-im.org/fcitx-chewing/"; - description = "Fcitx engine for chewing"; - license = licenses.gpl2; - platforms = platforms.linux; - maintainers = with maintainers; [ ericsagnes ]; + isFcitxEngine = true; + homepage = "https://github.com/fcitx/fcitx-chewing"; + downloadPage = "http://download.fcitx-im.org/fcitx-chewing/"; + description = "Fcitx engine for chewing"; + license = licenses.gpl2; + platforms = platforms.linux; + maintainers = with maintainers; [ ericsagnes ]; }; } diff --git a/pkgs/tools/inputmethods/fcitx-engines/fcitx-hangul/default.nix b/pkgs/tools/inputmethods/fcitx-engines/fcitx-hangul/default.nix index 529bb29f98c..54b5335d9bb 100644 --- a/pkgs/tools/inputmethods/fcitx-engines/fcitx-hangul/default.nix +++ b/pkgs/tools/inputmethods/fcitx-engines/fcitx-hangul/default.nix @@ -19,11 +19,12 @@ stdenv.mkDerivation rec { ''; meta = with stdenv.lib; { - homepage = "https://github.com/fcitx/fcitx-hangul"; - downloadPage = "http://download.fcitx-im.org/fcitx-hangul/"; - description = "Fcitx Wrapper for hangul"; - license = licenses.gpl2; - platforms = platforms.linux; - maintainers = with maintainers; [ ericsagnes ]; + isFcitxEngine = true; + homepage = "https://github.com/fcitx/fcitx-hangul"; + downloadPage = "http://download.fcitx-im.org/fcitx-hangul/"; + description = "Fcitx Wrapper for hangul"; + license = licenses.gpl2; + platforms = platforms.linux; + maintainers = with maintainers; [ ericsagnes ]; }; } diff --git a/pkgs/tools/inputmethods/fcitx-engines/fcitx-mozc/default.nix b/pkgs/tools/inputmethods/fcitx-engines/fcitx-mozc/default.nix index 7accea3f0fd..5366fe55877 100644 --- a/pkgs/tools/inputmethods/fcitx-engines/fcitx-mozc/default.nix +++ b/pkgs/tools/inputmethods/fcitx-engines/fcitx-mozc/default.nix @@ -105,12 +105,13 @@ in clangStdenv.mkDerivation rec { ''; meta = with clangStdenv.lib; { - description = "Fcitx engine for Google japanese input method"; - homepage = http://code.google.com/p/mozc/; - downloadPage = "http://download.fcitx-im.org/fcitx-mozc/"; - license = licenses.free; - platforms = platforms.linux; - maintainers = [ maintainers.ericsagnes ]; + isFcitxEngine = true; + description = "Fcitx engine for Google japanese input method"; + homepage = http://code.google.com/p/mozc/; + downloadPage = "http://download.fcitx-im.org/fcitx-mozc/"; + license = licenses.free; + platforms = platforms.linux; + maintainers = [ maintainers.ericsagnes ]; }; } diff --git a/pkgs/tools/inputmethods/fcitx-engines/fcitx-table-other/default.nix b/pkgs/tools/inputmethods/fcitx-engines/fcitx-table-other/default.nix index d5e74f6ba06..40ef0b33aea 100644 --- a/pkgs/tools/inputmethods/fcitx-engines/fcitx-table-other/default.nix +++ b/pkgs/tools/inputmethods/fcitx-engines/fcitx-table-other/default.nix @@ -17,12 +17,13 @@ stdenv.mkDerivation rec { ''; meta = with stdenv.lib; { - homepage = "https://github.com/fcitx/fcitx-table-other"; - downloadPage = "http://download.fcitx-im.org/fcitx-table-other/"; - description = "Provides some other tables for Fcitx"; - license = licenses.gpl3Plus; - platforms = platforms.linux; - maintainers = with maintainers; [ ericsagnes ]; + isFcitxEngine = true; + homepage = "https://github.com/fcitx/fcitx-table-other"; + downloadPage = "http://download.fcitx-im.org/fcitx-table-other/"; + description = "Provides some other tables for Fcitx"; + license = licenses.gpl3Plus; + platforms = platforms.linux; + maintainers = with maintainers; [ ericsagnes ]; }; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index cb1d083555d..d2e26707c45 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -1511,18 +1511,22 @@ let fcitx = callPackage ../tools/inputmethods/fcitx { }; - fcitx-anthy = callPackage ../tools/inputmethods/fcitx-engines/fcitx-anthy { }; + fcitx-engines = { - fcitx-chewing = callPackage ../tools/inputmethods/fcitx-engines/fcitx-chewing { }; + anthy = callPackage ../tools/inputmethods/fcitx-engines/fcitx-anthy { }; - fcitx-hangul = callPackage ../tools/inputmethods/fcitx-engines/fcitx-hangul { }; + chewing = callPackage ../tools/inputmethods/fcitx-engines/fcitx-chewing { }; + + hangul = callPackage ../tools/inputmethods/fcitx-engines/fcitx-hangul { }; + + mozc = callPackage ../tools/inputmethods/fcitx-engines/fcitx-mozc { + inherit (pythonPackages) gyp; + }; + + table-other = callPackage ../tools/inputmethods/fcitx-engines/fcitx-table-other { }; - fcitx-mozc = callPackage ../tools/inputmethods/fcitx-engines/fcitx-mozc { - inherit (pythonPackages) gyp; }; - fcitx-table-other = callPackage ../tools/inputmethods/fcitx-engines/fcitx-table-other { }; - fcitx-configtool = callPackage ../tools/inputmethods/fcitx/fcitx-configtool.nix { }; fcitx-with-plugins = callPackage ../tools/inputmethods/fcitx/wrapper.nix {