2 fetchFromGitHub, lib, stdenv, pkg-config, autoreconfHook,
3 acl, attr, bzip2, e2fsprogs, libxml2, lzo, openssl, sharutils, xz, zlib, zstd,
5 # Optional but increases closure only negligibly. Also, while libxml2
6 # builds fine on windows, but libarchive has trouble linking windows
7 # things it depends on for some reason.
8 xarSupport ? stdenv.hostPlatform.isUnix,
11 assert xarSupport -> libxml2 != null;
13 stdenv.mkDerivation rec {
17 src = fetchFromGitHub {
21 sha256 = "sha256-RFPhe4PCq8OLwa6c7ir+5u9jBsUxS5M/fcZYAG9W6R0=";
24 outputs = [ "out" "lib" "dev" ];
26 nativeBuildInputs = [ pkg-config autoreconfHook ];
28 lib.optional stdenv.hostPlatform.isUnix sharutils
29 ++ [ zlib bzip2 openssl xz lzo zstd ]
30 ++ lib.optionals stdenv.isLinux [ e2fsprogs attr acl ]
31 ++ lib.optional xarSupport libxml2;
33 # Without this, pkg-config-based dependencies are unhappy
34 propagatedBuildInputs = lib.optionals stdenv.isLinux [ attr acl ];
36 configureFlags = lib.optional (!xarSupport) "--without-xml2";
38 preBuild = if stdenv.isCygwin then ''
39 echo "#include <windows.h>" >> config.h
42 doCheck = false; # fails
45 sed -i $lib/lib/libarchive.la \
46 -e 's|-lcrypto|-L${openssl.out}/lib -lcrypto|' \
47 -e 's|-llzo2|-L${lzo}/lib -llzo2|'
50 enableParallelBuilding = true;
53 description = "Multi-format archive and compression library";
55 This library has code for detecting and reading many archive formats and
56 compressions formats including (but not limited to) tar, shar, cpio, zip, and
57 compressed with gzip, bzip2, lzma, xz, ...
59 homepage = "http://libarchive.org";
60 changelog = "https://github.com/libarchive/libarchive/releases/tag/v${version}";
61 license = lib.licenses.bsd3;
62 platforms = with lib.platforms; all;
63 maintainers = with lib.maintainers; [ jcumming ];