python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / pkgs / tools / inputmethods / fcitx5 / fcitx5-mozc.nix
blobac85bb2c40e9057eac70cbe4585b138f267a3b1b
1 { lib, clangStdenv, fetchFromGitHub, fetchurl, fetchpatch, fetchgit
2 , python3Packages, ninja, pkg-config, protobuf, zinnia, qt5, fcitx5
3 , jsoncpp, gtest, which, gtk2, unzip, abseil-cpp, breakpad }:
4 let
5   inherit (python3Packages) python gyp six;
6   utdic = fetchurl {
7     url = "https://osdn.net/downloads/users/39/39056/mozcdic-ut-20220904.tar.bz2";
8     sha256 = "sha256-pmLBCcw2Zsirzl1PjYkviRIZoyfUz5rpESeABDxuhtU=";
9   };
10   japanese_usage_dictionary = fetchFromGitHub {
11     owner = "hiroyuki-komatsu";
12     repo = "japanese-usage-dictionary";
13     rev = "e5b3425575734c323e1d947009dd74709437b684";
14     sha256 = "0pyrpz9c8nxccwpgyr36w314mi8h132cis8ijvlqmmhqxwsi30hm";
15   };
16   zipcode_rel = "202011";
17   jigyosyo = fetchurl {
18     url = "https://osdn.net/projects/ponsfoot-aur/storage/mozc/jigyosyo-${zipcode_rel}.zip";
19     sha256 = "j7MkNtd4+QTi91EreVig4/OV0o5y1+KIjEJBEmLK/mY=";
20   };
21   x-ken-all = fetchurl {
22     url =
23       "https://osdn.net/projects/ponsfoot-aur/storage/mozc/x-ken-all-${zipcode_rel}.zip";
24     sha256 = "ExS0Cg3rs0I9IOVbZHLt8UEfk8/LmY9oAHPVVlYuTPw=";
25   };
27 in clangStdenv.mkDerivation rec {
28   pname = "fcitx5-mozc";
29   version = "2.26.4220.102";
31   src = fetchFromGitHub {
32     owner = "fcitx";
33     repo = "mozc";
34     rev = "1882e33b61673b66d63277f82b4c80ae4e506c10";
35     sha256 = "R+w0slVFpqtt7PIr1pyupJjRoQsABVZiMdZ9fKGKAqw=";
36   };
38   nativeBuildInputs = [ gyp ninja python pkg-config qt5.wrapQtAppsHook six which unzip ];
40   buildInputs = [ protobuf zinnia qt5.qtbase fcitx5 abseil-cpp jsoncpp gtest gtk2 ];
42   patches = [
43     # Support linking system abseil-cpp
44     (fetchpatch {
45       url = "https://salsa.debian.org/debian/mozc/-/raw/debian/sid/debian/patches/0007-Update-src-base-absl.gyp.patch";
46       sha256 = "UiS0UScDKyAusXOhc7Bg8dF8ARQQiVTylEhAOxqaZt8=";
47     })
49   ];
51   postUnpack = ''
52     unzip ${x-ken-all} -d $sourceRoot/src/
53     unzip ${jigyosyo} -d $sourceRoot/src/
54     mkdir $TMPDIR/unpack
55     tar xf ${utdic} -C $TMPDIR/unpack
56     cat $TMPDIR/unpack/mozcdic-ut-20220904/mozcdic-ut-20220904.txt >> $sourceRoot/src/data/dictionary_oss/dictionary00.txt
58     rmdir $sourceRoot/src/third_party/breakpad/
59     ln -s ${breakpad} $sourceRoot/src/third_party/breakpad
60     rmdir $sourceRoot/src/third_party/gtest/
61     ln -s ${gtest} $sourceRoot/src/third_party/gtest
62     rmdir $sourceRoot/src/third_party/gyp/
63     ln -s ${gyp} $sourceRoot/src/third_party/gyp
64     rmdir $sourceRoot/src/third_party/japanese_usage_dictionary/
65     ln -s ${japanese_usage_dictionary} $sourceRoot/src/third_party/japanese_usage_dictionary
66   '';
68   # Copied from https://github.com/archlinux/svntogit-community/blob/packages/fcitx5-mozc/trunk/PKGBUILD
69   configurePhase = ''
70     cd src
71     export GYP_DEFINES="document_dir=$out/share/doc/mozc use_libzinnia=1 use_libprotobuf=1 use_libabseil=1"
73     # disable fcitx4
74     rm unix/fcitx/fcitx.gyp
76     # gen zip code seed
77     PYTHONPATH="$PWD:$PYTHONPATH" python dictionary/gen_zip_code_seed.py --zip_code="x-ken-all.csv" --jigyosyo="JIGYOSYO.CSV" >> data/dictionary_oss/dictionary09.txt
79     # use libstdc++ instead of libc++
80     sed "/stdlib=libc++/d;/-lc++/d" -i gyp/common.gypi
82     # run gyp
83     python build_mozc.py gyp --gypdir=${gyp}/bin --server_dir=$out/lib/mozc
84   '';
86   buildPhase = ''
87     python build_mozc.py build -c Release \
88       server/server.gyp:mozc_server \
89       gui/gui.gyp:mozc_tool \
90       unix/fcitx5/fcitx5.gyp:fcitx5-mozc
91   '';
93   installPhase = ''
94     export PREFIX=$out
95     export _bldtype=Release
96     ../scripts/install_server
97     install -d $out/share/licenses/fcitx5-mozc
98     head -n 29 server/mozc_server.cc > $out/share/licenses/fcitx5-mozc/LICENSE
99     install -m644 data/installer/*.html $out/share/licenses/fcitx5-mozc/
100     install -d $out/share/fcitx5/addon
101     install -d $out/share/fcitx5/inputmethod
102     install -d $out/lib/fcitx5
103     ../scripts/install_fcitx5
104   '';
106   meta = with lib; {
107     description = "Fcitx5 Module of A Japanese Input Method for Chromium OS, Windows, Mac and Linux (the Open Source Edition of Google Japanese Input)";
108     homepage = "https://github.com/fcitx/mozc";
109     license = licenses.bsd3;
110     maintainers = with maintainers; [ berberman govanify ];
111     platforms = platforms.linux;
112   };