diff options
author | Dan Peebles <thetypesaretoobig@gmail.com> | 2015-02-08 01:53:52 -0500 |
---|---|---|
committer | Dan Peebles <thetypesaretoobig@gmail.com> | 2015-02-08 01:53:52 -0500 |
commit | 29f265dfd28ce5567106a7a1df3bd6c1fbd8406f (patch) | |
tree | 3973e0a11ae1737f8d307ec07651cf5c12498210 /pkgs/os-specific/darwin/apple-source-releases/Libsystem/default.nix | |
parent | f43c324cee6ed5fdbe679b70b71caaca1c4629a8 (diff) | |
download | nixlib-29f265dfd28ce5567106a7a1df3bd6c1fbd8406f.tar nixlib-29f265dfd28ce5567106a7a1df3bd6c1fbd8406f.tar.gz nixlib-29f265dfd28ce5567106a7a1df3bd6c1fbd8406f.tar.bz2 nixlib-29f265dfd28ce5567106a7a1df3bd6c1fbd8406f.tar.lz nixlib-29f265dfd28ce5567106a7a1df3bd6c1fbd8406f.tar.xz nixlib-29f265dfd28ce5567106a7a1df3bd6c1fbd8406f.tar.zst nixlib-29f265dfd28ce5567106a7a1df3bd6c1fbd8406f.zip |
Add a big bundle of packages from apple source releases. Many of them only provide headers or stubs, but are what's needed for the upcoming pure-darwin stdenv, and don't do any harm for now.
Diffstat (limited to 'pkgs/os-specific/darwin/apple-source-releases/Libsystem/default.nix')
-rw-r--r-- | pkgs/os-specific/darwin/apple-source-releases/Libsystem/default.nix | 147 |
1 files changed, 147 insertions, 0 deletions
diff --git a/pkgs/os-specific/darwin/apple-source-releases/Libsystem/default.nix b/pkgs/os-specific/darwin/apple-source-releases/Libsystem/default.nix new file mode 100644 index 000000000000..ecab09413324 --- /dev/null +++ b/pkgs/os-specific/darwin/apple-source-releases/Libsystem/default.nix @@ -0,0 +1,147 @@ +{ stdenv, appleDerivation, cpio, bootstrap_cmds, xnu, Libc, Libm, libdispatch, cctools, Libinfo, + dyld, Csu, architecture, libclosure, CarbonHeaders, ncurses, CommonCrypto, copyfile, + removefile, libresolv, Libnotify, libpthread, mDNSResponder, launchd, version }: + +appleDerivation rec { + phases = [ "unpackPhase" "installPhase" ]; + + buildInputs = [ cpio libpthread ]; + + systemlibs = [ "cache" + "commonCrypto" + "compiler_rt" + "copyfile" + "corecrypto" + "dispatch" + "dyld" + "keymgr" + "kxld" + "launch" + "macho" + "quarantine" + "removefile" + "system_asl" + "system_blocks" + # "system_c" # special re-export here to hide newer functions + "system_configuration" + "system_dnssd" + "system_info" + # "system_kernel" # special re-export here to hide newer functions + "system_m" + "system_malloc" + "system_network" + "system_notify" + "system_platform" + "system_pthread" + "system_sandbox" + "system_stats" + "unc" + "unwind" + "xpc" + ]; + + installPhase = '' + export NIX_ENFORCE_PURITY= + + mkdir -p $out/lib $out/include + + # Set up our include directories + (cd ${xnu}/include && find . -name '*.h' -or -name '*.defs' | cpio -pdm $out/include) + cp ${xnu}/Library/Frameworks/Kernel.framework/Versions/A/Headers/Availability*.h $out/include + cp ${xnu}/Library/Frameworks/Kernel.framework/Versions/A/Headers/stdarg.h $out/include + + for dep in ${Libc} ${Libm} ${Libinfo} ${dyld} ${architecture} ${libclosure} ${CarbonHeaders} \ + ${libdispatch} ${ncurses} ${CommonCrypto} ${copyfile} ${removefile} ${libresolv} \ + ${Libnotify} ${mDNSResponder} ${launchd}; do + (cd $dep/include && find . -name '*.h' | cpio -pdm $out/include) + done + + (cd ${cctools}/include/mach-o && find . -name '*.h' | cpio -pdm $out/include/mach-o) + + cat <<EOF > $out/include/TargetConditionals.h + #ifndef __TARGETCONDITIONALS__ + #define __TARGETCONDITIONALS__ + #define TARGET_OS_MAC 1 + #define TARGET_OS_WIN32 0 + #define TARGET_OS_UNIX 0 + #define TARGET_OS_EMBEDDED 0 + #define TARGET_OS_IPHONE 0 + #define TARGET_IPHONE_SIMULATOR 0 + #define TARGET_OS_LINUX 0 + + #define TARGET_CPU_PPC 0 + #define TARGET_CPU_PPC64 0 + #define TARGET_CPU_68K 0 + #define TARGET_CPU_X86 0 + #define TARGET_CPU_X86_64 1 + #define TARGET_CPU_ARM 0 + #define TARGET_CPU_MIPS 0 + #define TARGET_CPU_SPARC 0 + #define TARGET_CPU_ALPHA 0 + #define TARGET_RT_MAC_CFM 0 + #define TARGET_RT_MAC_MACHO 1 + #define TARGET_RT_LITTLE_ENDIAN 1 + #define TARGET_RT_BIG_ENDIAN 0 + #define TARGET_RT_64_BIT 1 + #endif /* __TARGETCONDITIONALS__ */ + EOF + + # The startup object files + cp ${Csu}/lib/* $out/lib + + # selectively re-export functions from libsystem_c and libsystem_kernel + # to provide a consistent interface across OSX verions + mkdir -p $out/lib/system + ld -macosx_version_min 10.7 -arch x86_64 -dylib \ + -o $out/lib/system/libsystem_c.dylib \ + /usr/lib/libSystem.dylib \ + -reexported_symbols_list ${./system_c_symbols} + + ld -macosx_version_min 10.7 -arch x86_64 -dylib \ + -o $out/lib/system/libsystem_kernel.dylib \ + /usr/lib/libSystem.dylib \ + -reexported_symbols_list ${./system_kernel_symbols} + + # Set up the actual library link + clang -c -o CompatibilityHacks.o -Os CompatibilityHacks.c + clang -c -o init.o -Os init.c + ld -macosx_version_min 10.7 \ + -arch x86_64 \ + -dylib \ + -o $out/lib/libSystem.dylib \ + CompatibilityHacks.o init.o \ + -compatibility_version 1.0 \ + -current_version ${version} \ + -reexport_library $out/lib/system/libsystem_c.dylib \ + -reexport_library $out/lib/system/libsystem_kernel.dylib \ + ${stdenv.lib.concatStringsSep " " + (map (l: "-reexport_library /usr/lib/system/lib${l}.dylib") systemlibs)} + + # Set up links to pretend we work like a conventional unix (Apple's design, not mine!) + for name in c dbm dl info m mx poll proc pthread rpcsvc gcc_s.10.4 gcc_s.10.5; do + ln -s libSystem.dylib $out/lib/lib$name.dylib + done + + # This probably doesn't belong here, but we want to stay similar to glibc, which includes resolv internally... + cp ${libresolv}/lib/libresolv.9.dylib $out/lib/libresolv.9.dylib + resolv_libSystem=$(otool -L "$out/lib/libresolv.9.dylib" | tail -n +3 | grep -o "$NIX_STORE.*-\S*") || true + echo $libs + + chmod +w $out/lib/libresolv.9.dylib + install_name_tool \ + -id $out/lib/libresolv.9.dylib \ + -change "$resolv_libSystem" $out/lib/libSystem.dylib \ + -delete_rpath ${libresolv}/lib \ + $out/lib/libresolv.9.dylib + ln -s libresolv.9.dylib $out/lib/libresolv.dylib + + otool -L $out/lib/libresolv.dylib + ''; + + meta = with stdenv.lib; { + description = "The Mac OS libc/libSystem (impure symlinks to binaries with pure headers)"; + maintainers = with maintainers; [ copumpkin gridaphobe ]; + platforms = platforms.darwin; + license = licenses.apsl20; + }; +} |