Merge pull request #262224 from chayleaf/tsja
postgresqlPackages.tsja: init at 0.5.0
This commit is contained in:
commit
fb1c60b65a
5 changed files with 82 additions and 1 deletions
|
@ -849,6 +849,7 @@ in {
|
|||
trezord = handleTest ./trezord.nix {};
|
||||
trickster = handleTest ./trickster.nix {};
|
||||
trilium-server = handleTestOn ["x86_64-linux"] ./trilium-server.nix {};
|
||||
tsja = handleTest ./tsja.nix {};
|
||||
tsm-client-gui = handleTest ./tsm-client-gui.nix {};
|
||||
txredisapi = handleTest ./txredisapi.nix {};
|
||||
tuptime = handleTest ./tuptime.nix {};
|
||||
|
|
32
nixos/tests/tsja.nix
Normal file
32
nixos/tests/tsja.nix
Normal file
|
@ -0,0 +1,32 @@
|
|||
import ./make-test-python.nix ({ pkgs, lib, ...} : {
|
||||
name = "tsja";
|
||||
meta = {
|
||||
maintainers = with lib.maintainers; [ chayleaf ];
|
||||
};
|
||||
|
||||
nodes = {
|
||||
master =
|
||||
{ config, ... }:
|
||||
|
||||
{
|
||||
services.postgresql = {
|
||||
enable = true;
|
||||
extraPlugins = with config.services.postgresql.package.pkgs; [
|
||||
tsja
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
start_all()
|
||||
master.wait_for_unit("postgresql")
|
||||
master.succeed("sudo -u postgres psql -f /run/current-system/sw/share/postgresql/extension/libtsja_dbinit.sql")
|
||||
# make sure "日本語" is parsed as a separate lexeme
|
||||
master.succeed("""
|
||||
sudo -u postgres \\
|
||||
psql -c "SELECT * FROM ts_debug('japanese', 'PostgreSQLで日本語のテキスト検索ができます。')" \\
|
||||
| grep "{日本語}"
|
||||
""")
|
||||
'';
|
||||
})
|
45
pkgs/servers/sql/postgresql/ext/tsja.nix
Normal file
45
pkgs/servers/sql/postgresql/ext/tsja.nix
Normal file
|
@ -0,0 +1,45 @@
|
|||
{ lib
|
||||
, fetchzip
|
||||
, nixosTests
|
||||
, stdenv
|
||||
|
||||
, mecab
|
||||
, postgresql
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "tsja";
|
||||
version = "0.5.0";
|
||||
|
||||
src = fetchzip {
|
||||
url = "https://www.amris.jp/tsja/tsja-${version}.tar.xz";
|
||||
hash = "sha256-h59UhUG/7biN8NaDiGK6kXDqfhR9uMzt8CpwbJ+PpEM=";
|
||||
};
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace Makefile \
|
||||
--replace /usr/local/pgsql ${postgresql} \
|
||||
--replace -L/usr/local/lib "" \
|
||||
--replace -I/usr/local/include ""
|
||||
substituteInPlace tsja.c --replace /usr/local/lib/mecab ${mecab}/lib/mecab
|
||||
'';
|
||||
|
||||
buildInputs = [ mecab postgresql ];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/lib $out/share/postgresql/extension
|
||||
mv libtsja.so $out/lib
|
||||
mv dbinit_libtsja.txt $out/share/postgresql/extension/libtsja_dbinit.sql
|
||||
'';
|
||||
|
||||
passthru.tests.tsja = nixosTests.tsja;
|
||||
|
||||
meta = with lib; {
|
||||
description = "PostgreSQL extension implementing Japanese text search";
|
||||
homepage = "https://www.amris.jp/tsja/index.html";
|
||||
maintainers = with maintainers; [ chayleaf ];
|
||||
# GNU-specific linker options are used
|
||||
platforms = platforms.gnu;
|
||||
license = licenses.gpl2Only;
|
||||
};
|
||||
}
|
|
@ -87,5 +87,7 @@ self: super: {
|
|||
|
||||
rum = super.callPackage ./ext/rum.nix { };
|
||||
|
||||
tsja = super.callPackage ./ext/tsja.nix { };
|
||||
|
||||
wal2json = super.callPackage ./ext/wal2json.nix { };
|
||||
}
|
||||
|
|
|
@ -7,7 +7,8 @@ stdenv.mkDerivation (finalAttrs: ((mecab-base finalAttrs) // {
|
|||
pname = "mecab";
|
||||
|
||||
postInstall = ''
|
||||
sed -i 's|^dicdir = .*$|dicdir = ${mecab-ipadic}|' "$out/etc/mecabrc"
|
||||
mkdir -p $out/lib/mecab/dic
|
||||
ln -s ${mecab-ipadic} $out/lib/mecab/dic/ipadic
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
|
|
Loading…
Reference in a new issue