From 0b1c28d5a1c46a7a10aa518863b1bd532824495e Mon Sep 17 00:00:00 2001 From: Luis Pedro Coelho Date: Wed, 4 May 2022 02:13:31 +0200 Subject: [PATCH 1/4] Static build for megahit --- pkgs/applications/science/biology/megahit/default.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/applications/science/biology/megahit/default.nix b/pkgs/applications/science/biology/megahit/default.nix index ee2f16f389b..45cb7560502 100644 --- a/pkgs/applications/science/biology/megahit/default.nix +++ b/pkgs/applications/science/biology/megahit/default.nix @@ -14,6 +14,9 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ cmake ]; buildInputs = [ zlib ]; + cmakeFlags = lib.optional stdenv.hostPlatform.isStatic [ + "-DSTATIC_BUILD=ON" + ]; meta = with lib; { description = "An ultra-fast single-node solution for large and complex metagenomics assembly via succinct de Bruijn graph"; license = licenses.gpl3; From 967a5d78962b88f4e91fe5e3e4497912556ea60b Mon Sep 17 00:00:00 2001 From: Luis Pedro Coelho Date: Wed, 4 May 2022 02:15:17 +0200 Subject: [PATCH 2/4] Static builds for HTSLIB We need to disable curses support and replace the build and install phases (otherwise, they expect that *.so files will be present). --- .../science/biology/htslib/default.nix | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/pkgs/development/libraries/science/biology/htslib/default.nix b/pkgs/development/libraries/science/biology/htslib/default.nix index d93b4fb2a5a..2e3f9dec319 100644 --- a/pkgs/development/libraries/science/biology/htslib/default.nix +++ b/pkgs/development/libraries/science/biology/htslib/default.nix @@ -14,9 +14,25 @@ stdenv.mkDerivation rec { buildInputs = [ zlib bzip2 xz curl ]; - configureFlags = [ "--enable-libcurl" ]; # optional but strongly recommended + configureFlags = if ! stdenv.hostPlatform.isStatic + then [ "--enable-libcurl" ] # optional but strongly recommended + else [ "--disable-libcurl" "--disable-plugins" ]; - installFlags = [ "prefix=$(out)" ]; + + # 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/ From 47588733783c4133de4973caa466d52d9c04992a Mon Sep 17 00:00:00 2001 From: Luis Pedro Coelho Date: Wed, 4 May 2022 02:16:17 +0200 Subject: [PATCH 3/4] Static build for samtools Curses is not supported (it may be possible to support it) --- pkgs/applications/science/biology/samtools/default.nix | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkgs/applications/science/biology/samtools/default.nix b/pkgs/applications/science/biology/samtools/default.nix index 98b0394c35f..ec61e0bd7ce 100644 --- a/pkgs/applications/science/biology/samtools/default.nix +++ b/pkgs/applications/science/biology/samtools/default.nix @@ -22,8 +22,15 @@ stdenv.mkDerivation rec { buildInputs = [ zlib ncurses htslib ]; + preConfigure = lib.optional stdenv.hostPlatform.isStatic '' + export LIBS="-lz -lbz2 -llzma" + ''; + makeFlags = lib.optional stdenv.hostPlatform.isStatic "AR=${stdenv.cc.targetPrefix}ar"; + configureFlags = [ "--with-htslib=${htslib}" ] - ++ lib.optional (ncurses == null) "--without-curses"; + ++ lib.optional (ncurses == null) "--without-curses" + ++ lib.optional stdenv.hostPlatform.isStatic ["--without-curses" ] + ; preCheck = '' patchShebangs test/ From 596c5e7ea26ba8c0bcd6d2f09ca7cb8202c20e70 Mon Sep 17 00:00:00 2001 From: Luis Pedro Coelho Date: Wed, 4 May 2022 02:20:50 +0200 Subject: [PATCH 4/4] Static bwa AR needs to be passed specifically on the command line --- pkgs/applications/science/biology/bwa/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/applications/science/biology/bwa/default.nix b/pkgs/applications/science/biology/bwa/default.nix index a2a11b1d451..d4727b41bd0 100644 --- a/pkgs/applications/science/biology/bwa/default.nix +++ b/pkgs/applications/science/biology/bwa/default.nix @@ -17,6 +17,8 @@ stdenv.mkDerivation rec { sed -i '/^CC/d' Makefile ''; + makeFlags = lib.optional stdenv.hostPlatform.isStatic "AR=${stdenv.cc.targetPrefix}ar"; + # it's unclear which headers are intended to be part of the public interface # so we may find ourselves having to add more here over time installPhase = ''