summary refs log tree commit diff
path: root/pkgs/applications/science/biology/blast/default.nix
blob: 95a1b905e9e24f90bb5ea3de635006dcdf8f9619 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
{ lib, stdenv, fetchurl, zlib, bzip2, perl, cpio, gawk, coreutils, ApplicationServices }:

stdenv.mkDerivation rec {
  pname = "blast";
  version = "2.10.0";

  src = fetchurl {
    url = "ftp://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/${version}/ncbi-blast-${version}+-src.tar.gz";
    sha256 = "09nry5knj5hhxpn0a5ww1gb1704grd4r1y7adbjl6kqwq37dkk9s";
  };

  sourceRoot = "ncbi-blast-${version}+-src/c++";
  
  configureFlags = [ 
    # With flat Makefile we can use all_projects in order not to build extra.
    # These extra cause clang to hang on Darwin.
    "--with-flat-makefile"
    "--without-makefile-auto-update" 
    "--with-dll"  # build dynamic libraries (static are default)
    ];
  
  makeFlags = [ "all_projects=app/" ];

  preConfigure = ''
    export NCBICXX_RECONF_POLICY=warn
    export PWD=$(pwd)
    export HOME=$PWD

    # The configure scripts wants to set AR="ar cr" unless it is already set in
    # the environment. Because stdenv sets AR="ar", the result is a bad call to
    # the assembler later in the process. Thus, we need to unset AR
    unset AR

    for awks in scripts/common/impl/is_log_interesting.awk \
        scripts/common/impl/report_duplicates.awk; do

        substituteInPlace $awks \
              --replace /usr/bin/awk ${gawk}/bin/awk
    done

    for mk in src/build-system/Makefile.meta.in \
        src/build-system/helpers/run_with_lock.c ; do

        substituteInPlace $mk \
        --replace /bin/rm ${coreutils}/bin/rm
    done

    for mk in src/build-system/Makefile.meta.gmake=no \
        src/build-system/Makefile.meta_l \
        src/build-system/Makefile.meta_r \
        src/build-system/Makefile.requirements \
        src/build-system/Makefile.rules_with_autodep.in; do

        substituteInPlace $mk \
            --replace /bin/echo ${coreutils}/bin/echo
    done
    for mk in src/build-system/Makefile.meta_p \
        src/build-system/Makefile.rules_with_autodep.in \
        src/build-system/Makefile.protobuf.in ; do

        substituteInPlace $mk \
            --replace /bin/mv ${coreutils}/bin/mv
    done


    substituteInPlace src/build-system/configure \
        --replace /bin/pwd ${coreutils}/bin/pwd \
        --replace /bin/ln ${coreutils}/bin/ln

    substituteInPlace src/build-system/configure.ac \
        --replace /bin/pwd ${coreutils}/bin/pwd \
        --replace /bin/ln ${coreutils}/bin/ln

    substituteInPlace src/build-system/Makefile.meta_l \
        --replace /bin/date ${coreutils}/bin/date
  '';

  nativeBuildInputs = [ perl ];

  # perl is necessary in buildInputs so that installed perl scripts get patched
  # correctly
  buildInputs = [ coreutils perl gawk zlib bzip2 cpio ]
    ++ lib.optionals stdenv.isDarwin [ ApplicationServices ];
  hardeningDisable = [ "format" ];

  postInstall = ''
    substituteInPlace $out/bin/get_species_taxids.sh \
        --replace /bin/rm ${coreutils}/bin/rm
  '';
  patches = [ ./no_slash_bin.patch ];

  enableParallelBuilding = true;

  # Many tests require either network access or locally available databases
  doCheck = false;

  meta = with stdenv.lib; {
    description = ''Basic Local Alignment Search Tool (BLAST) finds regions of
    similarity between biological sequences'';
    homepage = "https://blast.ncbi.nlm.nih.gov/Blast.cgi";
    license = licenses.publicDomain;

    # Version 2.10.0 fails on Darwin
    # See https://github.com/NixOS/nixpkgs/pull/61430
    platforms = platforms.linux;
    maintainers = with maintainers; [ luispedro ];
  };
}