nixpkgs/pkgs/by-name/su/sudachi-rs/package.nix
Alexis Hildebrandt 755b915a15 treewide: Remove indefinite article from meta.description
nix run nixpkgs#silver-searcher -- -G '\.nix$' -0l 'description.*"[Aa]n?' pkgs \
  | xargs -0 nix run nixpkgs#gnused -- -i '' -Ee 's/(description.*")[Aa]n? (.)/\1\U\2/'
2024-06-09 23:07:45 +02:00

61 lines
1.6 KiB
Nix

{ lib
, rustPlatform
, fetchFromGitHub
, sudachidict
, runCommand
, sudachi-rs
, writeScript
}:
rustPlatform.buildRustPackage rec {
pname = "sudachi-rs";
version = "0.6.8";
src = fetchFromGitHub {
owner = "WorksApplications";
repo = "sudachi.rs";
rev = "refs/tags/v${version}";
hash = "sha256-9GXU+YDPuQ+roqQfUE5q17Hl6AopsvGhRPjZ+Ui+n24=";
};
postPatch = ''
substituteInPlace sudachi/src/config.rs \
--replace '"resources"' '"${placeholder "out"}/share/resources"'
'';
cargoHash = "sha256-Ufo3dB2KGDDNiebp7hLhQrUMLsefO8wRpJQDz57Yb8Y=";
# 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";
};
}