jadb/nix/docs.nix

53 lines
932 B
Nix

{
stdenvNoCC,
database,
sqlite,
schemaspy,
sqlite-jdbc,
writeText,
}:
stdenvNoCC.mkDerivation {
name = "docs";
src = database;
nativeBuildInputs = [
sqlite
schemaspy
sqlite-jdbc
];
buildPhase = let
properties = writeText "sqlite.properties" ''
description=SQLite
driver=org.sqlite.JDBC
driverPath=${sqlite-jdbc}/share/java/sqlite-jdbc-3.25.2.jar
connectionSpec=jdbc:sqlite:<db>
'';
args = writeText "schemaspy.properties" ''
schemaspy.cat="%"
schemaspy.t=sqlite
schemaspy.sso=true
schemaspy.db=jadb.sqlite
schemaspy.o=docs
schemaspy.s=schema.sql
'';
in ''
runHook preBuild
sqlite3 jadb.sqlite ".schema" > schema.sql
cp ${args} ./schemaspy.properties
schemaspy -t ${properties}
runHook postBuild
'';
installPhase = ''
runHook preBuild
cp -r docs $out
runHook postBuild
'';
}