1 { lib, stdenv, rustPlatform, rustc, cargo, fetchFromGitHub, pkg-config, cmake, extra-cmake-modules
3 , withIndicator ? true, dbus, libdbusmenu
4 , withXim ? true, xorg, cairo
5 , withGtk3 ? true, gtk3
6 , withGtk4 ? true, gtk4
12 cmake_args = lib.optionals withGtk3 ["-DENABLE_GTK3=ON"]
13 ++ lib.optionals withGtk4 ["-DENABLE_GTK4=ON"]
14 ++ lib.optionals withQt5 ["-DENABLE_QT5=ON"]
15 ++ lib.optionals withQt6 ["-DENABLE_QT6=ON"];
17 optFlag = w: (if w then "1" else "0");
19 stdenv.mkDerivation (finalAttrs: {
23 src = fetchFromGitHub {
26 rev = "v${finalAttrs.version}";
27 hash = "sha256-apQkxAUve7+2h9XACZZgroqBK1sCUYMNfsX/4nEnCPA=";
30 cargoDeps = rustPlatform.fetchCargoTarball {
31 inherit (finalAttrs) src;
32 hash = "sha256-2MG6xigiKdvQX8PR457d6AXswTRPRJBPERvZqemjv24=";
35 # Replace autostart path
37 substituteInPlace res/kime.desktop res/kime-xdg-autostart \
38 --replace-warn "/usr/bin/kime" "kime"
41 dontUseCmakeConfigure = true;
42 dontWrapQtApps = true;
45 export KIME_BUILD_CHECK=1
46 export KIME_BUILD_INDICATOR=${optFlag withIndicator}
47 export KIME_BUILD_XIM=${optFlag withXim}
48 export KIME_BUILD_WAYLAND=${optFlag withWayland}
49 export KIME_BUILD_KIME=1
50 export KIME_CARGO_ARGS="-j$NIX_BUILD_CORES --frozen"
51 export KIME_MAKE_ARGS="-j$NIX_BUILD_CORES"
52 export KIME_CMAKE_ARGS="${lib.concatStringsSep " " cmake_args}"
53 bash scripts/build.sh -r
60 cargo test --release --frozen
66 export KIME_BIN_DIR=bin
67 export KIME_INSTALL_HEADER=1
68 export KIME_INSTALL_DOC=1
69 export KIME_INCLUDE_DIR=include
70 export KIME_DOC_DIR=share/doc/kime
71 export KIME_ICON_DIR=share/icons
72 export KIME_LIB_DIR=lib
73 export KIME_QT5_DIR=lib/qt-${qt5.qtbase.version}
74 export KIME_QT6_DIR=lib/qt-${qt6.qtbase.version}
75 bash scripts/install.sh "$out"
79 doInstallCheck = true;
80 installCheckPhase = ''
81 runHook preInstallCheck
82 # Don't pipe output to head directly it will cause broken pipe error https://github.com/rust-lang/rust/issues/46016
83 kimeVersion=$(echo "$($out/bin/kime --version)" | head -n1)
84 echo "'kime --version | head -n1' returns: $kimeVersion"
85 [[ "$kimeVersion" == "kime ${finalAttrs.version}" ]]
86 runHook postInstallCheck
89 buildInputs = lib.optionals withIndicator [ dbus libdbusmenu ]
90 ++ lib.optionals withXim [ xorg.libxcb cairo ]
91 ++ lib.optionals withGtk3 [ gtk3 ]
92 ++ lib.optionals withGtk4 [ gtk4 ]
93 ++ lib.optionals withQt5 [ qt5.qtbase ]
94 ++ lib.optionals withQt6 [ qt6.qtbase ];
100 rustPlatform.bindgenHook
101 rustPlatform.cargoSetupHook
109 homepage = "https://github.com/Riey/kime";
110 description = "Korean IME";
111 license = lib.licenses.gpl3Plus;
112 maintainers = [ lib.maintainers.riey ];
113 platforms = lib.platforms.linux;