1{ lib
2, stdenv
3, callPackage
4, maven
5, jdk
6, jre
7, buildMaven
8, makeWrapper
9, git
10, fetchFromGitHub
11, graphviz
12, ensureNewerSourcesHook
13}:
14
15let
16 version = "6.1.1-SNAPSHOT";
17 pname = "schemaspy";
18
19 src = fetchFromGitHub {
20 owner = "schemaspy";
21 repo = "schemaspy";
22 rev = "110b1614f9ae4aec0e4dc4e8f0e7c647274d3af6";
23 sha256 = "sha256-X5B34zGhD/NxcK8TQvwdk1NljGJ1HwfBp47ocbE4HiU=";
24 };
25
26 deps = stdenv.mkDerivation {
27 name = "${pname}-${version}-deps";
28 inherit src;
29
30 nativeBuildInputs = [ jdk maven git ];
31 buildInputs = [ jre ];
32
33 buildPhase = ''
34 mvn package -Dmaven.test.skip=true -Dmaven.repo.local=$out/.m2 -Dmaven.wagon.rto=5000
35 '';
36
37 # keep only *.{pom,jar,sha1,nbm} and delete all ephemeral files with lastModified timestamps inside
38 installPhase = ''
39 find $out/.m2 -type f -regex '.+\(\.lastUpdated\|resolver-status\.properties\|_remote\.repositories\)' -delete
40 find $out/.m2 -type f -iname '*.pom' -exec sed -i -e 's/\r\+$//' {} \;
41 '';
42
43 outputHashAlgo = "sha256";
44 outputHashMode = "recursive";
45 outputHash = "sha256-CUFA9L6qqjo3Jp5Yy1yCqbS9QAEb9PElys4ArPa9VhA=";
46
47 doCheck = false;
48 };
49in
50stdenv.mkDerivation rec {
51 inherit version pname src;
52
53 buildInputs = [
54 maven
55 ];
56
57 nativeBuildInputs = [
58 makeWrapper
59 # the build system gets angry if it doesn't see git (even though it's not
60 # actually in a git repository)
61 git
62
63 # springframework boot gets angry about 1970 sources
64 # fix from https://github.com/nix-community/mavenix/issues/25
65 (ensureNewerSourcesHook { year = "1980"; })
66 ];
67
68 wrappedPath = lib.makeBinPath [
69 graphviz
70 ];
71
72 buildPhase = ''
73 VERSION=${version}
74 SEMVER_STR=${version}
75
76 mvn package --offline -Dmaven.test.skip=true -Dmaven.repo.local=$(cp -dpR ${deps}/.m2 ./ && chmod +w -R .m2 && pwd)/.m2
77 '';
78
79 installPhase = ''
80 install -D target/${pname}-${version}.jar $out/share/java/${pname}-${version}.jar
81
82 makeWrapper ${jre}/bin/java $out/bin/schemaspy \
83 --add-flags "-jar $out/share/java/${pname}-${version}.jar" \
84 --prefix PATH : "$wrappedPath"
85 '';
86
87 meta = with lib; {
88 homepage = "https://schemaspy.org";
89 description = "Document your database simply and easily";
90 license = licenses.lgpl3Plus;
91 maintainers = with maintainers; [ jraygauthier ];
92 };
93}
94