1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 cmake,
6 sqlite,
7 corrosion,
8 rustPlatform,
9 cargo,
10 rustc,
11}:
12
13stdenv.mkDerivation (finalAttrs: {
14 pname = "libchewing";
15 version = "0.9.1";
16
17 src = fetchFromGitHub {
18 owner = "chewing";
19 repo = "libchewing";
20 tag = "v${finalAttrs.version}";
21 hash = "sha256-5aeAsvTiUMTm+ibNfJI57rzSUpJB7luhA/aWmTcnBj4=";
22 };
23
24 # ld: unknown option: -version-script
25 postPatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
26 substituteInPlace CMakeLists.txt \
27 --replace-fail "if(CMAKE_C_COMPILER_ID MATCHES GNU|^Clang)" "if((CMAKE_C_COMPILER_ID MATCHES GNU|^Clang) AND NOT APPLE)"
28 '';
29
30 cargoDeps = rustPlatform.fetchCargoVendor {
31 inherit (finalAttrs) src;
32 hash = "sha256-LTuUhQ0ZeyGloNvVs+6OGjFvPdBsQNZupwC8QTjUfyk=";
33 };
34
35 nativeBuildInputs = [
36 cmake
37 rustPlatform.cargoSetupHook
38 cargo
39 rustc
40 ];
41
42 buildInputs = [
43 sqlite
44 corrosion
45 ];
46
47 meta = {
48 description = "Intelligent Chinese phonetic input method";
49 homepage = "https://chewing.im/";
50 license = lib.licenses.lgpl21Only;
51 maintainers = with lib.maintainers; [ ShamrockLee ];
52 platforms = lib.platforms.all;
53 # compile time tools init_database, dump_database are built for host
54 broken = !stdenv.buildPlatform.canExecute stdenv.hostPlatform;
55 };
56})