diff --git a/pkgs/development/libraries/libasyncns/default.nix b/pkgs/development/libraries/libasyncns/default.nix
index c94e1c04e0ba..423b8cca6915 100644
--- a/pkgs/development/libraries/libasyncns/default.nix
+++ b/pkgs/development/libraries/libasyncns/default.nix
@@ -9,6 +9,11 @@ stdenv.mkDerivation rec {
     sha256 = "0x5b6lcic4cd7q0bx00x93kvpyzl7n2abbgvqbrlzrfb8vknc6jg";
   };
 
+  postPatch = lib.optionalString stdenv.isDarwin ''
+    substituteInPlace libasyncns/asyncns.c \
+      --replace '<arpa/nameser.h>' '<arpa/nameser_compat.h>'
+  '';
+
   configureFlags = lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
     "ac_cv_func_malloc_0_nonnull=yes"
     "ac_cv_func_realloc_0_nonnull=yes"