@@ -14,9 +14,25 @@ stdenv.mkDerivation rec {
1414
1515 buildInputs = [ zlib bzip2 xz curl ];
1616
17− configureFlags = [ "--enable-libcurl" ]; # optional but strongly recommended
17+ configureFlags = if ! stdenv.hostPlatform.isStatic
18+ then [ "--enable-libcurl" ] # optional but strongly recommended
19+ else [ "--disable-libcurl" "--disable-plugins" ];
1820
19− installFlags = [ "prefix=$(out)" ];
21+
22+ # In the case of static builds, we need to replace the build and install phases
23+ buildPhase = lib.optional stdenv.hostPlatform.isStatic ''
24+ make AR=$AR lib-static
25+ make LDFLAGS=-static bgzip htsfile tabix
26+ '';
27+
28+ installPhase = lib.optional stdenv.hostPlatform.isStatic ''
29+ install -d $out/bin
30+ install -d $out/lib
31+ install -d $out/include/htslib
32+ install -D libhts.a $out/lib
33+ install -m644 htslib/*h $out/include/htslib
34+ install -D bgzip htsfile tabix $out/bin
35+ '';
2036
2137 preCheck = ''
2238 patchShebangs test/