about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/science/biology/htslib/default.nix
blob: bf9233d3050eb9a0f471da6992037d5ec86cbaf1 (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
{ lib, stdenv, fetchurl, zlib, bzip2, xz, curl, perl }:

stdenv.mkDerivation rec {
  pname = "htslib";
  version = "1.18";

  src = fetchurl {
    url = "https://github.com/samtools/htslib/releases/download/${version}/${pname}-${version}.tar.bz2";
    sha256 = "sha256-8atTpZOiMgob+t9O+RXa54QAbFtckiyKgXTXUwqa8Y8=";
  };

  # perl is only used during the check phase.
  nativeBuildInputs = [ perl ];

  buildInputs = [ zlib bzip2 xz curl ];

  configureFlags = if ! stdenv.hostPlatform.isStatic
                    then [ "--enable-libcurl" ] # optional but strongly recommended
                    else [ "--disable-libcurl" "--disable-plugins" ];


  # In the case of static builds, we need to replace the build and install phases
  buildPhase = lib.optional stdenv.hostPlatform.isStatic ''
    make AR=$AR lib-static
    make LDFLAGS=-static bgzip htsfile tabix
  '';

  installPhase = lib.optional stdenv.hostPlatform.isStatic ''
    install -d $out/bin
    install -d $out/lib
    install -d $out/include/htslib
    install -D libhts.a $out/lib
    install  -m644 htslib/*h $out/include/htslib
    install -D bgzip htsfile tabix $out/bin
  '';

  preCheck = ''
    patchShebangs test/
  '';

  enableParallelBuilding = true;

  doCheck = true;

  meta = with lib; {
    description = "A C library for reading/writing high-throughput sequencing data";
    license = licenses.mit;
    homepage = "http://www.htslib.org/";
    platforms = platforms.unix;
    maintainers = [ maintainers.mimame ];
  };
}