at 22.05-pre 113 lines 3.2 kB view raw
1{ lib, stdenv, rustPlatform, rustc, cargo, fetchFromGitHub, pkg-config, cmake, extra-cmake-modules, llvmPackages 2, withWayland ? true 3, withIndicator ? true, dbus, libdbusmenu 4, withXim ? true, xorg, cairo 5, withGtk2 ? true, gtk2 6, withGtk3 ? true, gtk3 7, withQt5 ? true, qt5 8}: 9 10let 11 cmake_args = lib.optionals withGtk2 ["-DENABLE_GTK2=ON"] 12 ++ lib.optionals withGtk3 ["-DENABLE_GTK3=ON"] 13 ++ lib.optionals withQt5 ["-DENABLE_QT5=ON"]; 14 15 optFlag = w: (if w then "1" else "0"); 16in 17stdenv.mkDerivation rec { 18 pname = "kime"; 19 version = "2.5.5"; 20 21 src = fetchFromGitHub { 22 owner = "Riey"; 23 repo = pname; 24 rev = "v${version}"; 25 sha256 = "sha256-u2CmehJipXSH1dey5oIyQf8CsRveeae5cSjpY8vWYRs="; 26 }; 27 28 cargoDeps = rustPlatform.fetchCargoTarball { 29 inherit src; 30 sha256 = "sha256-ROzEEfIPeWoWDi5McNwub5E/UCAeJpOx5nZS9r/q4K4="; 31 }; 32 33 # Replace autostart path 34 postPatch = '' 35 substituteInPlace res/kime.desktop --replace "/usr/bin/kime" "$out/bin/kime" 36 ''; 37 38 dontUseCmakeConfigure = true; 39 dontWrapQtApps = true; 40 buildPhase = '' 41 runHook preBuild 42 export KIME_BUILD_CHECK=1 43 export KIME_BUILD_INDICATOR=${optFlag withIndicator} 44 export KIME_BUILD_XIM=${optFlag withXim} 45 export KIME_BUILD_WAYLAND=${optFlag withWayland} 46 export KIME_BUILD_KIME=1 47 export KIME_CARGO_ARGS="-j$NIX_BUILD_CORES --frozen" 48 export KIME_MAKE_ARGS="-j$NIX_BUILD_CORES" 49 export KIME_CMAKE_ARGS="${lib.concatStringsSep " " cmake_args}" 50 bash scripts/build.sh -r 51 runHook postBuild 52 ''; 53 54 doCheck = true; 55 checkPhase = '' 56 runHook preCheck 57 cargo test --release --frozen 58 runHook postCheck 59 ''; 60 61 installPhase = '' 62 runHook preInstall 63 export KIME_BIN_DIR=bin 64 export KIME_INSTALL_HEADER=1 65 export KIME_INSTALL_DOC=1 66 export KIME_INCLUDE_DIR=include 67 export KIME_DOC_DIR=share/doc/kime 68 export KIME_ICON_DIR=share/icons 69 export KIME_LIB_DIR=lib 70 export KIME_QT5_DIR=lib/qt-${qt5.qtbase.version} 71 bash scripts/install.sh "$out" 72 runHook postInstall 73 ''; 74 75 doInstallCheck = true; 76 installCheckPhase = '' 77 runHook preInstallCheck 78 # Don't pipe output to head directly it will cause broken pipe error https://github.com/rust-lang/rust/issues/46016 79 kimeVersion=$(echo "$($out/bin/kime --version)" | head -n1) 80 echo "'kime --version | head -n1' returns: $kimeVersion" 81 [[ "$kimeVersion" == "kime ${version}" ]] 82 runHook postInstallCheck 83 ''; 84 85 buildInputs = lib.optionals withIndicator [ dbus libdbusmenu ] 86 ++ lib.optionals withXim [ xorg.libxcb cairo ] 87 ++ lib.optionals withGtk2 [ gtk2 ] 88 ++ lib.optionals withGtk3 [ gtk3 ] 89 ++ lib.optionals withQt5 [ qt5.qtbase ]; 90 91 nativeBuildInputs = [ 92 pkg-config 93 llvmPackages.clang 94 llvmPackages.libclang 95 llvmPackages.bintools 96 cmake 97 extra-cmake-modules 98 rustPlatform.cargoSetupHook 99 rustc 100 cargo 101 ]; 102 103 RUST_BACKTRACE = 1; 104 LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib"; 105 106 meta = with lib; { 107 homepage = "https://github.com/Riey/kime"; 108 description = "Korean IME"; 109 license = licenses.gpl3Plus; 110 maintainers = [ maintainers.riey ]; 111 platforms = platforms.linux; 112 }; 113}