nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 115 lines 2.9 kB view raw
1{ 2 lib, 3 buildBazelPackage, 4 fetchFromGitHub, 5 qt6, 6 pkg-config, 7 protobuf_27, 8 bazel_7, 9 ibus, 10 unzip, 11 xdg-utils, 12 jp-zip-codes, 13 dictionaries ? [ ], 14 merge-ut-dictionaries, 15}: 16 17let 18 ut-dictionary = merge-ut-dictionaries.override { inherit dictionaries; }; 19in 20buildBazelPackage rec { 21 pname = "mozc"; 22 version = "2.30.5544.102"; # make sure to update protobuf if needed 23 24 src = fetchFromGitHub { 25 owner = "google"; 26 repo = "mozc"; 27 tag = version; 28 hash = "sha256-w0bjoMmq8gL7DSehEG7cKqp5e4kNOXnCYLW31Zl9FRs="; 29 fetchSubmodules = true; 30 }; 31 32 nativeBuildInputs = [ 33 qt6.wrapQtAppsHook 34 pkg-config 35 unzip 36 ]; 37 38 buildInputs = [ 39 ibus 40 qt6.qtbase 41 ]; 42 43 dontAddBazelOpts = true; 44 removeRulesCC = false; 45 46 bazel = bazel_7; 47 48 fetchAttrs = { 49 hash = "sha256-c+v2vWvTmwJ7MFh3VJlUh+iSINjsX66W9K0UBX5K/1s="; 50 51 preInstall = '' 52 # Remove zip code data. It will be replaced with jp-zip-codes from nixpkgs 53 rm -rv "$bazelOut"/external/zip_code_{jigyosyo,ken_all} 54 # Remove references to buildInputs 55 rm -rv "$bazelOut"/external/{ibus,qt_linux} 56 # Remove reference to the host platform 57 rm -rv "$bazelOut"/external/host_platform 58 ''; 59 }; 60 61 bazelFlags = [ 62 "--config" 63 "oss_linux" 64 "--compilation_mode" 65 "opt" 66 ]; 67 68 bazelTargets = [ "package" ]; 69 70 postPatch = '' 71 # replace protobuf with our own 72 rm -r src/third_party/protobuf 73 cp -r ${protobuf_27.src} src/third_party/protobuf 74 substituteInPlace src/config.bzl \ 75 --replace-fail "/usr/bin/xdg-open" "${xdg-utils}/bin/xdg-open" \ 76 --replace-fail "/usr" "$out" 77 substituteInPlace src/WORKSPACE.bazel \ 78 --replace-fail "https://www.post.japanpost.jp/zipcode/dl/kogaki/zip/ken_all.zip" "file://${jp-zip-codes}/ken_all.zip" \ 79 --replace-fail "https://www.post.japanpost.jp/zipcode/dl/jigyosyo/zip/jigyosyo.zip" "file://${jp-zip-codes}/jigyosyo.zip" 80 ''; 81 82 preConfigure = '' 83 cd src 84 '' 85 + lib.optionalString (dictionaries != [ ]) '' 86 cat ${ut-dictionary}/mozcdic-ut.txt >> data/dictionary_oss/dictionary00.txt 87 ''; 88 89 buildAttrs.installPhase = '' 90 runHook preInstall 91 92 unzip bazel-bin/unix/mozc.zip -x "tmp/*" -d / 93 94 # create a desktop file for gnome-control-center 95 # copied from ubuntu 96 mkdir -p $out/share/applications 97 cp ${./ibus-setup-mozc-jp.desktop} $out/share/applications/ibus-setup-mozc-jp.desktop 98 substituteInPlace $out/share/applications/ibus-setup-mozc-jp.desktop \ 99 --replace-fail "@mozc@" "$out" 100 101 runHook postInstall 102 ''; 103 104 meta = { 105 isIbusEngine = true; 106 description = "Japanese input method from Google"; 107 mainProgram = "mozc_emacs_helper"; 108 homepage = "https://github.com/google/mozc"; 109 license = lib.licenses.free; 110 platforms = lib.platforms.linux; 111 maintainers = with lib.maintainers; [ 112 pineapplehunter 113 ]; 114 }; 115}