{ appleDerivation', lib, stdenv, stdenvNoCC, buildPackages , bootstrap_cmds, bison, flex , gnum4, unifdef, perl, python3 , headersOnly ? true }: appleDerivation' (if headersOnly then stdenvNoCC else stdenv) ( let arch = if stdenv.isx86_64 then "x86_64" else "arm64"; in { depsBuildBuild = [ buildPackages.stdenv.cc ]; nativeBuildInputs = [ bootstrap_cmds bison flex gnum4 unifdef perl python3 ]; patches = lib.optionals stdenv.isx86_64 [ ./python3.patch ]; postPatch = '' substituteInPlace Makefile \ --replace "/bin/" "" \ --replace "MAKEJOBS := " '# MAKEJOBS := ' substituteInPlace makedefs/MakeInc.cmd \ --replace "/usr/bin/" "" \ --replace "/bin/" "" \ --replace "-Werror " "" substituteInPlace makedefs/MakeInc.def \ --replace "-c -S -m" "-c -m" substituteInPlace makedefs/MakeInc.top \ --replace "MEMORY_SIZE := " 'MEMORY_SIZE := 1073741824 # ' substituteInPlace libkern/kxld/Makefile \ --replace "-Werror " "" substituteInPlace SETUP/kextsymboltool/Makefile \ --replace "-lstdc++" "-lc++ -lc++abi" substituteInPlace libsyscall/xcodescripts/mach_install_mig.sh \ --replace "/usr/include" "/include" \ --replace "/usr/local/include" "/include" \ --replace 'MIG=`' "# " \ --replace 'MIGCC=`' "# " \ --replace " -o 0" "" \ --replace '$SRC/$mig' '-I$DSTROOT/include $SRC/$mig' \ --replace '$SRC/servers/netname.defs' '-I$DSTROOT/include $SRC/servers/netname.defs' \ --replace '$BUILT_PRODUCTS_DIR/mig_hdr' '$BUILT_PRODUCTS_DIR' \ --replace 'MACHINE_ARCH=armv7' 'MACHINE_ARCH=arm64' # this might break the comments saying 32-bit is required patchShebangs . '' + lib.optionalString stdenv.isAarch64 '' # iig is closed-sourced, we don't have it # create an empty file to the header instead # this line becomes: echo "" > $@; echo --header ... substituteInPlace iokit/DriverKit/Makefile \ --replace '--def $<' '> $@; echo' ''; PLATFORM = "MacOSX"; SDKVERSION = "10.11"; CC = "${stdenv.cc.targetPrefix or ""}cc"; CXX = "${stdenv.cc.targetPrefix or ""}c++"; MIG = "mig"; MIGCOM = "migcom"; STRIP = "${stdenv.cc.bintools.targetPrefix or ""}strip"; RANLIB = "${stdenv.cc.bintools.targetPrefix or ""}ranlib"; NM = "${stdenv.cc.bintools.targetPrefix or ""}nm"; UNIFDEF = "unifdef"; DSYMUTIL = "dsymutil"; HOST_OS_VERSION = "10.10"; HOST_CC = "${buildPackages.stdenv.cc.targetPrefix or ""}cc"; HOST_FLEX = "flex"; HOST_BISON = "bison"; HOST_GM4 = "m4"; MIGCC = "cc"; ARCHS = arch; ARCH_CONFIGS = arch; env.NIX_CFLAGS_COMPILE = "-Wno-error"; preBuild = let macosVersion = "10.0 10.1 10.2 10.3 10.4 10.5 10.6 10.7 10.8 10.9 10.10 10.11" + lib.optionalString stdenv.isAarch64 " 10.12 10.13 10.14 10.15 11.0"; in '' # This is a bit of a hack... mkdir -p sdk/usr/local/libexec cat > sdk/usr/local/libexec/availability.pl <