Files
jadb/nix/docs.nix
2025-04-15 13:52:24 +02:00

54 lines
985 B
Nix

{
stdenvNoCC,
database,
sqlite,
schemaspy,
sqlite-jdbc,
writeText,
}:
stdenvNoCC.mkDerivation {
name = "docs";
src = database;
nativeBuildInputs = [
sqlite
schemaspy
sqlite-jdbc
];
buildPhase = let
sqliteProperties = writeText "sqlite.properties" ''
description=SQLite
driver=org.sqlite.JDBC
driverPath=${sqlite-jdbc}/share/java/sqlite-jdbc-3.25.2.jar
connectionSpec=jdbc:sqlite:<db>
'';
schemaspyProperties = 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 "${schemaspyProperties}" ./schemaspy.properties
schemaspy -t "${sqliteProperties}"
runHook postBuild
'';
installPhase = ''
runHook preInstall
cp -r docs "$out"
runHook postInstall
'';
}