depot/third_party/nixpkgs/pkgs/by-name/su/sudachi-rs/package.nix
Luke Granger-Brown f92e137cfb
Some checks failed
/ combine-systems (push) Blocked by required conditions
/ build (x86_64-linux) (push) Failing after 11m44s
/ build (aarch64-linux) (push) Failing after 11m50s
/ build (push) Failing after 16m42s
Merge commit '1e2ed035f4bebc9adad02b365508ad96f7df87c1' into HEAD
2025-03-02 02:23:32 +00:00

67 lines
1.8 KiB
Nix

{
lib,
rustPlatform,
fetchFromGitHub,
sudachidict,
runCommand,
sudachi-rs,
writeScript,
}:
rustPlatform.buildRustPackage rec {
pname = "sudachi-rs";
version = "0.6.10";
src = fetchFromGitHub {
owner = "WorksApplications";
repo = "sudachi.rs";
tag = "v${version}";
hash = "sha256-2sJ9diE/EjrQmFcCc4VluE4Gu4RebTYitd7zzfgj3g4=";
};
postPatch = ''
substituteInPlace sudachi/src/config.rs \
--replace '"resources"' '"${placeholder "out"}/share/resources"'
'';
cargoPatches = [
# https://github.com/WorksApplications/sudachi.rs/issues/299
./update-outdated-lockfile.patch
];
useFetchCargoVendor = true;
cargoHash = "sha256-lUP/9s4W0JehxeCjMmq6G22KMGdDNnq1YlobeLQn2AE=";
# prepare the resources before the build so that the binary can find sudachidict
preBuild = ''
install -Dm644 ${sudachidict}/share/system.dic resources/system.dic
install -Dm644 resources/* -t $out/share/resources
'';
passthru = {
updateScript = writeScript "update.sh" ''
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p nix-update
set -eu -o pipefail
nix-update sudachi-rs
nix-update --version=skip python3Packages.sudachipy
'';
tests = {
# detects an error that sudachidict is not found
cli = runCommand "${pname}-cli-test" { } ''
mkdir $out
echo "" | ${lib.getExe sudachi-rs} > $out/result
'';
};
};
meta = with lib; {
description = "Japanese morphological analyzer";
homepage = "https://github.com/WorksApplications/sudachi.rs";
changelog = "https://github.com/WorksApplications/sudachi.rs/blob/${src.rev}/CHANGELOG.md";
license = licenses.asl20;
maintainers = with maintainers; [ natsukium ];
mainProgram = "sudachi";
};
}