jadb/nix/database.nix

43 lines
657 B
Nix

{
lib,
stdenvNoCC,
src,
database-tool,
jmdict,
radkfile,
kanjidic2,
sqlite,
}:
stdenvNoCC.mkDerivation {
name = "jadb";
inherit src;
nativeBuildInputs = [
database-tool
sqlite
];
buildPhase = ''
runHook preBuild
mkdir -p data
ln -s ${jmdict}/* data
ln -s ${radkfile}/* data
ln -s ${kanjidic2}/* data
for migration in migrations/*.sql; do
sqlite3 jadb.sqlite < $migration
done
${lib.getExe database-tool} ${sqlite.out}/lib/libsqlite3.so
runHook postBuild
'';
installPhase = ''
runHook preInstall
install -Dm644 -t $out jadb.sqlite
runHook postInstall
'';
}