16 # Optional but increases closure only negligibly. Also, while libxml2 builds
17 # fine on windows, libarchive has trouble linking windows things it depends on
19 , xarSupport ? stdenv.hostPlatform.isUnix, libxml2
27 assert xarSupport -> libxml2 != null;
29 stdenv.mkDerivation rec {
33 src = fetchFromGitHub {
37 hash = "sha256-G4wL5DDbX0FqaA4cnOlVLZ25ObN8dNsRtxyas29tpDA=";
41 substituteInPlace Makefile.am --replace '/bin/pwd' "$(type -P pwd)"
43 declare -a skip_test_paths=(
44 # test won't work in nix sandbox
45 'libarchive/test/test_write_disk_perms.c'
46 # can't be sure builder will have sparse-capable fs
47 'libarchive/test/test_sparse_basic.c'
48 # can't even be sure builder will have hardlink-capable fs
49 'libarchive/test/test_write_disk_hardlink.c'
50 # access-time-related tests flakey on some systems
51 'cpio/test/test_option_a.c'
52 'cpio/test/test_option_t.c'
55 for test_path in "''${skip_test_paths[@]}" ; do
56 substituteInPlace Makefile.am --replace "$test_path" ""
61 outputs = [ "out" "lib" "dev" ];
75 ] ++ lib.optional stdenv.hostPlatform.isUnix sharutils
76 ++ lib.optionals stdenv.isLinux [ acl attr e2fsprogs ]
77 ++ lib.optional xarSupport libxml2;
79 # Without this, pkg-config-based dependencies are unhappy
80 propagatedBuildInputs = lib.optionals stdenv.isLinux [ attr acl ];
82 configureFlags = lib.optional (!xarSupport) "--without-xml2";
84 preBuild = lib.optionalString stdenv.isCygwin ''
85 echo "#include <windows.h>" >> config.h
88 # https://github.com/libarchive/libarchive/issues/1475
89 doCheck = !stdenv.hostPlatform.isMusl;
92 sed -i $lib/lib/libarchive.la \
93 -e 's|-lcrypto|-L${lib.getLib openssl}/lib -lcrypto|' \
94 -e 's|-llzo2|-L${lzo}/lib -llzo2|'
97 enableParallelBuilding = true;
100 homepage = "http://libarchive.org";
101 description = "Multi-format archive and compression library";
103 The libarchive project develops a portable, efficient C library that can
104 read and write streaming archives in a variety of formats. It also
105 includes implementations of the common tar, cpio, and zcat command-line
106 tools that use the libarchive library.
108 changelog = "https://github.com/libarchive/libarchive/releases/tag/v${version}";
109 license = licenses.bsd3;
110 maintainers = with maintainers; [ jcumming AndersonTorres ];
111 platforms = platforms.all;
115 inherit cmake nix samba;