anchor.diff:  
     configureFlags = lib.optional (!xarSupport) "--without-xml2";
   
  -  preBuild = if stdenv.isCygwin then ''
  +  postPatch = ''
  +     substituteInPlace Makefile.am --replace '/bin/pwd' 'pwd'
  +  '';
  +
  +  preBuild = lib.optionalString stdenv.isCygwin ''
       echo "#include <windows.h>" >> config.h
  -  '' else null;
  +  '';
   
  -  doCheck = false; # fails
  +  # 484: test_write_disk_perms FAIL
  +  # TODO: how to disable it? Should it be reported upstream?
  +  doCheck = false;
   
     preFixup = ''
       sed -i $lib/lib/libarchive.la \
  
positive.code: 
    enableParallelBuilding = true;
  
    passthru.tests = {
      inherit cmake nix samba;
    };
  
    meta = {
      description = "Multi-format archive and compression library";
      longDescription = ''
        This library has code for detecting and reading many archive formats and
        compressions formats including (but not limited to) tar, shar, cpio, zip, and
        compressed with gzip, bzip2, lzma, xz, ...
      '';
      homepage = "http://libarchive.org";
      changelog = "https://github.com/libarchive/libarchive/releases/tag/v${version}";
      license = lib.licenses.bsd3;
      platforms = with lib.platforms; all;
      maintainers = with lib.maintainers; [ jcumming ];
    };
  }
  
negative.code: { lib
  , stdenv
  , fetchFromGitHub
  , acl
  , attr
  , autoreconfHook
  , bzip2
  , e2fsprogs
  , lzo
  , openssl
  , pkg-config
  , sharutils
  , xz
  , zlib
  , zstd
  # Optional but increases closure only negligibly. Also, while libxml2 builds
  # fine on windows, libarchive has trouble linking windows things it depends on
  # for some reason.
  , xarSupport ? stdenv.hostPlatform.isUnix, libxml2
  
  # for passthru.tests
  , cmake
  , nix
  , samba
  }:
  
  assert xarSupport -> libxml2 != null;
  