diff options
Diffstat (limited to 'pkgs/os-specific/darwin')
11 files changed, 362 insertions, 9 deletions
diff --git a/pkgs/os-specific/darwin/apple-source-releases/Librpcsvc/default.nix b/pkgs/os-specific/darwin/apple-source-releases/Librpcsvc/default.nix new file mode 100644 index 000000000000..512ec6253c78 --- /dev/null +++ b/pkgs/os-specific/darwin/apple-source-releases/Librpcsvc/default.nix @@ -0,0 +1,24 @@ +{ stdenv, appleDerivation, developer_cmds }: + +appleDerivation rec { + phases = [ "unpackPhase" "installPhase" ]; + + buildInputs = [ developer_cmds ]; + + installPhase = '' + export DSTROOT=$out + export SRCROOT=$PWD + export OBJROOT=$PWD + + . ./xcodescripts/install_rpcsvc.sh + + mv $out/usr/* $out + rmdir $out/usr/ + ''; + + meta = with stdenv.lib; { + maintainers = with maintainers; [ matthewbauer ]; + platforms = platforms.darwin; + license = licenses.apsl20; + }; +} diff --git a/pkgs/os-specific/darwin/apple-source-releases/Libsystem/default.nix b/pkgs/os-specific/darwin/apple-source-releases/Libsystem/default.nix index aac213bb8047..92c54d9b679e 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/Libsystem/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/Libsystem/default.nix @@ -56,9 +56,8 @@ appleDerivation rec { # The startup object files cp ${Csu}/lib/* $out/lib - # Narrowly speaking, these would work if we re-exported libsystem_c and libsystem_kernel, - # but we also need to run the original central libsystem constructor (which initializes - # a ton of crap for its consitutent libraries) so we link against the central library here. + # We can't re-exported libsystem_c and libsystem_kernel directly, + # so we link against the central library here. mkdir -p $out/lib/system ld -macosx_version_min 10.7 -arch x86_64 -dylib \ -o $out/lib/system/libsystem_c.dylib \ @@ -70,8 +69,14 @@ appleDerivation rec { /usr/lib/libSystem.dylib \ -reexported_symbols_list ${./system_kernel_symbols} - libs=$(otool -arch x86_64 -L /usr/lib/libSystem.dylib | tail -n +3 | awk '{ print $1 }') + # The umbrella libSystem also exports some symbols, + # but we don't want to pull in everything from the other libraries. + ld -macosx_version_min 10.7 -arch x86_64 -dylib \ + -o $out/lib/libSystem_internal.dylib \ + /usr/lib/libSystem.dylib \ + -reexported_symbols_list ${./system_symbols} + libs=$(otool -arch x86_64 -L /usr/lib/libSystem.dylib | tail -n +3 | awk '{ print $1 }') for i in $libs; do if [ "$i" != "/usr/lib/system/libsystem_kernel.dylib" ] && [ "$i" != "/usr/lib/system/libsystem_c.dylib" ]; then @@ -79,14 +84,13 @@ appleDerivation rec { fi done - ld -macosx_version_min 10.7 \ - -arch x86_64 \ - -dylib \ + ld -macosx_version_min 10.7 -arch x86_64 -dylib \ -o $out/lib/libSystem.B.dylib \ -compatibility_version 1.0 \ -current_version 1226.10.1 \ -reexport_library $out/lib/system/libsystem_c.dylib \ -reexport_library $out/lib/system/libsystem_kernel.dylib \ + -reexport_library $out/lib/libSystem_internal.dylib \ $args ln -s libSystem.B.dylib $out/lib/libSystem.dylib diff --git a/pkgs/os-specific/darwin/apple-source-releases/Libsystem/system_symbols b/pkgs/os-specific/darwin/apple-source-releases/Libsystem/system_symbols new file mode 100644 index 000000000000..75a00acac493 --- /dev/null +++ b/pkgs/os-specific/darwin/apple-source-releases/Libsystem/system_symbols @@ -0,0 +1 @@ +_mach_init_routine diff --git a/pkgs/os-specific/darwin/apple-source-releases/adv_cmds/xcode.nix b/pkgs/os-specific/darwin/apple-source-releases/adv_cmds/xcode.nix new file mode 100644 index 000000000000..254b4a231c22 --- /dev/null +++ b/pkgs/os-specific/darwin/apple-source-releases/adv_cmds/xcode.nix @@ -0,0 +1,47 @@ +{ stdenv, appleDerivation, fetchurl, xcbuild, libcxx }: + +appleDerivation { + + # pkill requires special private headers that are unavailable in + # NixPkgs. These ones are needed: + # - xpc/xpxc.h + # - os/base_private.h + # - _simple.h + # We disable it here for now. TODO: build pkill inside adv_cmds + + # We also disable locale here because of some issues with a missing + # "lstdc++". + patchPhase = '' + substituteInPlace adv_cmds.xcodeproj/project.pbxproj \ + --replace "FD201DC214369B4200906237 /* pkill.c in Sources */," "" \ + --replace "FDF278D60FC6204E00D7A3C6 /* locale.cc in Sources */," "" + ''; + + # temporary install phase until xcodebuild has "install" support + installPhase = '' + mkdir -p $out/bin/ + install adv_cmds-*/Build/Products/Release/* $out/bin/ + + for n in 1 8; do + mkdir -p $out/share/man/man$n + install */*.$n $out/share/man/man$n + done + + mkdir -p $out/System/Library/LaunchDaemons + install fingerd/finger.plist $out/System/Library/LaunchDaemons + + # from variant_links.sh + # ln -s $out/bin/pkill $out/bin/pgrep + # ln -s $out/share/man/man1/pkill.1 $out/share/man/man1/pgrep.1 + ''; + + buildInputs = [ xcbuild libcxx ]; + + # temporary fix for iostream issue + NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.isDarwin "-I${libcxx}/include/c++/v1"; + + meta = { + platforms = stdenv.lib.platforms.darwin; + maintainers = with stdenv.lib.maintainers; [ matthewbauer ]; + }; +} diff --git a/pkgs/os-specific/darwin/apple-source-releases/basic_cmds/default.nix b/pkgs/os-specific/darwin/apple-source-releases/basic_cmds/default.nix new file mode 100644 index 000000000000..9e8b78e57d6c --- /dev/null +++ b/pkgs/os-specific/darwin/apple-source-releases/basic_cmds/default.nix @@ -0,0 +1,29 @@ +{ stdenv, appleDerivation, fetchurl, xcbuild }: + +appleDerivation rec { + buildInputs = [ xcbuild ]; + + # These PBXcp calls should be patched in xcbuild to allow them to + # automatically be prefixed. + patchPhase = '' + substituteInPlace basic_cmds.xcodeproj/project.pbxproj \ + --replace "dstPath = /usr/share/man/man1;" "dstPath = $out/share/man/man1;" \ + --replace "dstPath = /usr/share/man/man5;" "dstPath = $out/share/man/man5;" + ''; + + # temporary install phase until xcodebuild has "install" support + installPhase = '' + mkdir -p $out/bin/ + install basic_cmds-*/Build/Products/Release/* $out/bin/ + + for n in 1; do + mkdir -p $out/share/man/man$n + install */*.$n $out/share/man/man$n + done + ''; + + meta = { + platforms = stdenv.lib.platforms.darwin; + maintainers = with stdenv.lib.maintainers; [ matthewbauer ]; + }; +} diff --git a/pkgs/os-specific/darwin/apple-source-releases/default.nix b/pkgs/os-specific/darwin/apple-source-releases/default.nix index 8625ac72c104..c63d7465a13d 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/default.nix @@ -1,4 +1,4 @@ -{ stdenv, fetchurl, fetchzip, pkgs }: +{ stdenv, fetchurl, fetchzip, pkgs, fetchurlBoot }: let # This attrset can in theory be computed automatically, but for that to work nicely we need @@ -34,6 +34,11 @@ let libutil = "43"; libunwind = "35.3"; + Librpcsvc = "26"; + developer_cmds= "62"; + network_cmds = "481.20.1"; + basic_cmds = "55"; + adv_cmds = "163"; }; "osx-10.11.5" = { Libc = "1082.50.1"; # 10.11.6 still unreleased :/ @@ -123,7 +128,14 @@ let }; }; - fetchApple = version: sha256: name: fetchurl { + fetchApple = version: sha256: name: let + # When cross-compiling, fetchurl depends on libiconv, resulting + # in an infinite recursion without this. It's not clear why this + # worked fine when not cross-compiling + fetch = if name == "libiconv" + then fetchurlBoot + else fetchurl; + in fetch { url = "http://www.opensource.apple.com/tarballs/${name}/${name}-${versions.${version}.${name}}.tar.gz"; inherit sha256; }; @@ -214,6 +226,11 @@ let removefile = applePackage "removefile" "osx-10.11.6" "1b6r74ry3k01kypvlaclf33fha15pcm0kzx9zrymlg66wg0s0i3r" {}; Security = applePackage "Security" "osx-10.9.5" "1nv0dczf67dhk17hscx52izgdcyacgyy12ag0jh6nl5hmfzsn8yy" {}; xnu = applePackage "xnu" "osx-10.11.6" "0yhziq4dqqcbjpf6vyqn8xhwva2zb525gndkx8cp8alzwp76jnr9" {}; + Librpcsvc = applePackage "Librpcsvc" "osx-10.11.6" "1zwfwcl9irxl1dlnf2b4v30vdybp0p0r6n6g1pd14zbdci1jcg2k" {}; + adv_cmds = applePackage "adv_cmds/xcode.nix" "osx-10.11.6" "12gbv35i09aij9g90p6b3x2f3ramw43qcb2gjrg8lzkzmwvcyw9q" {}; + basic_cmds = applePackage "basic_cmds" "osx-10.11.6" "0hvab4b1v5q2x134hdkal0rmz5gsdqyki1vb0dbw4py1bqf0yaw9" {}; + developer_cmds = applePackage "developer_cmds" "osx-10.11.6" "1r9c2b6dcl22diqf90x58psvz797d3lxh4r2wppr7lldgbgn24di" {}; + network_cmds = applePackage "network_cmds" "osx-10.11.6" "0lhi9wz84qr1r2ab3fb4nvmdg9gxn817n5ldg7zw9gnf3wwn42kw" {}; libsecurity_apple_csp = libsecPackage "libsecurity_apple_csp" "osx-10.7.5" "1ngyn1ik27n4x981px3kfd1z1n8zx7r5w812b6qfjpy5nw4h746w" {}; libsecurity_apple_cspdl = libsecPackage "libsecurity_apple_cspdl" "osx-10.7.5" "1svqa5fhw7p7njzf8bzg7zgc5776aqjhdbnlhpwmr5hmz5i0x8r7" {}; diff --git a/pkgs/os-specific/darwin/apple-source-releases/developer_cmds/default.nix b/pkgs/os-specific/darwin/apple-source-releases/developer_cmds/default.nix new file mode 100644 index 000000000000..67fbf83496ed --- /dev/null +++ b/pkgs/os-specific/darwin/apple-source-releases/developer_cmds/default.nix @@ -0,0 +1,26 @@ +{ stdenv, fetchurl, appleDerivation, xcbuild }: + +appleDerivation rec { + buildInputs = [ xcbuild ]; + + patchPhase = '' + substituteInPlace rpcgen/rpc_main.c \ + --replace "/usr/bin/cpp" "${stdenv.cc}/bin/cpp" + ''; + + # temporary install phase until xcodebuild has "install" support + installPhase = '' + mkdir -p $out/bin/ + install developer_cmds-*/Build/Products/Release/* $out/bin/ + + for n in 1; do + mkdir -p $out/share/man/man$n + install */*.$n $out/share/man/man$n + done + ''; + + meta = { + platforms = stdenv.lib.platforms.darwin; + maintainers = with stdenv.lib.maintainers; [ matthewbauer ]; + }; +} diff --git a/pkgs/os-specific/darwin/apple-source-releases/network_cmds/default.nix b/pkgs/os-specific/darwin/apple-source-releases/network_cmds/default.nix new file mode 100644 index 000000000000..357a87689a03 --- /dev/null +++ b/pkgs/os-specific/darwin/apple-source-releases/network_cmds/default.nix @@ -0,0 +1,43 @@ +{ stdenv, appleDerivation, xcbuild, openssl, Librpcsvc, xnu, libpcap, developer_cmds }: + +appleDerivation rec { + buildInputs = [ xcbuild openssl xnu Librpcsvc libpcap developer_cmds ]; + + NIX_CFLAGS_COMPILE = " -I./unbound -I${xnu}/Library/Frameworks/System.framework/Headers/"; + + # "spray" requires some files that aren't compiling correctly in xcbuild. + # "rtadvd" seems to fail with some missing constants. + # We disable spray and rtadvd here for now. + patchPhase = '' + substituteInPlace network_cmds.xcodeproj/project.pbxproj \ + --replace "7294F0EA0EE8BAC80052EC88 /* PBXTargetDependency */," "" \ + --replace "7216D34D0EE89FEC00AE70E4 /* PBXTargetDependency */," "" + ''; + + # temporary install phase until xcodebuild has "install" support + installPhase = '' + mkdir -p $out/bin/ + install network_cmds-*/Build/Products/Release/* $out/bin/ + + for n in 1 5; do + mkdir -p $out/share/man/man$n + install */*.$n $out/share/man/man$n + done + + # TODO: patch files to load from $out/ instead of /usr/ + + # mkdir -p $out/etc/ + # install rtadvd.tproj/rtadvd.conf ip6addrctl.tproj/ip6addrctl.conf $out/etc/ + + # mkdir -p $out/local/OpenSourceVersions/ + # install network_cmds.plist $out/local/OpenSourceVersions/ + + # mkdir -p $out/System/Library/LaunchDaemons + # install kdumpd.tproj/com.apple.kdumpd.plist $out/System/Library/LaunchDaemons + ''; + + meta = { + platforms = stdenv.lib.platforms.darwin; + maintainers = with stdenv.lib.maintainers; [ matthewbauer ]; + }; +} diff --git a/pkgs/os-specific/darwin/cctools/ld-tbd-v2.patch b/pkgs/os-specific/darwin/cctools/ld-tbd-v2.patch new file mode 100644 index 000000000000..9aae2be1d033 --- /dev/null +++ b/pkgs/os-specific/darwin/cctools/ld-tbd-v2.patch @@ -0,0 +1,98 @@ +diff --git a/cctools/ld64/src/ld/parsers/textstub_dylib_file.cpp b/cctools/ld64/src/ld/parsers/textstub_dylib_file.cpp +index 09c0e12..ac6b085 100644 +--- a/cctools/ld64/src/ld/parsers/textstub_dylib_file.cpp ++++ b/cctools/ld64/src/ld/parsers/textstub_dylib_file.cpp +@@ -187,6 +187,7 @@ struct DynamicLibrary { + ld::File::ObjcConstraint _objcConstraint; + Options::Platform _platform; + std::vector<Token> _allowedClients; ++ std::vector<Token> _allowableClients; + std::vector<Token> _reexportedLibraries; + std::vector<Token> _symbols; + std::vector<Token> _classes; +@@ -246,6 +247,14 @@ class TBDFile { + }); + } + ++ void parseAllowableClients(DynamicLibrary& lib) { ++ if ( !hasOptionalToken("allowable-clients") ) ++ return; ++ parseFlowSequence([&](Token name) { ++ lib._allowableClients.emplace_back(name); ++ }); ++ } ++ + void parseReexportedDylibs(DynamicLibrary& lib) { + if ( !hasOptionalToken("re-exports") ) + return; +@@ -306,6 +315,21 @@ class TBDFile { + return false; + } + ++ void skipUUIDs(DynamicLibrary& lib) { ++ expectToken("uuids"); ++ while ( true ) { ++ auto token = next(); ++ if ( token == "]" ) ++ break; ++ } ++ } ++ ++ void skipParentUmbrella(DynamicLibrary& lib) { ++ if (!hasOptionalToken("parent-umbrella")) ++ return; ++ next(); ++ } ++ + void parsePlatform(DynamicLibrary& lib) { + expectToken("platform"); + +@@ -410,6 +434,7 @@ class TBDFile { + } + + parseAllowedClients(lib); ++ parseAllowableClients(lib); + parseReexportedDylibs(lib); + parseSymbols(lib); + if ( !hasOptionalToken("-") ) +@@ -455,17 +480,21 @@ class TBDFile { + return result.front(); + } + +- void parseDocument(DynamicLibrary& lib, std::string &requestedArchName) { ++ void parseDocument(DynamicLibrary& lib, std::string &requestedArchName, bool isTbdV2) { + auto selectedArchName = parseAndSelectArchitecture(requestedArchName); + if (selectedArchName.empty()) + throwf("invalid arch"); + ++ if(isTbdV2) ++ skipUUIDs(lib); + parsePlatform(lib); + parseInstallName(lib); + parseCurrentVersion(lib); + parseCompatibilityVersion(lib); + parseSwiftVersion(lib); + parseObjCConstraint(lib); ++ if(isTbdV2) ++ skipParentUmbrella(lib); + parseExportsBlock(lib, selectedArchName); + } + +@@ -476,7 +505,8 @@ public: + _tokenizer.reset(); + DynamicLibrary lib; + expectToken("---"); +- parseDocument(lib, requestedArchName); ++ auto isTbdV2 = hasOptionalToken("!tapi-tbd-v2"); ++ parseDocument(lib, requestedArchName, isTbdV2); + expectToken("..."); + return lib; + } +@@ -486,6 +516,7 @@ public: + auto token = next(); + if ( token != "---" ) + return false; ++ hasOptionalToken("!tapi-tbd-v2"); + return !parseAndSelectArchitecture(requestedArchName).empty(); + } + diff --git a/pkgs/os-specific/darwin/cctools/port.nix b/pkgs/os-specific/darwin/cctools/port.nix index 2f13277d70c7..41fb090710cb 100644 --- a/pkgs/os-specific/darwin/cctools/port.nix +++ b/pkgs/os-specific/darwin/cctools/port.nix @@ -25,6 +25,7 @@ let ] ++ stdenv.lib.optionals stdenv.isDarwin [ # See https://github.com/tpoechtrager/cctools-port/issues/24. Remove when that's fixed. ./undo-unknown-triple.patch + ./ld-tbd-v2.patch ]; enableParallelBuilding = true; diff --git a/pkgs/os-specific/darwin/ios-cross/default.nix b/pkgs/os-specific/darwin/ios-cross/default.nix new file mode 100644 index 000000000000..1d26a8b350be --- /dev/null +++ b/pkgs/os-specific/darwin/ios-cross/default.nix @@ -0,0 +1,63 @@ +{ runCommand +, lib +, llvm +, clang +, binutils +, stdenv +, coreutils +, gnugrep +}: + +/* As of this writing, known-good prefix/arch/simulator triples: + * aarch64-apple-darwin14 | arm64 | false + * arm-apple-darwin10 | armv7 | false + * i386-apple-darwin11 | i386 | true + * x86_64-apple-darwin14 | x86_64 | true + */ + +{ prefix, arch, simulator ? false }: let + sdkType = if simulator then "Simulator" else "OS"; + + sdk = "/Applications/Xcode.app/Contents/Developer/Platforms/iPhone${sdkType}.platform/Developer/SDKs/iPhone${sdkType}10.0.sdk"; + + /* TODO: Properly integrate with gcc-cross-wrapper */ + wrapper = import ../../../build-support/cc-wrapper { + inherit stdenv coreutils gnugrep; + nativeTools = false; + nativeLibc = false; + inherit binutils; + libc = runCommand "empty-libc" {} "mkdir -p $out/{lib,include}"; + cc = clang; + extraBuildCommands = '' + # ugh + tr '\n' ' ' < $out/nix-support/cc-cflags > cc-cflags.tmp + mv cc-cflags.tmp $out/nix-support/cc-cflags + echo "-target ${prefix} -arch ${arch} -idirafter ${sdk}/usr/include ${if simulator then "-mios-simulator-version-min=7.0" else "-miphoneos-version-min=7.0"}" >> $out/nix-support/cc-cflags + + # Purposefully overwrite libc-ldflags-before, cctools ld doesn't know dynamic-linker and cc-wrapper doesn't do cross-compilation well enough to adjust + echo "-arch ${arch} -L${sdk}/usr/lib ${lib.optionalString simulator "-L${sdk}/usr/lib/system "}-i${if simulator then "os_simulator" else "phoneos"}_version_min 7.0.0" > $out/nix-support/libc-ldflags-before + ''; + }; +in { + cc = runCommand "${prefix}-cc" {} '' + mkdir -p $out/bin + ln -sv ${wrapper}/bin/clang $out/bin/${prefix}-cc + mkdir -p $out/nix-support + echo ${llvm} > $out/nix-support/propagated-native-build-inputs + cat > $out/nix-support/setup-hook <<EOF + if test "\$dontSetConfigureCross" != "1"; then + configureFlags="\$configureFlags --host=${prefix}" + fi + EOF + fixupPhase + ''; + + binutils = runCommand "${prefix}-binutils" {} '' + mkdir -p $out/bin + ln -sv ${wrapper}/bin/ld $out/bin/${prefix}-ld + for prog in ar nm ranlib; do + ln -s ${binutils}/bin/$prog $out/bin/${prefix}-$prog + done + fixupPhase + ''; +} |