Files
nixpkgs/pkgs/by-name/mo/mozc/package.nix
Dark Steveneq 646b892680
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
push sheeet
2025-10-09 14:15:47 +02:00

116 lines
2.8 KiB
Nix

{
lib,
buildBazelPackage,
fetchFromGitHub,
qt6,
pkg-config,
protobuf_27,
bazel_7,
ibus,
unzip,
xdg-utils,
jp-zip-codes,
dictionaries ? [ ],
merge-ut-dictionaries,
}:
let
ut-dictionary = merge-ut-dictionaries.override { inherit dictionaries; };
in
buildBazelPackage rec {
pname = "mozc";
version = "2.30.5544.102"; # make sure to update protobuf if needed
src = fetchFromGitHub {
owner = "google";
repo = "mozc";
tag = version;
hash = "sha256-w0bjoMmq8gL7DSehEG7cKqp5e4kNOXnCYLW31Zl9FRs=";
fetchSubmodules = true;
};
nativeBuildInputs = [
qt6.wrapQtAppsHook
pkg-config
unzip
];
buildInputs = [
ibus
qt6.qtbase
];
dontAddBazelOpts = true;
removeRulesCC = false;
bazel = bazel_7;
fetchAttrs = {
hash = "sha256-c+v2vWvTmwJ7MFh3VJlUh+iSINjsX66W9K0UBX5K/1s=";
preInstall = ''
# Remove zip code data. It will be replaced with jp-zip-codes from nixpkgs
rm -rv "$bazelOut"/external/zip_code_{jigyosyo,ken_all}
# Remove references to buildInputs
rm -rv "$bazelOut"/external/{ibus,qt_linux}
# Remove reference to the host platform
rm -rv "$bazelOut"/external/host_platform
'';
};
bazelFlags = [
"--config"
"oss_linux"
"--compilation_mode"
"opt"
];
bazelTargets = [ "package" ];
postPatch = ''
# replace protobuf with our own
rm -r src/third_party/protobuf
cp -r ${protobuf_27.src} src/third_party/protobuf
substituteInPlace src/config.bzl \
--replace-fail "/usr/bin/xdg-open" "${xdg-utils}/bin/xdg-open" \
--replace-fail "/usr" "$out"
substituteInPlace src/WORKSPACE.bazel \
--replace-fail "https://www.post.japanpost.jp/zipcode/dl/kogaki/zip/ken_all.zip" "file://${jp-zip-codes}/ken_all.zip" \
--replace-fail "https://www.post.japanpost.jp/zipcode/dl/jigyosyo/zip/jigyosyo.zip" "file://${jp-zip-codes}/jigyosyo.zip"
'';
preConfigure = ''
cd src
''
+ lib.optionalString (dictionaries != [ ]) ''
cat ${ut-dictionary}/mozcdic-ut.txt >> data/dictionary_oss/dictionary00.txt
'';
buildAttrs.installPhase = ''
runHook preInstall
unzip bazel-bin/unix/mozc.zip -x "tmp/*" -d /
# create a desktop file for gnome-control-center
# copied from ubuntu
mkdir -p $out/share/applications
cp ${./ibus-setup-mozc-jp.desktop} $out/share/applications/ibus-setup-mozc-jp.desktop
substituteInPlace $out/share/applications/ibus-setup-mozc-jp.desktop \
--replace-fail "@mozc@" "$out"
runHook postInstall
'';
meta = with lib; {
isIbusEngine = true;
description = "Japanese input method from Google";
mainProgram = "mozc_emacs_helper";
homepage = "https://github.com/google/mozc";
license = licenses.free;
platforms = platforms.linux;
maintainers = with maintainers; [
pineapplehunter
];
};
}