diff --git a/nixos/modules/i18n/input-method/default.nix b/nixos/modules/i18n/input-method/default.nix index 4649f9b862a5..bbc5783565a3 100644 --- a/nixos/modules/i18n/input-method/default.nix +++ b/nixos/modules/i18n/input-method/default.nix @@ -29,7 +29,7 @@ in options.i18n = { inputMethod = { enabled = mkOption { - type = types.nullOr (types.enum [ "ibus" "fcitx" "fcitx5" "nabi" "uim" "hime" ]); + type = types.nullOr (types.enum [ "ibus" "fcitx" "fcitx5" "nabi" "uim" "hime" "kime" ]); default = null; example = "fcitx"; description = '' @@ -46,6 +46,7 @@ in nabi: A Korean input method based on XIM. Nabi doesn't support Qt 5. uim: The universal input method, is a library with a XIM bridge. uim mainly support Chinese, Japanese and Korean. hime: An extremely easy-to-use input method framework. + kime: Koream IME. ''; }; diff --git a/nixos/modules/i18n/input-method/default.xml b/nixos/modules/i18n/input-method/default.xml index 73911059f8a6..dd66316c7308 100644 --- a/nixos/modules/i18n/input-method/default.xml +++ b/nixos/modules/i18n/input-method/default.xml @@ -40,6 +40,11 @@ Hime: An extremely easy-to-use input method framework. + + + Kime: Korean IME + +
IBus @@ -264,6 +269,23 @@ i18n.inputMethod = { i18n.inputMethod = { enabled = "hime"; }; + +
+
+ Kime + + + Kime is Korean IME. it's built with Rust language and let you get simple, safe, fast Korean typing + + + + The following snippet can be used to configure Kime: + + + +i18n.inputMethod = { + enabled = "kime"; +};
diff --git a/nixos/modules/i18n/input-method/kime.nix b/nixos/modules/i18n/input-method/kime.nix new file mode 100644 index 000000000000..2a73cb3f4605 --- /dev/null +++ b/nixos/modules/i18n/input-method/kime.nix @@ -0,0 +1,49 @@ +{ config, pkgs, lib, generators, ... }: +with lib; +let + cfg = config.i18n.inputMethod.kime; + yamlFormat = pkgs.formats.yaml { }; +in +{ + options = { + i18n.inputMethod.kime = { + config = mkOption { + type = yamlFormat.type; + default = { }; + example = literalExample '' + { + daemon = { + modules = ["Xim" "Indicator"]; + }; + + indicator = { + icon_color = "White"; + }; + + engine = { + hangul = { + layout = "dubeolsik"; + }; + }; + } + ''; + description = '' + kime configuration. Refer to for details on supported values. + ''; + }; + }; + }; + + config = mkIf (config.i18n.inputMethod.enabled == "kime") { + i18n.inputMethod.package = pkgs.kime; + + environment.variables = { + GTK_IM_MODULE = "kime"; + QT_IM_MODULE = "kime"; + XMODIFIERS = "@im=kime"; + }; + + environment.etc."xdg/kime/config.yaml".text = replaceStrings [ "\\\\" ] [ "\\" ] (builtins.toJSON cfg.config); + }; +} + diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index f72be732216e..67f852ca3f47 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -92,6 +92,7 @@ ./i18n/input-method/ibus.nix ./i18n/input-method/nabi.nix ./i18n/input-method/uim.nix + ./i18n/input-method/kime.nix ./installer/tools/tools.nix ./misc/assertions.nix ./misc/crashdump.nix diff --git a/pkgs/tools/inputmethods/kime/default.nix b/pkgs/tools/inputmethods/kime/default.nix new file mode 100644 index 000000000000..35ed99b5a426 --- /dev/null +++ b/pkgs/tools/inputmethods/kime/default.nix @@ -0,0 +1,113 @@ +{ lib, stdenv, rustPlatform, rustc, cargo, fetchFromGitHub, pkg-config, cmake, extra-cmake-modules, llvmPackages +, withWayland ? true +, withIndicator ? true, dbus, libdbusmenu +, withXim ? true, xorg, cairo +, withGtk2 ? true, gtk2 +, withGtk3 ? true, gtk3 +, withQt5 ? true, qt5 +}: + +let + cmake_args = lib.optionals withGtk2 ["-DENABLE_GTK2=ON"] + ++ lib.optionals withGtk3 ["-DENABLE_GTK3=ON"] + ++ lib.optionals withQt5 ["-DENABLE_QT5=ON"]; + + optFlag = w: (if w then "1" else "0"); +in +stdenv.mkDerivation rec { + pname = "kime"; + version = "2.5.2"; + + src = fetchFromGitHub { + owner = "Riey"; + repo = pname; + rev = "v${version}"; + sha256 = "10zd4yrqxzxf4nj3b5bsblcmlbqssxqq9pac0misa1g61jdbszj8"; + }; + + cargoDeps = rustPlatform.fetchCargoTarball { + inherit src; + sha256 = "1bimi7020m7v287bh7via7zm9m7y13d13kqpd772xmpdbwrj8nrl"; + }; + + # Replace autostart path + postPatch = '' + substituteInPlace res/kime.desktop --replace "/usr/bin/kime" "$out/bin/kime" + ''; + + dontUseCmakeConfigure = true; + dontWrapQtApps = true; + buildPhase = '' + runHook preBuild + export KIME_BUILD_CHECK=1 + export KIME_BUILD_INDICATOR=${optFlag withIndicator} + export KIME_BUILD_XIM=${optFlag withXim} + export KIME_BUILD_WAYLAND=${optFlag withWayland} + export KIME_BUILD_KIME=1 + export KIME_CARGO_ARGS="-j$NIX_BUILD_CORES --frozen" + export KIME_MAKE_ARGS="-j$NIX_BUILD_CORES" + export KIME_CMAKE_ARGS="${lib.concatStringsSep " " cmake_args}" + bash scripts/build.sh -r + runHook postBuild + ''; + + doCheck = true; + checkPhase = '' + runHook preCheck + cargo test --release --frozen + runHook postCheck + ''; + + installPhase = '' + runHook preInstall + export KIME_BIN_DIR=bin + export KIME_INSTALL_HEADER=1 + export KIME_INSTALL_DOC=1 + export KIME_INCLUDE_DIR=include + export KIME_DOC_DIR=share/doc/kime + export KIME_ICON_DIR=share/icons + export KIME_LIB_DIR=lib + export KIME_QT5_DIR=lib/qt-${qt5.qtbase.version} + bash scripts/install.sh "$out" + runHook postInstall + ''; + + doInstallCheck = true; + installCheckPhase = '' + runHook preInstallCheck + # Don't pipe output to head directly it will cause broken pipe error https://github.com/rust-lang/rust/issues/46016 + kimeVersion=$(echo "$($out/bin/kime --version)" | head -n1) + echo "'kime --version | head -n1' returns: $kimeVersion" + [[ "$kimeVersion" == "kime ${version}" ]] + runHook postInstallCheck + ''; + + buildInputs = lib.optionals withIndicator [ dbus libdbusmenu ] + ++ lib.optionals withXim [ xorg.libxcb cairo ] + ++ lib.optionals withGtk2 [ gtk2 ] + ++ lib.optionals withGtk3 [ gtk3 ] + ++ lib.optionals withQt5 [ qt5.qtbase ]; + + nativeBuildInputs = [ + pkg-config + llvmPackages.clang + llvmPackages.libclang + llvmPackages.bintools + cmake + extra-cmake-modules + rustPlatform.cargoSetupHook + rustc + cargo + ]; + + RUST_BACKTRACE = 1; + LIBCLANG_PATH = "${llvmPackages.libclang}/lib"; + + meta = with lib; { + homepage = "https://github.com/Riey/kime"; + description = "Korean IME"; + license = licenses.gpl3Plus; + maintainers = [ maintainers.riey ]; + platforms = platforms.linux; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index f762cca96c3b..c771e230105a 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -3467,6 +3467,8 @@ in gebaar-libinput = callPackage ../tools/inputmethods/gebaar-libinput { }; + kime = callPackage ../tools/inputmethods/kime { }; + libpinyin = callPackage ../development/libraries/libpinyin { }; libskk = callPackage ../development/libraries/libskk {