From 25ea922a4b5bc87df4e4c20d25947acd1b2902df Mon Sep 17 00:00:00 2001 From: TomaSajt <62384384+TomaSajt@users.noreply.github.com> Date: Tue, 19 Mar 2024 09:08:42 +0100 Subject: [PATCH] astral: make deterministic and clean up --- .../science/biology/astral/default.nix | 50 +++++++++++++------ .../biology/astral/make-deterministic.patch | 21 ++++++++ 2 files changed, 55 insertions(+), 16 deletions(-) create mode 100644 pkgs/applications/science/biology/astral/make-deterministic.patch diff --git a/pkgs/applications/science/biology/astral/default.nix b/pkgs/applications/science/biology/astral/default.nix index ffe0326239cc..34077949b97d 100644 --- a/pkgs/applications/science/biology/astral/default.nix +++ b/pkgs/applications/science/biology/astral/default.nix @@ -2,49 +2,67 @@ , stdenvNoCC , fetchFromGitHub , jdk8 -, makeWrapper , jre8 +, strip-nondeterminism +, makeWrapper , zip }: + let jdk = jdk8; jre = jre8; in -stdenvNoCC.mkDerivation rec { +stdenvNoCC.mkDerivation (finalAttrs: { pname = "astral"; version = "5.7.1"; src = fetchFromGitHub { owner = "smirarab"; repo = "ASTRAL"; - rev = "v${version}"; - sha256 = "043w2z6gbrisqirdid022f4b8jps1pp5syi344krv2bis1gjq5sn"; + rev = "v${finalAttrs.version}"; + hash = "sha256-VhcsX9BxiZ0nISN6Xe4N+kq0iBMCtNhyxDrm9cwXfBA="; }; - nativeBuildInputs = [ jdk makeWrapper jre zip ]; + patches = [ + # we can't use stripJavaArchivesHook here, because the build process puts a .jar file into a zip file + # this patch calls strip-nondeterminism manually + ./make-deterministic.patch + ]; + + nativeBuildInputs = [ + jdk + zip + strip-nondeterminism + makeWrapper + ]; buildPhase = '' + runHook preBuild patchShebangs ./make.sh ./make.sh + runHook postBuild ''; doCheck = true; checkPhase = '' runHook preCheck - java -jar astral.${version}.jar -i main/test_data/song_primates.424.gene.tre + java -jar astral.${finalAttrs.version}.jar -i main/test_data/song_primates.424.gene.tre runHook postCheck ''; installPhase = '' - mkdir -p $out/share/lib - mkdir -p $out/bin - mv astral.${version}.jar $out/share/ - mv lib/*.jar $out/share/lib - mv Astral.${version}.zip $out/share/ - cp -a main/test_data $out/share/ + runHook preInstall + + install -Dm644 astral.${finalAttrs.version}.jar -t $out/share + install -Dm644 lib/*.jar -t $out/share/lib + install -Dm644 Astral.${finalAttrs.version}.zip -t $out/share + cp -a main/test_data $out/share + makeWrapper ${jre}/bin/java $out/bin/astral \ - --add-flags "-jar $out/share/astral.${version}.jar" + --add-flags "-jar $out/share/astral.${finalAttrs.version}.jar" + + runHook postInstall ''; meta = with lib; { @@ -53,9 +71,9 @@ stdenvNoCC.mkDerivation rec { mainProgram = "astral"; sourceProvenance = with sourceTypes; [ fromSource - binaryBytecode # source bundles dependencies as jars + binaryBytecode # source bundles dependencies as jars ]; license = licenses.asl20; - maintainers = with maintainers; [ bzizou ]; + maintainers = with maintainers; [ bzizou tomasajt ]; }; -} +}) diff --git a/pkgs/applications/science/biology/astral/make-deterministic.patch b/pkgs/applications/science/biology/astral/make-deterministic.patch new file mode 100644 index 000000000000..940182e2f49f --- /dev/null +++ b/pkgs/applications/science/biology/astral/make-deterministic.patch @@ -0,0 +1,21 @@ +diff --git a/make.sh b/make.sh +index 3ff6529..937b1a2 100644 +--- a/make.sh ++++ b/make.sh +@@ -17,6 +17,8 @@ jar cvfm ../astral.$version.jar ../manifest.text phylonet/util/BitSet.* phylonet + + cd .. + ++strip-nondeterminism --type jar astral.$version.jar ++ + chmod +x astral.$version.jar + sed -e "s/__astral.jar__/astral.$version.jar/g" -e "s/__astral.zip__/Astral.$version.zip/g" README.template.md > README.md + sed -e "s/__astral.jar__/astral.$version.jar/g" -e "s/__astral.zip__/Astral.$version.zip/g" astral-tutorial-template.md > astral-tutorial.md +@@ -32,6 +34,7 @@ ln -s ../astral-tutorial.pdf . + cd .. + rm -f Astral.$version.zip + zip -r Astral.$version.zip Astral ++strip-nondeterminism --type zip Astral.$version.zip + + set +x + echo "