1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 jdk,
6 ant,
7 git,
8 coreutils,
9 hostname,
10 gawk,
11 unzip,
12}:
13
14stdenv.mkDerivation rec {
15 pname = "rtg-tools";
16 version = "3.13";
17
18 src = fetchFromGitHub {
19 owner = "RealTimeGenomics";
20 repo = "rtg-tools";
21 rev = version;
22 hash = "sha256-vPzKrgnX6BCQmn9aOVWWpFLC6SbPBHZhZ+oL1LCbvmo=";
23 };
24
25 nativeBuildInputs = [
26 ant
27 jdk
28 git # Required by build.xml to manage the build revision
29 unzip
30 ];
31
32 buildPhase = ''
33 runHook preBuild
34 ant rtg-tools.jar
35 runHook postBuild
36 '';
37
38 installPhase = ''
39 runHook preInstall
40 mkdir -p $out/bin
41 cp build/rtg-tools.jar $out/bin/RTG.jar
42 cp installer/rtg $out/bin/
43 runHook postInstall
44 '';
45
46 postPatch = ''
47 # Use a location outside nix (must be writable)
48 substituteInPlace installer/rtg \
49 --replace-fail '$THIS_DIR/rtg.cfg' '$HOME/.config/rtg-tools/rtg.cfg' \
50 --replace-fail 'RTG_JAVA="java"' 'RTG_JAVA="${lib.getExe jdk}"' \
51 --replace-fail uname ${lib.getExe' coreutils "uname"} \
52 --replace-fail awk ${lib.getExe gawk} \
53 --replace-fail "hostname -s" "${lib.getExe hostname} -s"
54
55 sed -i '/USER_JAVA_OPTS=$RTG_JAVA_OPTS/a mkdir -p $HOME/.config/rtg-tools' installer/rtg
56 '';
57
58 checkPhase = ''
59 ant runalltests
60 '';
61
62 meta = with lib; {
63 homepage = "https://github.com/RealTimeGenomics/rtg-tools";
64 description = "Useful utilities for dealing with VCF files and sequence data, especially vcfeval";
65 license = licenses.bsd2;
66 platforms = [ "x86_64-linux" ];
67 maintainers = with maintainers; [ apraga ];
68 };
69}