fcitx5: dogfood mozc patch
This commit is contained in:
parent
dc9adaae31
commit
01a3ce9b83
|
@ -100,6 +100,13 @@
|
|||
(self: super: {
|
||||
inherit (nonrecursive-unstable-pkgs) atuin wstunnel;
|
||||
})
|
||||
|
||||
# https://github.com/NixOS/nixpkgs/pull/251706
|
||||
(self: super: {
|
||||
mozc = self.qt6Packages.callPackage ./package-overrides/mozc.nix { };
|
||||
fcitx5-mozc = self.callPackage ./package-overrides/fcitx5-mozc.nix { };
|
||||
})
|
||||
|
||||
(self: super: {
|
||||
mpv-unwrapped = super.mpv-unwrapped.override {
|
||||
ffmpeg = super.ffmpeg_6-full;
|
||||
|
|
|
@ -0,0 +1,131 @@
|
|||
{ bazel
|
||||
, buildBazelPackage
|
||||
, fcitx5
|
||||
, fetchFromGitHub
|
||||
, gettext
|
||||
, lib
|
||||
, mozc
|
||||
, nixosTests
|
||||
, pkg-config
|
||||
, python3
|
||||
, unzip
|
||||
}:
|
||||
|
||||
buildBazelPackage {
|
||||
pname = "fcitx5-mozc";
|
||||
version = "unstable-2024-02-09";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "fcitx";
|
||||
repo = "mozc";
|
||||
fetchSubmodules = true;
|
||||
rev = "c687b82fccd443917359a5c2a7b9b1c5fd3737c9";
|
||||
hash = "sha256-lXEW7F7ctI7kNdKEjdeYHbyeF8hf6C5AohoWVIfDbjM=";
|
||||
};
|
||||
|
||||
sourceRoot = "source/src";
|
||||
|
||||
nativeBuildInputs = [
|
||||
gettext
|
||||
pkg-config
|
||||
python3
|
||||
unzip
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
mozc
|
||||
fcitx5
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
sed -i -e 's|^\(LINUX_MOZC_SERVER_DIR = \).\+|\1"${mozc}/lib/mozc"|' config.bzl
|
||||
'';
|
||||
|
||||
inherit bazel;
|
||||
removeRulesCC = false;
|
||||
dontAddBazelOpts = true;
|
||||
|
||||
bazelFlags = [
|
||||
"--config"
|
||||
"oss_linux"
|
||||
"--compilation_mode"
|
||||
"opt"
|
||||
];
|
||||
|
||||
bazelTargets = [
|
||||
"unix/fcitx5:fcitx5-mozc.so"
|
||||
"unix/icons"
|
||||
];
|
||||
|
||||
fetchAttrs = {
|
||||
preInstall = ''
|
||||
rm -rf $bazelOut/external/fcitx5
|
||||
'';
|
||||
|
||||
sha256 = "sha256-OrS5/3Zasd2WXsA+kg0pzvgaKZs7DG/aKfqekxCmAL8=";
|
||||
};
|
||||
|
||||
buildAttrs = {
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
install -Dm444 ../LICENSE $out/share/licenses/fcitx5-mozc/LICENSE
|
||||
install -Dm444 data/installer/credits_en.html $out/share/licenses/fcitx5-mozc/Submodules
|
||||
|
||||
install -Dm555 bazel-bin/unix/fcitx5/fcitx5-mozc.so $out/lib/fcitx5/fcitx5-mozc.so
|
||||
install -Dm444 unix/fcitx5/mozc-addon.conf $out/share/fcitx5/addon/mozc.conf
|
||||
install -Dm444 unix/fcitx5/mozc.conf $out/share/fcitx5/inputmethod/mozc.conf
|
||||
|
||||
for pofile in unix/fcitx5/po/*.po; do
|
||||
filename=$(basename $pofile)
|
||||
lang=''${filename/.po/}
|
||||
mofile=''${pofile/.po/.mo}
|
||||
msgfmt $pofile -o $mofile
|
||||
install -Dm444 $mofile $out/share/locale/$lang/LC_MESSAGES/fcitx5-mozc.mo
|
||||
done
|
||||
|
||||
msgfmt --xml -d unix/fcitx5/po/ --template unix/fcitx5/org.fcitx.Fcitx5.Addon.Mozc.metainfo.xml.in -o unix/fcitx5/org.fcitx.Fcitx5.Addon.Mozc.metainfo.xml
|
||||
install -Dm444 unix/fcitx5/org.fcitx.Fcitx5.Addon.Mozc.metainfo.xml $out/share/metainfo/org.fcitx.Fcitx5.Addon.Mozc.metainfo.xml
|
||||
|
||||
cd bazel-bin/unix
|
||||
|
||||
unzip -o icons.zip
|
||||
|
||||
# These are relative symlinks, they will always resolve to files within $out
|
||||
|
||||
install -Dm444 mozc.png $out/share/icons/hicolor/128x128/apps/org.fcitx.Fcitx5.fcitx-mozc.png
|
||||
ln -s org.fcitx.Fcitx5.fcitx-mozc.png $out/share/icons/hicolor/128x128/apps/fcitx-mozc.png
|
||||
|
||||
rm {mozc,dictionary,properties,tool}.svg
|
||||
for svg in *.svg outlined/*.svg; do
|
||||
name=$(basename -- ''${svg//_/-})
|
||||
path=$out/share/icons/hicolor/scalable/apps
|
||||
prefix=org.fcitx.Fcitx5.fcitx-mozc
|
||||
|
||||
install -Dm444 $svg $path/$prefix-$name
|
||||
ln -s $prefix-$name $path/fcitx-mozc-$name
|
||||
done
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
|
||||
passthru.tests = {
|
||||
inherit (nixosTests) fcitx5;
|
||||
};
|
||||
|
||||
meta = with lib; {
|
||||
description = "Mozc - a Japanese Input Method Editor designed for multi-platform";
|
||||
homepage = "https://github.com/fcitx/mozc";
|
||||
license = with licenses; [
|
||||
asl20 # abseil-cpp
|
||||
bsd3 # mozc, breakpad, gtest, gyp, japanese-usage-dictionary, protobuf
|
||||
mit # wil
|
||||
# naist-2003 # IPAdic
|
||||
publicDomain # src/data/test/stress_test, Okinawa dictionary
|
||||
# unicode-30 # src/data/unicode, breakpad
|
||||
];
|
||||
maintainers = with maintainers; [ berberman govanify ];
|
||||
platforms = platforms.linux;
|
||||
};
|
||||
}
|
|
@ -0,0 +1,241 @@
|
|||
{ bazel
|
||||
, buildBazelPackage
|
||||
, fetchFromGitHub
|
||||
, fetchurl
|
||||
, glibcLocales
|
||||
, lib
|
||||
, pkg-config
|
||||
, python3
|
||||
, qtbase
|
||||
, qtwayland
|
||||
, ruby
|
||||
, wrapQtAppsHook
|
||||
, dictionaries ? [
|
||||
"alt-cannadic"
|
||||
"edict2"
|
||||
"jawiki"
|
||||
"neologd"
|
||||
"personal-names"
|
||||
"place-names"
|
||||
"skk-jisyo"
|
||||
"sudachidict"
|
||||
]
|
||||
}:
|
||||
|
||||
buildBazelPackage {
|
||||
pname = "mozc";
|
||||
version = "unstable-2024-02-09";
|
||||
|
||||
srcs = [
|
||||
(fetchFromGitHub rec {
|
||||
owner = "google";
|
||||
repo = "mozc";
|
||||
name = repo;
|
||||
fetchSubmodules = true;
|
||||
rev = "c2fcbf6515c5884437977de46187c16a8cb7bb50";
|
||||
hash = "sha256-AcIN5sWPBe4JotAUYv1fytgQw+mJzdFhKuVPLR48soA=";
|
||||
})
|
||||
(fetchFromGitHub rec {
|
||||
owner = "utuhiro78";
|
||||
repo = "merge-ut-dictionaries";
|
||||
name = repo;
|
||||
rev = "a3d6fc4005aff2092657ebca98b9de226e1c617f";
|
||||
hash = "sha256-UK29ACZUK9zGfzW7C85uMw2aF5Gk+0aDeUdNV71PY+0=";
|
||||
})
|
||||
(fetchFromGitHub rec {
|
||||
owner = "utuhiro78";
|
||||
repo = "mozcdic-ut-alt-cannadic";
|
||||
name = repo;
|
||||
rev = "4e548e6356b874c76e8db438bf4d8a0b452f2435";
|
||||
hash = "sha256-4gzqVoCIhC0k3mh0qbEr8yYttz9YR0fItkFNlu7cYOY=";
|
||||
})
|
||||
(fetchFromGitHub rec {
|
||||
owner = "utuhiro78";
|
||||
repo = "mozcdic-ut-edict2";
|
||||
name = repo;
|
||||
rev = "b2eec665b81214082d61acee1c5a1b5b115baf1a";
|
||||
hash = "sha256-LIpGt6xB8dLUnazbJHZk6EH1/ZyAHMIn1m6Qpr2dsHs=";
|
||||
})
|
||||
(fetchFromGitHub rec {
|
||||
owner = "utuhiro78";
|
||||
repo = "mozcdic-ut-jawiki";
|
||||
name = repo;
|
||||
rev = "6e08b8c823f3d2d09064ad2080e7a16552a7b473";
|
||||
hash = "sha256-0YwAinlcI6yojCdW1MpLgMZfyYV7gk9Q+Wlu4lR3Hrg=";
|
||||
})
|
||||
(fetchFromGitHub rec {
|
||||
owner = "utuhiro78";
|
||||
repo = "mozcdic-ut-neologd";
|
||||
name = repo;
|
||||
rev = "bf9d0d217107f2fb2e7d1a26648ef429d9fdcd27";
|
||||
hash = "sha256-e0iM5fohwpNNhPl9CjkD753/Rgatg7GdwN0NSvlN94c=";
|
||||
})
|
||||
(fetchFromGitHub rec {
|
||||
owner = "utuhiro78";
|
||||
repo = "mozcdic-ut-personal-names";
|
||||
name = repo;
|
||||
rev = "8a500f82c553936cbdd33b85955120e731069d44";
|
||||
hash = "sha256-pMyYvl5S0+U++MO5m9rmbtxDzAmO4Xs8sFewOUGqgUA=";
|
||||
})
|
||||
(fetchFromGitHub rec {
|
||||
owner = "utuhiro78";
|
||||
repo = "mozcdic-ut-place-names";
|
||||
name = repo;
|
||||
rev = "a847a02e0137ab9e2fdbbaaf120826f870408ca6";
|
||||
hash = "sha256-B0kW8Wa/nCT4KEYl2Rz6gQcj0Po3GxU6i42unHhgZeU=";
|
||||
})
|
||||
(fetchFromGitHub rec {
|
||||
owner = "utuhiro78";
|
||||
repo = "mozcdic-ut-skk-jisyo";
|
||||
name = repo;
|
||||
rev = "ee94f6546ce52edfeec0fd203030f52d4d99656f";
|
||||
hash = "sha256-RXxO878ZBkxenrdo7cFom5NjM0m7CdYQk0dFu/HPp/Y=";
|
||||
})
|
||||
(fetchFromGitHub rec {
|
||||
owner = "utuhiro78";
|
||||
repo = "mozcdic-ut-sudachidict";
|
||||
name = repo;
|
||||
rev = "55f61c3fca81dec661c36c73eb29b2631c8ed618";
|
||||
hash = "sha256-gNnBcuVU1M7rllfZXIrLg7WYUhKqPJsUjR8Scnq3Fw8=";
|
||||
})
|
||||
(fetchurl rec {
|
||||
name = "jawiki";
|
||||
url = "https://dumps.wikimedia.org/${name}/20240620/${name}-20240620-all-titles-in-ns0.gz";
|
||||
recursiveHash = true;
|
||||
hash = "sha256-p1LP8mHYknUPEB9u9CLCP1/uUjCVfb/mdpnOPawGcqQ=";
|
||||
downloadToTemp = true;
|
||||
postFetch = ''
|
||||
mkdir -p "$out"
|
||||
install -Dm444 "$downloadedFile" "$out/${name}.gz"
|
||||
'';
|
||||
})
|
||||
(fetchFromGitHub rec {
|
||||
owner = "musjj";
|
||||
repo = "jp-zip-codes";
|
||||
name = repo;
|
||||
rev = "cfbb54655223d8e2cea6fedbaef202919d8d62fe";
|
||||
hash = "sha256-ZvZL/6yTE6JrBu4ja7HvyBUKWUAIL0jULii5Im+zmLQ=";
|
||||
})
|
||||
];
|
||||
|
||||
sourceRoot = ".";
|
||||
|
||||
nativeBuildInputs = [
|
||||
glibcLocales
|
||||
pkg-config
|
||||
python3
|
||||
ruby
|
||||
wrapQtAppsHook
|
||||
];
|
||||
|
||||
buildInputs = [ qtbase qtwayland ];
|
||||
|
||||
preBuild = ''
|
||||
cd mozc/src
|
||||
'';
|
||||
|
||||
# Required so that the ruby scripts can work
|
||||
env.LOCALE_ARCHIVE = "${glibcLocales}/lib/locale/locale-archive";
|
||||
env.LC_ALL = "en_US.UTF-8";
|
||||
|
||||
inherit bazel;
|
||||
removeRulesCC = false;
|
||||
dontAddBazelOpts = true;
|
||||
|
||||
bazelFlags = [
|
||||
"--config"
|
||||
"oss_linux"
|
||||
"--compilation_mode"
|
||||
"opt"
|
||||
];
|
||||
|
||||
bazelTargets = [
|
||||
"server:mozc_server"
|
||||
"gui/tool:mozc_tool"
|
||||
];
|
||||
|
||||
fetchAttrs = {
|
||||
postPatch = ''
|
||||
substituteInPlace mozc/src/WORKSPACE.bazel \
|
||||
--replace \
|
||||
'url = "https://www.post.japanpost.jp/zipcode/dl/kogaki/zip/ken_all.zip"' \
|
||||
"url = \"file://$PWD/jp-zip-codes/ken_all.zip\"" \
|
||||
--replace \
|
||||
'url = "https://www.post.japanpost.jp/zipcode/dl/jigyosyo/zip/jigyosyo.zip"' \
|
||||
"url = \"file://$PWD/jp-zip-codes/jigyosyo.zip\""
|
||||
'';
|
||||
|
||||
preInstall = ''
|
||||
rm -rf $bazelOut/external/qt_linux
|
||||
'';
|
||||
|
||||
sha256 = "sha256-KTBdQte6eokKBnVlLWUOzGzwgwTVEq4qyICJhl8czJs=";
|
||||
};
|
||||
|
||||
buildAttrs = {
|
||||
postPatch = ''
|
||||
sed -ri -e "s|^(LINUX_MOZC_SERVER_DIR = ).+|\1\"$out/lib/mozc\"|" mozc/src/config.bzl
|
||||
|
||||
(
|
||||
cd merge-ut-dictionaries/src
|
||||
|
||||
sed -i -e "s|https://raw.githubusercontent.com/google/mozc/master|../../mozc|" remove_duplicate_ut_entries.rb
|
||||
|
||||
sed -i -e '/wget/d' count_word_hits.rb
|
||||
sed -i -e "s|^filename = \"jawiki-.*|filename = \"../../jawiki/jawiki.gz\"|" count_word_hits.rb
|
||||
|
||||
[[ -e mozcdic-ut.txt ]] && rm mozcdic-ut.txt
|
||||
|
||||
dictionaries=(
|
||||
${lib.escapeShellArgs dictionaries}
|
||||
)
|
||||
for name in "''${dictionaries[@]}"; do
|
||||
tar -xf ../../mozcdic-ut-$name/mozcdic-ut-$name.txt.tar.bz2
|
||||
cat mozcdic-ut-$name.txt >>mozcdic-ut.txt
|
||||
done
|
||||
|
||||
ruby remove_duplicate_ut_entries.rb mozcdic-ut.txt
|
||||
ruby count_word_hits.rb
|
||||
ruby apply_word_hits.rb mozcdic-ut.txt
|
||||
|
||||
cat mozcdic-ut.txt >>../../mozc/src/data/dictionary_oss/dictionary00.txt
|
||||
)
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
install -Dm444 -t $out/share/licenses/mozc ../LICENSE
|
||||
install -Dm444 -t $out/share/licenses/mozc/Submodules data/installer/credits_en.html
|
||||
|
||||
install -Dm555 -t $out/lib/mozc bazel-bin/server/mozc_server
|
||||
install -Dm555 -t $out/lib/mozc bazel-bin/gui/tool/mozc_tool
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
|
||||
meta = with lib; {
|
||||
description = "The Open Source edition of Google Japanese Input bundled with the UT dictionary";
|
||||
homepage = "https://github.com/google/mozc";
|
||||
license = with licenses; [
|
||||
asl20 # abseil-cpp, merge-ut-dictionaries, mozcdic-ut-alt-cannadic,
|
||||
# mozcdic-ut-edict2, mozcdic-ut-jawiki, mozcdic-ut-neologd,
|
||||
# mecab-ipadic-neologd, mozcdic-ut-personal-names,
|
||||
# mozcdic-ut-place-names, mozcdic-ut-skk-jisyo,
|
||||
# mozcdic-ut-sudachidict
|
||||
bsd2 # japanese-usage-dictionary
|
||||
bsd3 # mozc, breakpad, gtest, gyp, japanese-usage-dictionary, protobuf, id.def
|
||||
cc-by-sa-30 # jawiki-latest-all-titles, mozcdic-ut-jawiki.txt, jawiki
|
||||
cc-by-sa-40 # mozcdic-ut-edict2.txt
|
||||
gpl2Only # mozcdic-ut-alt-cannadic.txt
|
||||
gpl2Plus # mozcdic-ut-skk-jisyo.txt
|
||||
mit # wil
|
||||
# naist-2003 # IPAdic
|
||||
publicDomain # src/data/test/stress_test, mozcdic-ut-place-names.txt, jp-zip-codes, Okinawa dictionary
|
||||
# unicode-30 # src/data/unicode, breakpad
|
||||
];
|
||||
maintainers = with maintainers; [ musjj ];
|
||||
platforms = platforms.linux;
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue