2017-07-11 15:56:58 +01:00
{ fetchFromGitHub , buildMaven , maven , jdk , makeWrapper , stdenv , . . . }:
stdenv . mkDerivation rec {
name = " e x h i b i t o r - ${ version } " ;
version = " 1 . 5 . 6 " ;
src = fetchFromGitHub {
owner = " s o a b a s e " ;
repo = " e x h i b i t o r " ;
sha256 = " 0 7 v i k h k l d x y 5 1 j b p y 3 j g v a 6 w z 7 5 j k s c h 6 b j d 6 d q k a g f g q d 6 b a w 4 5 " ;
rev = " 5 f c d b 4 1 1 d 0 6 e 8 6 3 8 c 2 3 8 0 f 7 a c b 7 2 a 8 a 6 9 0 9 7 3 9 c d " ;
} ;
mavenDependenciesSha256 = " 0 0 r 6 9 n 9 h w v r n 5 c b h x k l x 7 w 0 0 s j m q v c x s 7 g v h b m 1 5 0 g g y 7 b c 8 6 5 q v " ;
# This is adapted from https://github.com/volth/nixpkgs/blob/6aa470dfd57cae46758b62010a93c5ff115215d7/pkgs/applications/networking/cluster/hadoop/default.nix#L20-L32
fetchedMavenDeps = stdenv . mkDerivation {
name = " e x h i b i t o r - ${ version } - m a v e n - d e p s " ;
inherit src nativeBuildInputs ;
buildPhase = ''
2017-07-21 21:10:44 +01:00
cd $ { pomFileDir } ;
2017-07-11 15:56:58 +01:00
while timeout - - kill-after = 2 1 m 2 0 m mvn package - Dmaven . repo . local = $ out/.m2 ; [ $ ? = 124 ] ; do
echo " m a v e n h a n g s w h i l e d o w n l o a d i n g : ( "
done
'' ;
installPhase = '' f i n d $o u t / . m 2 - t y p e f \ ! - r e g e x ' . + \ ( p o m \ | j a r \ | x m l \ | s h a 1 \ ) ' - d e l e t e '' ; # delete files with lastModified timestamps inside
outputHashAlgo = " s h a 2 5 6 " ;
outputHashMode = " r e c u r s i v e " ;
outputHash = mavenDependenciesSha256 ;
} ;
# The purpose of this is to fetch the jar file out of public Maven and use Maven
# to build a monolithic, standalone jar, rather than build everything from source
# (given the state of Maven support in Nix). We're not actually building any java
# source here.
pomFileDir = " e x h i b i t o r - s t a n d a l o n e / s r c / m a i n / r e s o u r c e s / b u i l d s c r i p t s / s t a n d a l o n e / m a v e n " ;
nativeBuildInputs = [ maven ] ;
buildInputs = [ makeWrapper ] ;
buildPhase = ''
2017-07-21 21:10:44 +01:00
cd $ { pomFileDir }
2017-07-11 15:56:58 +01:00
mvn package - - offline - Dmaven . repo . local = $ ( cp - dpR $ { fetchedMavenDeps } /.m2 . / && chmod + w - R . m2 && pwd ) /.m2
'' ;
meta = with stdenv . lib ; {
2017-08-01 21:03:30 +01:00
homepage = https://github.com/soabase/exhibitor ;
2017-07-11 15:56:58 +01:00
description = " Z o o K e e p e r c o - p r o c e s s f o r i n s t a n c e m o n i t o r i n g , b a c k u p / r e c o v e r y , c l e a n u p a n d v i s u a l i z a t i o n " ;
license = licenses . asl20 ;
platforms = platforms . unix ;
} ;
installPhase = ''
mkdir - p $ out/bin
mkdir - p $ out/share/java
mv target / $ name . jar $ out/share/java /
makeWrapper $ { jdk } /bin/java $ out/bin/startExhibitor.sh - - add-flags " - j a r $ o u t / s h a r e / j a v a / $ n a m e . j a r " - - suffix PATH : $ { stdenv . lib . makeBinPath [ jdk ] }
'' ;
}