Last active
July 28, 2019 11:03
-
-
Save scalavision/4dcb4ebdada1ab4232c6501cc145079c to your computer and use it in GitHub Desktop.
Unable to escape \$ for nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ stdenv, fetchFromGitHub, jdk, maven, jre, makeWrapper, ... }: | |
let | |
mavenDependenciesSha256 = "0cfj312zcf33s89qxpqycc3j8cnz44svylzxjg94d5147a5ddazb"; | |
src = fetchFromGitHub { | |
owner = "broadgsa"; | |
repo = "gatk-protected"; | |
sha256 = "025v8wxqnp3bab2g5pblrrd2yiy7w1jw7nd09544wamf8in8a8v6"; | |
rev = "aa8764d6c3de146856b174a8674fa787a6311d7c"; | |
}; | |
# This is adapted from https://github.com/volth/nixpkgs/blob/6aa470dfd57cae46758b62010a93c5ff115215d7/pkgs/applications/networking/cluster/hadoop/default.nix#L20-L32 | |
fetchedMavenDeps = stdenv.mkDerivation rec { | |
inherit src mavenDependenciesSha256; | |
buildInputs = [ maven ]; | |
version = "3.8-1"; | |
name = "gatk3-${version}-maven-deps"; | |
patchPhase = '' | |
substituteInPlace ./public/src/main/scripts/shell/delete_maven_links.sh \ | |
--replace "#!/bin/bash" "#!/usr/bin/env bash" | |
substituteInPlace ./public/src/main/scripts/shell/check_utils_engine_tools.sh \ | |
--replace "#!/bin/sh" "#!/usr/bin/env sh" | |
substituteInPlace pom.xml \ | |
--replace "\${gatk.shell.directory}/check_utils_engine_tools.sh" "./public/src/main/scripts/shell/check_utils_engine_tools.sh" | |
''; | |
buildPhase = '' | |
mvn -Dmaven.repo.local=$out/.m2 dependency:resolve-plugins | |
while timeout --kill-after=21m 20m mvn package -Dmaven.repo.local=$out/.m2; [ $? = 124 ]; do | |
echo "maven hangs while downloading :(" | |
done | |
echo "FINISHED BUILDING, DID WE GET MORE THAN JUST DEPS?" | |
ls -hal . | |
ls -hal ./public | |
''; | |
installPhase = '' | |
find $out/.m2 -type f \! -regex '.+\(pom\|jar\|xml\|sha1\)' -delete | |
''; # delete files with lastModified timestamps inside | |
outputHashAlgo = "sha256"; | |
outputHashMode = "recursive"; | |
outputHash = mavenDependenciesSha256; | |
}; | |
in | |
stdenv.mkDerivation rec { | |
name = "gatk3"; | |
version = "3.8-1"; | |
inherit src; | |
buildInputs = [ makeWrapper jdk maven ]; | |
buildPhase = '' | |
mvn package --offline -Dmaven.repo.local=$(cp -dpR ${fetchedMavenDeps}/.m2 ./ && chmod +w -R .m2 && pwd)/.m2 | |
''; | |
installPhase = '' | |
mkdir -p $out/bin | |
cp target/GenomeAnalysisTK.jar $out/bin/GenomeAnalysisTK.jar | |
makeWrapper ${jre}/bin/java $out/bin/GenomeAnalysisTK.jar --add-flags "-jar" | |
''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment