diff --git a/pkgs/os-specific/darwin/apple-source-releases/libresolv/meson.build.in b/pkgs/os-specific/darwin/apple-source-releases/libresolv/meson.build.in index 6a7c523a164c..2d96b556bbc8 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/libresolv/meson.build.in +++ b/pkgs/os-specific/darwin/apple-source-releases/libresolv/meson.build.in @@ -3,6 +3,12 @@ # Project settings project('libresolv', 'c', version : '@version@') +add_project_arguments( + '-DCOMMON_DIGEST_FOR_RFC_1321', # To enable legacy `MD5` APIs in CommonCrypto. + # This is not defined automatically by Clang. Not having them defined causes compilation failures. + '-DTARGET_OS_BRIDGE=0', + language : 'c', +) # Dependencies @@ -46,10 +52,12 @@ libresolv = library( soversion : '9' ) install_headers( + 'arpa/nameser_compat.h', 'dns.h', 'dns_util.h', 'nameser.h', 'resolv.h', + preserve_path : true, ) install_man( 'resolver.3', diff --git a/pkgs/os-specific/darwin/apple-source-releases/libresolv/package.nix b/pkgs/os-specific/darwin/apple-source-releases/libresolv/package.nix index 158317c22c80..9e63efb55228 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/libresolv/package.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/libresolv/package.nix @@ -2,14 +2,31 @@ lib, apple-sdk, mkAppleDerivation, + stdenvNoCC, }: let configd = apple-sdk.sourceRelease "configd"; + dyld = apple-sdk.sourceRelease "dyld"; Libinfo = apple-sdk.sourceRelease "Libinfo"; + Libnotify = apple-sdk.sourceRelease "Libnotify"; + xnu = apple-sdk.sourceRelease "xnu"; # `arpa/nameser_compat.h` is included in the Libc source release instead of libresolv. Libc = apple-sdk.sourceRelease "Libc"; + + privateHeaders = stdenvNoCC.mkDerivation { + name = "libresolv-deps-private-headers"; + + buildCommand = '' + install -D -t "$out/include/mach-o" \ + '${dyld}/include/mach-o/dyld_priv.h' + + substituteInPlace "$out/include/mach-o/dyld_priv.h" \ + --replace-fail ', bridgeos(3.0)' "" \ + --replace-fail '//@VERSION_DEFS@' 'const dyld_build_version_t dyld_2024_SU_E_os_versions = { 1 /* macOS */, 150400 };' + ''; + }; in mkAppleDerivation { releaseName = "libresolv"; @@ -20,19 +37,18 @@ mkAppleDerivation { "man" ]; - xcodeHash = "sha256-yHNa6cpI3T4R/iakeHmL6S/c9p+VpYR4fudv2UXUpnY="; - - postUnpack = '' - mkdir -p "$sourceRoot/arpa" - ln -s "$NIX_BUILD_TOP/$sourceRoot/nameser.h" "$sourceRoot/arpa/nameser.h" + postPatch = '' + mkdir arpa + cp ${Libc}/include/arpa/nameser_compat.h arpa/nameser_compat.h + cp nameser.h arpa ''; - env.NIX_CFLAGS_COMPILE = "-I${configd}/dnsinfo -I${Libinfo}/lookup.subproj"; + xcodeHash = "sha256-yHNa6cpI3T4R/iakeHmL6S/c9p+VpYR4fudv2UXUpnY="; + + env.NIX_CFLAGS_COMPILE = "-I${privateHeaders}/include -I${configd}/dnsinfo -I${Libinfo}/lookup.subproj -I${Libnotify}"; postInstall = '' - mkdir -p "$out/include/arpa" - ln -s ../nameser.h "$out/include/arpa" - cp ${Libc}/include/arpa/nameser_compat.h "$out/include/arpa" + ln -s ../nameser.h "''${!outputDev}/include/arpa" ''; meta = {