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