diff --git a/pkgs/development/r-modules/default.nix b/pkgs/development/r-modules/default.nix index e944bdba59ae..2148b1afc4d5 100644 --- a/pkgs/development/r-modules/default.nix +++ b/pkgs/development/r-modules/default.nix @@ -1758,7 +1758,6 @@ let "Rmpi" # tries to run MPI processes "ReactomeContentService4R" # tries to connect to Reactome "PhIPData" # tries to download something from a DB - "RBioFormats" # tries to download jar during load test "pbdMPI" # tries to run MPI processes "CTdata" # tries to connect to ExperimentHub "rfaRm" # tries to connect to Ebi @@ -2021,6 +2020,34 @@ let ''; }); + RBioFormats = old.RBioFormats.overrideAttrs (attrs: { + # 1. Never download the jar file + # 2. Use jar from pkgs.bftools instead + # 3. Break the build if versions don't match + propagatedBuildInputs = (attrs.propagatedBuildInputs or [ ]) ++ [ pkgs.bftools ]; + + postPatch = '' + substituteInPlace "R/zzz.R" \ + --replace-fail '!file.exists(bf_jar)' 'FALSE' \ + --replace-fail \ + '.jpackage(pkg, lib.loc = lib, morePaths = c(jars, bf_jar))' \ + '.jpackage(pkg, lib.loc = lib, morePaths = union(jars, "${lib.getBin pkgs.bftools}/share/java/bioformats_package.jar"))' \ + --replace-fail 'bf_jar <-' 'stopifnot(bf_ver == "${pkgs.bftools.version}");bf_jar <-' + ''; + + # Ensure that bftools version matches that in the package DESCRIPTION + preInstall = '' + rbf_version="$(sed -n 's/^BioFormats: //p' DESCRIPTION)" + bf_version="${pkgs.bftools.version}" + if [ "$rbf_version" != "$bf_version" ]; then + echo "BioFormats version mismatch detected!" + echo "RBioformats needs: $rbf_version" + echo "bftools provides: $bf_version" + exit 1 + fi + ''; + }); + rbm25 = old.rbm25.overrideAttrs (attrs: { postPatch = "patchShebangs configure"; });