17 # Optional but increases closure only negligibly. Also, while libxml2 builds
18 # fine on windows, libarchive has trouble linking windows things it depends on
20 , xarSupport ? stdenv.hostPlatform.isUnix, libxml2
28 assert xarSupport -> libxml2 != null;
29 stdenv.mkDerivation (finalAttrs: {
33 src = fetchFromGitHub {
36 rev = "v${finalAttrs.version}";
37 hash = "sha256-p2JgJ/rvqaQ6yyXSh+ehScUH565ud5bQncl+lOnsWfc=";
41 # Pull fix for test failure on 32-bit systems:
43 name = "32-bit-tests-fix.patch";
44 url = "https://github.com/libarchive/libarchive/commit/3bd918d92f8c34ba12de9c6604d96f9e262a59fc.patch";
45 hash = "sha256-RM3xFM6S2DkM5DJ0kAba8eLzEXuY5/7AaU06maHJ6rM=";
49 outputs = [ "out" "lib" "dev" ];
53 # test won't work in nix sandbox
54 "libarchive/test/test_write_disk_perms.c"
55 # the filesystem does not necessarily have sparse capabilities
56 "libarchive/test/test_sparse_basic.c"
57 # the filesystem does not necessarily have hardlink capabilities
58 "libarchive/test/test_write_disk_hardlink.c"
59 # access-time-related tests flakey on some systems
60 "cpio/test/test_option_a.c"
61 "cpio/test/test_option_t.c"
63 removeTest = testPath: ''
64 substituteInPlace Makefile.am --replace "${testPath}" ""
68 substituteInPlace Makefile.am --replace '/bin/pwd' "$(type -P pwd)"
70 ${lib.concatStringsSep "\n" (map removeTest skipTestPaths)}
85 ] ++ lib.optional stdenv.hostPlatform.isUnix sharutils
86 ++ lib.optionals stdenv.isLinux [ acl attr e2fsprogs ]
87 ++ lib.optional xarSupport libxml2;
89 # Without this, pkg-config-based dependencies are unhappy
90 propagatedBuildInputs = lib.optionals stdenv.isLinux [ attr acl ];
92 configureFlags = lib.optional (!xarSupport) "--without-xml2";
94 preBuild = lib.optionalString stdenv.isCygwin ''
95 echo "#include <windows.h>" >> config.h
98 # https://github.com/libarchive/libarchive/issues/1475
99 doCheck = !stdenv.hostPlatform.isMusl;
102 sed -i $lib/lib/libarchive.la \
103 -e 's|-lcrypto|-L${lib.getLib openssl}/lib -lcrypto|' \
104 -e 's|-llzo2|-L${lzo}/lib -llzo2|'
107 enableParallelBuilding = true;
110 homepage = "http://libarchive.org";
111 description = "Multi-format archive and compression library";
113 The libarchive project develops a portable, efficient C library that can
114 read and write streaming archives in a variety of formats. It also
115 includes implementations of the common tar, cpio, and zcat command-line
116 tools that use the libarchive library.
118 changelog = "https://github.com/libarchive/libarchive/releases/tag/v${finalAttrs.version}";
119 license = licenses.bsd3;
120 maintainers = with maintainers; [ jcumming AndersonTorres ];
121 platforms = platforms.all;
125 inherit cmake nix samba;