diff --git a/pkgs/all-packages.nix b/pkgs/all-packages.nix index 56a8f8c..e73ce45 100644 --- a/pkgs/all-packages.nix +++ b/pkgs/all-packages.nix @@ -4,6 +4,10 @@ # self: super: pkgs: with pkgs; { + blast = callPackage ./blast { + stdenv = overrideCC stdenv gcc5; + }; + cryptominisat = callPackage ./cryptominisat.nix { }; #firedrake = callPackage ./firedrake { }; diff --git a/pkgs/blast/default.nix b/pkgs/blast/default.nix new file mode 100644 index 0000000..5fea7bd --- /dev/null +++ b/pkgs/blast/default.nix @@ -0,0 +1,74 @@ +{ stdenv, fetchurl, gcc5, cpio, curl +, python, perl, zlib, bzip2, boost }: + +stdenv.mkDerivation rec { + version = "2.6.0"; + name = "ncbi-blast-${version}"; + + src = fetchurl { + url = "ftp://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/${version}/ncbi-blast-${version}+-src.tar.gz"; + sha256 = "15n937pw5aqmyfjb6l387d18grqbb96l63d5xj4l7yyh0zbf2405"; + }; + + # The install target is broken as it tries to install a subdirectory using install + patches = [ ./install.patch ]; + + # Contains a lot of hardcoded paths for standard utils and some scripts the just reset PATH for the fun of it. + # + # - for every $cmd on the path, replace all occurances of /usr/bin/$cmd and /bin/$cmd with it + # - delete every line that has PATH=/bin:/usr/bin in it + # + # A bit of prefix/suffix matching and escaping is required for the first to avoid replacing things like $(foo)/bin/... + # and keeping the sed regexps valid in the face of commands like [. + # + postPatch = '' + patchShebangs . + echo 'replacing hardcoded /bin and /usr/bin commands with any nix equivalents on the PATH' + find -L ''${PATH//:/ } -maxdepth 1 -type f -perm -u=x -print0 | + while read -d ''' -r cmd; do + cmd=''${cmd//\/\\\\} + cmd=''${cmd//{/\\{} + cmd=''${cmd//[/\\[} + cmd=''${cmd//(/\\(} + cmd=''${cmd//)/\\)} + cmd=''${cmd//+/\\+} + cmd=''${cmd//\*/\\*} + cmd=''${cmd//\?/\\?} + cmd=''${cmd//!/\\!} + echo 's!(^|[[:space:]({>`'\'''";|,=@\!]|&&|\|\|)(/usr)?/bin/'"''${cmd##*/}"'($|[[:space:])}<`'\'''";|,]|&&|\|\|)!\1'"$cmd"'\3!g' + done >> commands.sed + find c++ -type f -print0 | xargs -0 -n 16 -P $NIX_BUILD_CORES \ + sed -i -E \ + -e '/ *PATH=['\'''"]?\/bin:\/usr\/bin/d' \ + -e 's!/bin/(\$base_action|\$LN_S)!\1!g' \ + -f commands.sed + ''; + + # AR command variable is abused to include parameters, but these don't get figured out if $AR is already set + preConfigure = '' + cd c++ + test -n "$AR" && AR="$AR cr" || true + ''; + + configureFlags = "--with-dll --without-debug --with-bin-release --with-strip --with-mt --without-opengl --without-connext"; + + buildInputs = [ + boost + zlib + bzip2 + cpio + curl + python +# python3 -- some scripts like ./c++/scripts/projects/magicblast/post_build/blast_utils.py + perl + ]; + + meta = with stdenv.lib; { + homepage = https://blast.ncbi.nlm.nih.gov/; + description = "BLAST finds regions of similarity between biological sequences. The program compares nucleotide or protein sequences to sequence databases and calculates the statistical significance."; + platforms = platforms.all; + license = licenses.publicDomain; + }; + + enableParallelBuilding = true; +} diff --git a/pkgs/blast/install.patch b/pkgs/blast/install.patch new file mode 100644 index 0000000..3fbd6c0 --- /dev/null +++ b/pkgs/blast/install.patch @@ -0,0 +1,16 @@ +--- ncbi-blast-2.6.0+-src/c++/src/build-system/Makefile.in.top_ 2018-04-23 16:13:57.759988900 -0400 ++++ ncbi-blast-2.6.0+-src/c++/src/build-system/Makefile.in.top 2018-04-23 16:14:38.270252707 -0400 +@@ -49,9 +49,10 @@ + for x in *.a; do \ + $(LN_S) "$$x" "`$(BASENAME) \"$$x\" .a`-static.a"; \ + done +- cd $(includedir0) && find * -name CVS -prune -o -print |\ +- cpio -pd $(pincludedir) +- $(INSTALL) -m 644 $(incdir)/* $(pincludedir) ++ cd $(includedir0) && find * -type f \( -name '*.inl' -o -name '*.h' -o -name '*.hpp' -o -name '*.c' \) \ ++ -exec $(INSTALL) -m 644 -D \{\} $(pincludedir)/\{\} \; ++ cd $(incdir) && find * -type f \( -name '*.inl' -o -name '*.h' -o -name '*.hpp' -o -name '*.c' \) \ ++ -exec $(INSTALL) -m 644 -D \{\} $(pincludedir)/\{\} \; + ## set up appropriate build and status directories somewhere under $(libdir)? + + install-gbench: