darwin: change the SDK pattern, update the SDKs, and update source releases (#346043)

This commit is contained in:
Emily 2024-10-11 00:58:09 +01:00 committed by GitHub
commit 66d78e097f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
257 changed files with 12211 additions and 18168 deletions

View File

@ -194,7 +194,10 @@ with lib.maintainers;
};
darwin = {
members = [ toonn ];
members = [
reckenrode
toonn
];
githubTeams = [ "darwin-maintainers" ];
scope = "Maintain Darwin compatibility of packages and Darwin-only packages.";
shortName = "Darwin";

View File

@ -79,3 +79,13 @@ if [ ! "$havePlatformVersionFlag" ]; then
extraBefore+=(-@darwinPlatform@_version_min "${@darwinMinVersionVariable@_@suffixSalt@:-@darwinMinVersion@}")
fi
fi
mangleVarSingle DEVELOPER_DIR ${role_suffixes[@]+"${role_suffixes[@]}"}
# Allow wrapped bintools to do something useful when no `DEVELOPER_DIR` is set, which can happen when
# the compiler is run outside of a stdenv or intentionally in an environment with no environment variables set.
DEVELOPER_DIR=${DEVELOPER_DIR_@suffixSalt@:-@fallback_sdk@}
# Darwin looks for frameworks in the SDK located at `DEVELOPER_DIR`.
extraBefore+=("-F$DEVELOPER_DIR/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks")
extraBefore+=("-L$DEVELOPER_DIR/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib")

View File

@ -10,6 +10,7 @@
, stdenvNoCC
, runtimeShell
, bintools ? null, libc ? null, coreutils ? null, gnugrep ? null
, apple-sdk ? null
, netbsd ? null
, sharedLibraryLoader ?
if libc == null then
@ -107,7 +108,8 @@ let
coreutils_bin = optionalString (!nativeTools) (getBin coreutils);
# See description in cc-wrapper.
suffixSalt = replaceStrings ["-" "."] ["_" "_"] targetPlatform.config;
suffixSalt = replaceStrings ["-" "."] ["_" "_"] targetPlatform.config
+ lib.optionalString (targetPlatform.isDarwin && targetPlatform.isStatic) "_static";
# The dynamic linker has different names on different platforms. This is a
# shell glob that ought to match it.
@ -412,6 +414,9 @@ stdenvNoCC.mkDerivation {
inherit dynamicLinker targetPrefix suffixSalt coreutils_bin;
inherit bintools_bin libc_bin libc_dev libc_lib;
default_hardening_flags_str = builtins.toString defaultHardeningFlags;
} // lib.optionalAttrs (apple-sdk != null && stdenvNoCC.targetPlatform.isDarwin) {
# Wrapped compilers should do something useful even when no SDK is provided at `DEVELOPER_DIR`.
fallback_sdk = apple-sdk.__spliced.buildTarget or apple-sdk;
};
meta =

View File

@ -78,12 +78,28 @@ if [ -e @out@/nix-support/cc-cflags-before ]; then
NIX_CFLAGS_COMPILE_BEFORE_@suffixSalt@="$(< @out@/nix-support/cc-cflags-before) $NIX_CFLAGS_COMPILE_BEFORE_@suffixSalt@"
fi
# Only add darwin min version flag if a default darwin min version is set,
# Only add darwin min version flag and set up `DEVELOPER_DIR` if a default darwin min version is set,
# which is a signal that we're targetting darwin.
if [ "@darwinMinVersion@" ]; then
mangleVarSingle @darwinMinVersionVariable@ ${role_suffixes[@]+"${role_suffixes[@]}"}
NIX_CFLAGS_COMPILE_BEFORE_@suffixSalt@="-m@darwinPlatformForCC@-version-min=${@darwinMinVersionVariable@_@suffixSalt@:-@darwinMinVersion@} $NIX_CFLAGS_COMPILE_BEFORE_@suffixSalt@"
# `DEVELOPER_DIR` is used to dynamically locate libSystem (and the SDK frameworks) based on the SDK at that path.
mangleVarSingle DEVELOPER_DIR ${role_suffixes[@]+"${role_suffixes[@]}"}
# Allow wrapped compilers to do something useful when no `DEVELOPER_DIR` is set, which can happen when
# the compiler is run outside of a stdenv or intentionally in an environment with no environment variables set.
DEVELOPER_DIR=${DEVELOPER_DIR_@suffixSalt@:-@fallback_sdk@}
# xcbuild needs `SDKROOT` to be the name of the SDK, which it sets in its own wrapper,
# but compilers expect it to point to the absolute path.
SDKROOT="$DEVELOPER_DIR/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
# Set up various library paths since compilers may not support (or may have disabled) finding them in the sysroot.
NIX_CFLAGS_COMPILE_BEFORE_@suffixSalt@+=" -isysroot $SDKROOT"
NIX_CFLAGS_COMPILE_@suffixSalt@+=" -idirafter $SDKROOT/usr/include"
NIX_CFLAGS_COMPILE_@suffixSalt@+=" -iframework $SDKROOT/System/Library/Frameworks"
fi
# That way forked processes will not extend these environment variables again.

View File

@ -10,6 +10,7 @@
, stdenvNoCC
, runtimeShell
, cc ? null, libc ? null, bintools, coreutils ? null
, apple-sdk ? null
, zlib ? null
, nativeTools, noLibc ? false, nativeLibc, nativePrefix ? ""
, propagateDoc ? cc != null && cc ? man
@ -114,7 +115,8 @@ let
# without interfering. For the moment, it is defined as the target triple,
# adjusted to be a valid bash identifier. This should be considered an
# unstable implementation detail, however.
suffixSalt = replaceStrings ["-" "."] ["_" "_"] targetPlatform.config;
suffixSalt = replaceStrings ["-" "."] ["_" "_"] targetPlatform.config
+ lib.optionalString (targetPlatform.isDarwin && targetPlatform.isStatic) "_static";
useGccForLibs = useCcForLibs
&& libcxx == null
@ -749,6 +751,9 @@ stdenvNoCC.mkDerivation {
inherit libc_bin libc_dev libc_lib;
inherit darwinPlatformForCC darwinMinVersion darwinMinVersionVariable;
default_hardening_flags_str = builtins.toString defaultHardeningFlags;
} // lib.optionalAttrs (apple-sdk != null && stdenvNoCC.targetPlatform.isDarwin) {
# Wrapped compilers should do something useful even when no SDK is provided at `DEVELOPER_DIR`.
fallback_sdk = apple-sdk.__spliced.buildTarget or apple-sdk;
};
meta =

View File

View File

@ -0,0 +1,51 @@
{
lib,
fetchFromGitHub,
stdenvNoCC,
}:
let
CoreSymbolication = stdenvNoCC.mkDerivation (finalAttrs: {
pname = "CoreSymbolication";
version = "0-unstable-2018-06-17";
src = fetchFromGitHub {
repo = "CoreSymbolication";
owner = "matthewbauer";
rev = "24c87c23664b3ee05dc7a5a87d647ae476a680e4";
hash = "sha256-PzvLq94eNhP0+rLwGMKcMzxuD6MlrNI7iT/eV0obtSE=";
};
patches = [
# Add missing symbol definitions needed to build `zlog` in system_cmds.
# https://github.com/matthewbauer/CoreSymbolication/pull/2
../patches/0001-Add-function-definitions-needed-to-build-zlog-in-sys.patch
../patches/0002-Add-CF_EXPORT-To-const-symbols.patch
];
dontBuild = true;
installPhase = ''
mkdir -p "$out/include"
cp *.h "$out/include"
'';
meta = {
description = "Reverse engineered headers for Apple's CoreSymbolication framework";
homepage = "https://github.com/matthewbauer/CoreSymbolication";
license = lib.licenses.mit;
maintainers = lib.teams.darwin.members;
platforms = lib.platforms.darwin;
};
});
in
self: super: {
buildPhase =
super.buildPhase or ""
+ ''
mkdir -p System/Library/PrivateFrameworks/CoreSymbolication.framework/Versions/A/Headers
ln -s A System/Library/PrivateFrameworks/CoreSymbolication.framework/Versions/Current
ln -s Versions/Current/Headers System/Library/PrivateFrameworks/CoreSymbolication.framework/Headers
cp '${CoreSymbolication}/include/'*.h System/Library/PrivateFrameworks/CoreSymbolication.framework/Versions/A/Headers
'';
}

View File

@ -0,0 +1,17 @@
{ lib, config }:
self: super: {
preBuild =
super.preBuild or ""
+ ''
platformPath=$out/Platforms/MacOSX.platform
sdkpath=$platformPath/Developer/SDKs
'';
preInstall =
super.preInstall or ""
+ ''
platformPath=$out/Platforms/MacOSX.platform
sdkpath=$platformPath/Developer/SDKs
'';
}

View File

@ -0,0 +1,42 @@
{
lib,
fetchurl,
cpio,
pbzx,
}:
{
url,
version,
hash,
}:
fetchurl {
pname = "macOS-SDK";
inherit version url hash;
recursiveHash = true;
nativeBuildInputs = [
cpio
pbzx
];
postFetch = ''
renamed=$(mktemp -d)/sdk.xar
mv "$downloadedFile" "$renamed"
pbzx "$renamed" | cpio -idm
# SDKs are inconsistent about whether MacOSX.sdk or MacOSX<version>.sdk is a symlink.
src=Library/Developer/CommandLineTools/SDKs/MacOSX${lib.versions.majorMinor version}.sdk
if [ ! -d $src ]; then
src=Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
fi
# Remove unwanted binaries, man pages, and folders from the SDK.
rm -rf $src/usr/bin $src/usr/share $src/System/Library/Perl
mkdir -p "$out"
cp -rd $src/* "$out"
'';
}

View File

@ -0,0 +1,9 @@
{ makeSetupHook, sdkVersion }:
self: super: {
passthru = super.passthru or { } // {
privateFrameworksHook = makeSetupHook {
name = "apple-sdk-private-frameworks-hook";
} ../setup-hooks/add-private-frameworks.sh;
};
}

View File

@ -0,0 +1,37 @@
let
lockfile = builtins.fromJSON (builtins.readFile ../metadata/apple-oss-lockfile.json);
in
{
lib,
fetchFromGitHub,
stdenvNoCC,
sdkVersion,
}:
let
sdkinfo = lockfile.${sdkVersion};
in
self: super: {
passthru = super.passthru or { } // {
# Returns the raw source from apple-oss-distributions repo.
# This is mostly useful for copying private headers needed to build other source releases.
#
# Note: The source releases are mostly not used to build the SDK. Unless they can be used to build binaries,
# theyre not used.
sourceRelease =
name:
let
lockinfo = sdkinfo.${name};
in
fetchFromGitHub {
owner = "apple-oss-distributions";
repo = name;
rev = lockinfo.rev or "${name}-${lockinfo.version}";
inherit (lockinfo) hash;
}
// {
inherit (lockinfo) version;
};
};
}

View File

@ -1,7 +1,10 @@
{ stdenv, runCommand, lib, sdks, xcodePlatform, writeText }:
{
lib,
stdenvNoCC,
xcodePlatform,
}:
let
inherit (lib.generators) toPlist;
Info = {
@ -10,11 +13,7 @@ let
Name = lib.toLower xcodePlatform;
};
Version = {
ProjectName = "OSXPlatformSupport";
};
# These files are all based off of Xcode spec fies found in
# These files are all based off of Xcode spec files found in
# /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Xcode/PrivatePlugIns/IDEOSXSupportCore.ideplugin/Contents/Resources.
# Based off of the "MacOSX Architectures.xcspec" file. All i386 stuff
@ -24,14 +23,20 @@ let
Identifier = "Standard";
Type = "Architecture";
Name = "Standard Architectures (Apple Silicon, 64-bit Intel)";
RealArchitectures = [ "arm64" "x86_64" ];
RealArchitectures = [
"arm64"
"x86_64"
];
ArchitectureSetting = "ARCHS_STANDARD";
}
{
Identifier = "Universal";
Type = "Architecture";
Name = "Universal (Apple Silicon, 64-bit Intel)";
RealArchitectures = [ "arm64" "x86_64" ];
RealArchitectures = [
"arm64"
"x86_64"
];
ArchitectureSetting = "ARCHS_STANDARD_32_64_BIT";
}
{
@ -44,11 +49,14 @@ let
Identifier = "Standard64bit";
Type = "Architecture";
Name = "Apple Silicon, 64-bit Intel";
RealArchitectures = [ "arm64" "x86_64" ];
RealArchitectures = [
"arm64"
"x86_64"
];
ArchitectureSetting = "ARCHS_STANDARD_64_BIT";
}
{
Identifier = if stdenv.hostPlatform.isAarch64 then "arm64" else "x86_64";
Identifier = stdenvNoCC.hostPlatform.darwinArch;
Type = "Architecture";
Name = "Apple Silicon or Intel 64-bit";
}
@ -56,7 +64,10 @@ let
Identifier = "Standard_Including_64_bit";
Type = "Architecture";
Name = "Standard Architectures (including 64-bit)";
RealArchitectures = [ "arm64" "x86_64" ];
RealArchitectures = [
"arm64"
"x86_64"
];
ArchitectureSetting = "ARCHS_STANDARD_INCLUDING_64_BIT";
}
];
@ -283,19 +294,14 @@ let
}
];
ToolchainInfo = {
Identifier = "com.apple.dt.toolchain.XcodeDefault";
};
in
runCommand "Platforms" {} ''
platform=$out/${xcodePlatform}.platform
install -D ${writeText "Info.plist" (toPlist {} Info)} $platform/Info.plist
install -D ${writeText "version.plist" (toPlist {} Version)} $platform/version.plist
install -D ${writeText "Architectures.xcspec" (toPlist {} Architectures)} $platform/Developer/Library/Xcode/Specifications/Architectures.xcspec
install -D ${writeText "PackageTypes.xcspec" (toPlist {} PackageTypes)} $platform/Developer/Library/Xcode/Specifications/PackageTypes.xcspec
install -D ${writeText "ProductTypes.xcspec" (toPlist {} ProductTypes)} $platform/Developer/Library/Xcode/Specifications/ProductTypes.xcspec
ln -s $platform $platform/usr
mkdir -p $platform/Developer
ln -s ${sdks} $platform/Developer/SDKs
''
{
"Info.plist" = builtins.toFile "Info.plist" (toPlist { } Info);
"ToolchainInfo.plist" = builtins.toFile "ToolchainInfo.plist" (toPlist { } ToolchainInfo);
"Architectures.xcspec" = builtins.toFile "Architectures.xcspec" (toPlist { } Architectures);
"PackageTypes.xcspec" = builtins.toFile "PackageTypes.xcspec" (toPlist { } PackageTypes);
"ProductTypes.xcspec" = builtins.toFile "ProductTypes.xcspec" (toPlist { } ProductTypes);
}

View File

@ -0,0 +1,46 @@
let
removedDylibs = [
# corecrypto is available under a very restrictive license (effectively: non-free, cant use).
# Without the headers and not being able to use corecrypto due to its license, its not very useful.
# Stubs are included in the SDK for all dylibs, including corecrypto. They should be removed.
"/usr/lib/system/libcorecrypto.dylib"
];
in
{
lib,
jq,
libtapi,
}:
self: super: {
nativeBuildInputs = super.nativeBuildInputs or [ ] ++ [
jq
libtapi
];
buildPhase =
super.buildPhase or ""
+ ''
echo "Removing the following dylibs from the libSystem reexported libraries list: ${lib.escapeShellArg (lib.concatStringsSep ", " removedDylibs)}"
for libSystem in libSystem.B.tbd libSystem.B_asan.tbd; do
test ! -e usr/lib/$libSystem && continue # TODO: remove once the minimum SDK is 10.14 or newer.
tapi stubify --filetype=tbd-v5 usr/lib/$libSystem -o usr/lib/$libSystem # tbd-v5 is a JSON-based format.
jq --argjson libs ${lib.escapeShellArg (builtins.toJSON removedDylibs)} '
if .libraries then
.libraries[] |= select(.install_names[] | any([.] | inside($libs)) | not)
else
.
end
| .main_library.reexported_libraries[].names[] |= select([.] | inside($libs) | not)
' usr/lib/$libSystem > usr/lib/$libSystem~
mv usr/lib/$libSystem~ usr/lib/$libSystem
done
# Rewrite the text-based stubs to v4 using `tapi`. This ensures a consistent format between SDK versions.
# tbd-v4 also drops certain elements that are no longer necessary (such as GUID lists).
find . -name '*.tbd' -type f \
-exec echo "Converting {} to tbd-v4" \; \
-exec tapi stubify --filetype=tbd-v4 {} -o {} \;
'';
}

View File

@ -0,0 +1,71 @@
{
lib,
cups,
darwin,
db,
libiconv,
ncurses,
stdenv,
stdenvNoCC,
xcbuild,
}:
let
# CUPS has too many dependencies to build as part of the Darwin bootstrap. Its also typically taken as an explicit
# dependency by other packages, so building only the headers (to satisfy other SDK headers) should be okay.
cupsHeaders = darwin.bootstrapStdenv.mkDerivation {
pname = "${lib.getName cups}-headers";
version = lib.getVersion cups;
inherit (cups) src;
patches = cups.patches or [ ];
strictDeps = true;
dontBuild = true;
buildInputs = [ darwin.libresolv ]; # The `configure` script requires libresolv headers.
# CUPSs configure script fails to find `ar` when cross-compiling.
configureFlags = [ "ac_cv_path_AR=${stdenv.cc.targetPrefix}ar" ];
installTargets = [ "install-headers" ];
__structuredAttrs = true;
meta = {
inherit (cups.meta)
homepage
description
license
maintainers
platforms
;
};
};
in
self: super: {
# These packages are propagated only because other platforms include them in their libc (or otherwise by default).
# Reducing the number of special cases required to support Darwin makes supporting it easier for package authors.
propagatedBuildInputs =
super.propagatedBuildInputs or [ ]
++ [
libiconv
darwin.libresolv
darwin.libsbuf
# Required by some SDK headers
cupsHeaders
]
# x86_64-darwin links the object files from Csu when targeting very old releases
++ lib.optionals stdenvNoCC.hostPlatform.isx86_64 [ darwin.Csu ];
# The Darwin module for Swift requires certain headers to be included in the SDK (and not just be propagated).
buildPhase =
super.buildPhase or ""
+ ''
for header in '${lib.getDev libiconv}/include/'* '${lib.getDev ncurses}/include/'*; do
ln -s "$header" "usr/include/$(basename "$header")"
done
'';
}

View File

@ -0,0 +1,50 @@
{
lib,
pkgsBuildHost,
stdenv,
stdenvNoCC,
}:
let
plists = import ./plists.nix {
inherit lib stdenvNoCC;
xcodePlatform = if stdenvNoCC.hostPlatform.isMacOS then "MacOSX" else "iPhoneOS";
};
inherit (pkgsBuildHost) darwin cctools xcbuild;
in
self: super: {
propagatedNativeBuildInputs = super.propagatedNativeBuildInputs or [ ] ++ [ xcbuild.xcrun ];
postInstall =
super.postInstall or ""
+ ''
specspath=$out/Library/Xcode/Specifications
toolchainsPath=$out/Toolchains/XcodeDefault.xctoolchain
mkdir -p "$specspath" "$toolchainsPath"
# xcbuild expects to find things relative to the plist locations. If these are linked instead of copied,
# it wont find any platforms or SDKs.
cp '${plists."Info.plist"}' "$platformPath/Info.plist"
cp '${plists."ToolchainInfo.plist"}' "$toolchainsPath/ToolchainInfo.plist"
for spec in '${xcbuild}/Library/Xcode/Specifications/'*; do
ln -s "$spec" "$specspath/$(basename "$spec")"
done
cp '${plists."Architectures.xcspec"}' "$specspath/Architectures.xcspec"
cp '${plists."PackageTypes.xcspec"}' "$specspath/PackageTypes.xcspec"
cp '${plists."ProductTypes.xcspec"}' "$specspath/ProductTypes.xcspec"
mkdir -p "$out/usr/bin"
ln -s '${xcbuild.xcrun}/bin/xcrun' "$out/usr/bin/xcrun"
# Include `libtool` in the toolchain, so `xcrun -find libtool` can find it without requiring `cctools.libtool`
# as a `nativeBuildInput`.
mkdir -p "$toolchainsPath/usr/bin"
ln -s '${cctools.libtool}/bin/${stdenv.cc.targetPrefix}libtool' "$toolchainsPath/usr/bin/libtool"
# Include additional binutils required by some packages (such as Chromium).
for tool in lipo nm otool size strip; do
ln -s '${darwin.binutils-unwrapped}/bin/${stdenv.cc.targetPrefix}'$tool "$toolchainsPath/usr/bin/$tool"
done
'';
}

View File

@ -0,0 +1,35 @@
let
# This can be made unconditional once jq is available in the bootstrap tools. If corecrypto is not removed from
# the umbrella framework, linking will fail in stage 1 because it cant find the tbd.
disallowedPackages' = builtins.fromJSON (builtins.readFile ../metadata/disallowed-packages.json);
in
{
lib,
jq,
stdenv,
}:
let
disallowedPackages =
if jq == null then
lib.filter (p: p.package != "corecrypto") disallowedPackages'
else
disallowedPackages';
in
self: super: {
# Remove headers and stubs for packages that are available in nixpkgs.
buildPhase =
super.buildPhase or ""
+ ''
${lib.concatMapStringsSep "\n" (
pkg:
lib.concatLines (
[ ''echo "Removing headers and libraries from ${pkg.package}"'' ]
++ (map (header: "rm -rf -- usr/include/${header}") pkg.headers or [ ])
++ (map (framework: "rm -rf -- System/Library/Frameworks/${framework}") pkg.frameworks or [ ])
++ (map (library: "rm -rf -- usr/lib/${library}") pkg.libraries or [ ])
)
) disallowedPackages}
'';
}

View File

@ -0,0 +1,18 @@
{ lib, sdkVersion }:
let
name = "MacOSX${lib.versions.majorMinor sdkVersion}.sdk";
in
self: super: {
# Rewrite the stubs to point to dylibs in the SDK instead of at system locations. This is needed for umbrella
# frameworks in older SDKs, which dont also embed their stubs.
buildPhase =
super.buildPhase or ""
+ ''
echo "Rewriting stubs to reference the SDK location in the store"
find . -name '*.tbd' -type f -exec sed -E \
-e "/^install-name/n; s|( \\|'\\|\"\\|\\[)/usr/|\1$sdkpath/${name}/usr/|g" \
-e "/^install-name/n; s|( \\|'\\|\"\\|\\[)/System/|\1$sdkpath/${name}/System/|g" \
-i {} \;
'';
}

View File

@ -0,0 +1,9 @@
{ }:
self: super: {
buildPhase = ''
runHook preBuild
${super.buildPhase or ""}
runHook postBuild
'';
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,545 @@
[
{
"package": "apache",
"headers": [
"apache2"
]
},
{
"package": "apr",
"headers": [
"apr-1"
],
"libraries": [
"libapr-1.*",
"libaprutil-1.*"
]
},
{
"package": "boringssl",
"libraries": [
"libboringssl.*"
]
},
{
"package": "bzip2",
"headers": [
"bzlib.h"
],
"libraries": [
"libbz2.*"
]
},
{
"package": "corecrypto",
"libraries": [
"system/libcorecrypto*"
]
},
{
"package": "Csu",
"libraries": [
"*.o"
]
},
{
"package": "cups",
"headers": [
"cups"
],
"libraries": [
"libcups*"
]
},
{
"package": "curl",
"headers": [
"curl"
],
"libraries": [
"libcurl.*"
]
},
{
"package": "cyrus_sasl",
"headers": [
"sasl"
],
"libraries": [
"libsasl*"
]
},
{
"package": "editline",
"headers": [
"editline.h",
"editline"
],
"libraries": [
"libedit.*",
"libeditline.*"
]
},
{
"package": "html-tidy",
"headers": [
"tidy*"
],
"libraries": [
"libtidy.*"
]
},
{
"package": "hunspell",
"headers": [
"hunspell"
],
"libraries": [
"libhunspell*"
]
},
{
"package": "icu",
"headers": [
"unicode"
],
"libraries": [
"libicucore.*"
]
},
{
"package": "libarchive",
"headers": [
"archive.h",
"archive_entry.h"
],
"libraries": [
"libarchive.*"
]
},
{
"package": "libc++",
"headers": [
"c++",
"cxxabi.h",
"__cxxabi_config.h"
],
"libraries": [
"libc++*"
]
},
{
"package": "ld64",
"libraries": [
"libcodedirectory.*",
"libcodedirectory_static.*"
]
},
{
"package": "expat",
"headers": [
"expat.h",
"expat_config.h",
"expat_external.h"
],
"libraries": [
"libexpat.*"
]
},
{
"package": "libffi",
"headers": [
"ffi*"
],
"libraries": [
"libffi*"
]
},
{
"package": "libgcc",
"libraries": [
"libgcc*"
]
},
{
"package": "libiconv",
"headers": [
"iconv.h",
"libcharset.h",
"localcharset.h"
],
"libraries": [
"libcharset.*",
"libiconv.*",
"i18n"
]
},
{
"package": "libiodbc",
"libraries": [
"libiodbc*"
]
},
{
"package": "libkrb4",
"libraries": [
"libkrb4.*"
]
},
{
"package": "libkrb5",
"headers": [
"com_err.h",
"gssapi",
"gssapi.h",
"gssrpc",
"kadm5",
"kdb.h",
"krad.h",
"krb5",
"krb5.h",
"profile.h",
"verto-module.h",
"verto.h"
],
"libraries": [
"krb5",
"libcom_err.*",
"libgssapi_krb5.*",
"libgssrpc.*",
"libk5crypto.*",
"libkadm5clnt.*",
"libkadm5clnt_mit.*",
"libkadm5srv.*",
"libkadm5srv_mit.*",
"libkdb5.*",
"libkrad.*",
"libkrb5*",
"libkrb5support.*",
"libverto.*"
]
},
{
"package": "libpcap",
"headers": [
"pcap*"
],
"libraries": [
"libpcap.*"
]
},
{
"package": "libresolv",
"headers": [
"arpa/nameser.h",
"arpa/nameser_compat.h",
"dns.h",
"dns_util.h",
"nameser.h",
"resolv.h"
],
"libraries": [
"libresolv.*"
]
},
{
"package": "libstdc++",
"libraries": [
"libstdc++.*"
]
},
{
"package": "libsbuf",
"headers": [
"usbuf.h"
],
"libraries": [
"libsbuf.*"
]
},
{
"package": "libtermcap",
"headers": [
"termcap.h"
],
"libraries": [
"libtermcap.*"
]
},
{
"package": "libutil",
"headers": [
"libutil.h"
],
"libraries": [
"libutil.*",
"libutil1.*"
]
},
{
"package": "libxml2",
"headers": [
"libxml",
"libxml2"
],
"libraries": [
"libxml2.*"
]
},
{
"package": "libxo",
"headers": [
"libxo"
],
"libraries": [
"libxo.*"
]
},
{
"package": "libxslt",
"headers": [
"libexslt",
"libxslt"
],
"libraries": [
"libexslt.*",
"libxslt.*"
]
},
{
"package": "liby",
"libraries": [
"liby.a"
]
},
{
"package": "marisa-trie",
"libraries": [
"libmarisa.*"
]
},
{
"package": "ncurses",
"headers": [
"curses*",
"cursslk.h",
"eti.h",
"etip.h",
"form.h",
"menu.h",
"nc_tparm.h",
"ncurses*",
"panel.h",
"term.h",
"term_entry.h",
"termcap.h",
"tic.h",
"unctrl.h"
],
"libraries": [
"libcurses.*",
"libform.*",
"libformw.*",
"libmenu.*",
"libmenuw.*",
"libncurses.*",
"libncursesw.*",
"libpanel.*",
"libpanelw.*",
"libtinfo.*"
]
},
{
"package": "net-snmp",
"headers": [
"net-snmp"
],
"libraries": [
"libnetsnmp*"
]
},
{
"package": "nghttp",
"libraries": [
"lib*nghttp2.*"
]
},
{
"package": "openblas",
"headers": [
"cblas.h",
"f77blas.h",
"lapack.h",
"lapacke.h",
"lapacke_config.h",
"lapacke_mangling.h",
"lapacke_utils.h",
"openblas_config.h"
],
"libraries": [
"libblas.*",
"libcblas.*",
"libclapack.*",
"libf77lapack.*",
"liblapack.*",
"liblapacke.*",
"libopenblas.*",
"libopenblas.*",
"libopenblasp*"
]
},
{
"package": "openldap",
"headers": [
"lber.h",
"lber_types.h",
"ldap.h",
"ldap_cdefs.h",
"ldap_features.h",
"ldap_schema.h",
"ldap_utf8.h",
"ldif.h",
"openldap.h",
"slapi-plugin.h"
],
"libraries": [
"liblber.*",
"liblber_r.*",
"libldap.*",
"libldap_r.*"
]
},
{
"package": "openpam",
"headers": [
"security"
],
"libraries": [
"libpam.*",
"pam_*"
]
},
{
"package": "pcre",
"headers": [
"pcre.h",
"pcreposix.h"
],
"libraries": [
"libpcre.*",
"libpcre2*",
"libpcreposix.*"
]
},
{
"package": "php",
"headers": [
"php"
],
"libraries": [
"php"
]
},
{
"package": "postgresql",
"libraries": [
"libecpg*",
"libpg*",
"libpq*"
]
},
{
"package": "python",
"headers": [
"python*"
],
"frameworks": [
"Python.framework"
],
"libraries": [
"libpython*",
"python*"
]
},
{
"package": "readline",
"headers": [
"readline"
],
"libraries": [
"libhistory.*",
"libreadline.*"
]
},
{
"package": "ruby",
"frameworks": [
"Ruby.framework"
],
"libraries": [
"libruby.*",
"ruby"
]
},
{
"package": "sqlite3",
"headers": [
"sqlite3.h",
"sqlite3ext.h"
],
"libraries": [
"libsqlite3.*"
]
},
{
"package": "swift",
"libraries": [
"swift/shims"
]
},
{
"package": "tcl",
"headers": [
"tcl*",
"tk*"
],
"frameworks": [
"Tcl.framework",
"Tk.framework"
],
"libraries": [
"libtcl*",
"libtk*",
"tclConfig.sh",
"tkConfig.sh"
]
},
{
"package": "xar",
"headers": [
"xar"
],
"libraries": [
"libxar.*"
]
},
{
"package": "xz",
"headers": [
"lzma*"
],
"libraries": [
"liblzma.*"
]
},
{
"package": "zlib",
"headers": [
"zconf.h",
"zlib.h"
],
"libraries": [
"libz.*"
]
}
]

View File

@ -0,0 +1,42 @@
{
"10.12": {
"url": "http://swcdn.apple.com/content/downloads/22/62/041-88607/wg8avdk0jo75k9a13gentz9stwqgrqmcv6/CLTools_SDK_OSX1012.pkg",
"version": "10.12.2",
"hash": "sha256-Jf2WIB9bY/rPwe0AOW3YWJY/6EqVe41yhezdTGOO3M8="
},
"10.13": {
"url": "http://swcdn.apple.com/content/downloads/33/36/041-90419-A_7JJ4H9ZHO2/xs88ob5wjz6riz7g6764twblnvksusg4ps/CLTools_SDK_macOS1013.pkg",
"version": "10.13.2",
"hash": "sha256-8nd55fiJLfRWABAbMaHXjp6i20RqupmKedwmhb3S0/A="
},
"10.14": {
"url": "http://swcdn.apple.com/content/downloads/41/57/061-26573-A_JMOA8GZGDR/lj8yrtu8dgs40fw9k8f5fkoviwkp0og6vs/CLTools_SDK_macOS1014.pkg",
"version": "10.14.6",
"hash": "sha256-NMNkycIl3AVZCw0ZpHNkaeYVS9LAZVSddHw5loL9dhk="
},
"10.15": {
"url": "https://swcdn.apple.com/content/downloads/50/51/071-29699-A_YC8SX0OHH3/7479xojqghsvgtnt3dxjpnxuz9sjpmbmds/CLTools_macOSLMOS_SDK.pkg",
"version": "10.15.6",
"hash": "sha256-mPJQC+v4yNiOCKLQfhidB2WH2MMclSCP1odvOoGdVPw="
},
"11": {
"url": "https://swcdn.apple.com/content/downloads/02/62/071-54303-A_EU2CL1YVT7/943i95dpeyi2ghlnj2mgyq3t202t5gf18b/CLTools_macOSNMOS_SDK.pkg",
"version": "11.3",
"hash": "sha256-/go8utcx3jprf6c8V/DUbXwsmNYSFchOAai1OaJs3Bg="
},
"12": {
"url": "https://swcdn.apple.com/content/downloads/24/42/002-83793-A_74JRE8GVAT/rlnkct919wgc5c0pjq986z5bb9h62uvni2/CLTools_macOSNMOS_SDK.pkg",
"version": "12.3",
"hash": "sha256-qG21ssNUmkqxPLTXALGP2N/RBHu8NMlI1dWvGlV+Wm8="
},
"13": {
"url": "https://swcdn.apple.com/content/downloads/15/62/032-84673-A_7A1TG1RF8Z/xpc8q44ggn2pkn82iwr0fi1zeb9cxi8ath/CLTools_macOSNMOS_SDK.pkg",
"version": "13.3",
"hash": "sha256-zZ4pbgoXunLGwdYDemxOfyH4CE5WGfMy2s5jN+0q4B4="
},
"14": {
"url": "https://swcdn.apple.com/content/downloads/14/48/052-59890-A_I0F5YGAY0Y/p9n40hio7892gou31o1v031ng6fnm9sb3c/CLTools_macOSNMOS_SDK.pkg",
"version": "14.4",
"hash": "sha256-QozDiwY0Czc0g45vPD7G4v4Ra+3DujCJbSads3fJjjM="
}
}

View File

@ -0,0 +1,120 @@
let
sdkVersions = builtins.fromJSON (builtins.readFile ./metadata/versions.json);
in
{
lib,
stdenv,
stdenvNoCC,
substitute,
# Specifies the major version used for the SDK. Uses `hostPlatform.darwinSdkVersion` by default.
darwinSdkMajorVersion ? (
if lib.versionOlder stdenv.hostPlatform.darwinSdkVersion "11" then
lib.versions.majorMinor stdenv.hostPlatform.darwinSdkVersion
else
lib.versions.major stdenv.hostPlatform.darwinSdkVersion
),
# Enabling bootstrap disables propagation. Defaults to `false` (meaning to propagate certain packages and `xcrun`)
# except in stage0 of the Darwin stdenv bootstrap.
enableBootstrap ? stdenv.name == "bootstrap-stage0-stdenv-darwin",
# Required by various phases
callPackage,
jq,
}:
let
sdkInfo =
sdkVersions.${darwinSdkMajorVersion}
or (lib.throw "Unsupported SDK major version: ${darwinSdkMajorVersion}");
sdkVersion = sdkInfo.version;
fetchSDK = callPackage ./common/fetch-sdk.nix { };
phases = lib.composeManyExtensions (
[
(callPackage ./common/add-core-symbolication.nix { })
(callPackage ./common/derivation-options.nix { })
(callPackage ./common/passthru-private-frameworks.nix { inherit sdkVersion; })
(callPackage ./common/passthru-source-release-files.nix { inherit sdkVersion; })
(callPackage ./common/remove-disallowed-packages.nix { })
]
# Only process stubs and convert them to tbd-v4 if jq is available. This can be made unconditional once
# the bootstrap tools have jq and libtapi.
++ lib.optional (jq != null) (callPackage ./common/process-stubs.nix { })
# Avoid infinite recursions by not propagating certain packages, so they can themselves build with the SDK.
++ lib.optionals (!enableBootstrap) [
(callPackage ./common/propagate-inputs.nix { })
(callPackage ./common/propagate-xcrun.nix { })
]
++ [
# These have to happen last.
(callPackage ./common/rewrite-sdk-paths.nix { inherit sdkVersion; })
(callPackage ./common/run-build-phase-hooks.nix { })
]
);
in
stdenvNoCC.mkDerivation (
lib.extends phases (finalAttrs: {
pname = "apple-sdk";
inherit (sdkInfo) version;
src = fetchSDK sdkInfo;
dontConfigure = true;
strictDeps = true;
setupHooks = [
# `role.bash` is copied from `../build-support/setup-hooks/role.bash` due to the requirements not to reference
# paths outside the package when it is in `by-name`. It needs to be kept in sync, but it fortunately does not
# change often. Once `build-support` is available as a package (or some other mechanism), it should be changed
# to whatever that replacement is.
./setup-hooks/role.bash
(substitute {
src = ./setup-hooks/sdk-hook.sh;
substitutions = [
"--subst-var-by"
"sdkVersion"
(lib.escapeShellArgs (lib.splitVersion sdkVersion))
];
})
];
installPhase =
let
sdkName = "MacOSX${lib.versions.majorMinor sdkVersion}.sdk";
sdkMajor = lib.versions.major sdkVersion;
in
''
runHook preInstall
mkdir -p "$sdkpath"
cp -rd . "$sdkpath/${sdkName}"
${lib.optionalString (lib.versionAtLeast finalAttrs.version "11.0") ''
ln -s "${sdkName}" "$sdkpath/MacOSX${sdkMajor}.sdk"
''}
ln -s "${sdkName}" "$sdkpath/MacOSX.sdk"
runHook postInstall
'';
passthru = {
sdkroot = finalAttrs.finalPackage + "/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk";
};
__structuredAttrs = true;
meta = {
description = "Frameworks and libraries required for building packages on Darwin";
homepage = "https://developer.apple.com";
maintainers = lib.teams.darwin.members;
platforms = lib.platforms.darwin;
badPlatforms =
lib.optionals (lib.versionAtLeast sdkVersion "10.15") [ lib.systems.inspect.patterns.is32bit ]
++ lib.optionals (lib.versionOlder sdkVersion "11.0") [ lib.systems.inspect.patterns.isAarch ];
};
})
)

View File

@ -0,0 +1,48 @@
From 6531da946949a94643e6d8424236174ae64fe0ca Mon Sep 17 00:00:00 2001
From: Randy Eckenrode <randy@largeandhighquality.com>
Date: Sat, 30 Sep 2023 18:02:39 -0400
Subject: [PATCH 1/2] Add function definitions needed to build zlog in
system_cmds
---
CoreSymbolication.h | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/CoreSymbolication.h b/CoreSymbolication.h
index a413860..f3cf63f 100644
--- a/CoreSymbolication.h
+++ b/CoreSymbolication.h
@@ -324,7 +324,9 @@ CSSymbolOwnerEditRelocations
CSSymbolOwnerForeachRegion
CSSymbolOwnerForeachRegionWithName
CSSymbolOwnerForeachSection
-CSSymbolOwnerForeachSegment
+*/
+void CSSymbolOwnerForeachSegment(CSSymbolOwnerRef owner, void (^block)(CSSegmentRef));
+/*
CSSymbolOwnerForeachSourceInfo
CSSymbolOwnerForeachSymbol
*/
@@ -333,7 +335,9 @@ void CSSymbolOwnerForeachSymbolWithName(CSSymbolOwnerRef owner, const char *sna
/*
CSSymbolOwnerGetArchitecture
CSSymbolOwnerGetBaseAddress
-CSSymbolOwnerGetCFUUIDBytes
+*/
+const CFUUIDBytes* CSSymbolOwnerGetCFUUIDBytes(CSSymbolOwnerRef owner);
+/*
CSSymbolOwnerGetCompatibilityVersion
CSSymbolOwnerGetCurrentVersion
CSSymbolOwnerGetDataFlags
@@ -390,7 +394,7 @@ CSSymbolOwnerSetLoadTimestamp
CSSymbolOwnerSetPath
CSSymbolOwnerSetRelocationCount
*/
-CSSymbolOwnerSetTransientUserData(CSSymbolOwnerRef owner, uint32_t gen);
+void CSSymbolOwnerSetTransientUserData(CSSymbolOwnerRef owner, uint32_t gen);
/*
CSSymbolOwnerSetUnloadTimestamp
*/
--
2.44.1

View File

@ -0,0 +1,45 @@
From ae7ac6a7043dbae8e63d6ce5e63dfaf02b5977fe Mon Sep 17 00:00:00 2001
From: Randy Eckenrode <randy@largeandhighquality.com>
Date: Sat, 30 Sep 2023 18:37:18 -0400
Subject: [PATCH 2/2] Add CF_EXPORT To const symbols
---
CoreSymbolication.h | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/CoreSymbolication.h b/CoreSymbolication.h
index f3cf63f..4124a54 100644
--- a/CoreSymbolication.h
+++ b/CoreSymbolication.h
@@ -49,6 +49,7 @@
#include <CoreFoundation/CoreFoundation.h>
+#include <CoreFoundation/CFBase.h>
#include <mach/mach.h>
@@ -139,13 +140,13 @@ typedef void (^CSSegmentIterator)(CSSegmentRef segment);
* External symbols
*/
-const char* kCSRegionMachHeaderName;
-const CSDictionaryKeyCallBacks kCSTypeDictionaryKeyCallBacks;
-const CSDictionaryValueCallBacks kCSTypeDictionaryValueCallBacks;
-const CSDictionaryKeyCallBacks kCSTypeDictionaryWeakKeyCallBacks;
-const CSDictionaryValueCallBacks kCSTypeDictionaryWeakValueCallBacks;
-const CSSetCallBacks kCSTypeSetCallBacks;
-const CSSetCallBacks kCSTypeSetWeakCallBacks;
+CF_EXPORT const char* kCSRegionMachHeaderName;
+CF_EXPORT const CSDictionaryKeyCallBacks kCSTypeDictionaryKeyCallBacks;
+CF_EXPORT const CSDictionaryValueCallBacks kCSTypeDictionaryValueCallBacks;
+CF_EXPORT const CSDictionaryKeyCallBacks kCSTypeDictionaryWeakKeyCallBacks;
+CF_EXPORT const CSDictionaryValueCallBacks kCSTypeDictionaryWeakValueCallBacks;
+CF_EXPORT const CSSetCallBacks kCSTypeSetCallBacks;
+CF_EXPORT const CSSetCallBacks kCSTypeSetWeakCallBacks;
/*
--
2.44.1

View File

@ -0,0 +1,41 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p coreutils curl file gzip jq xcbuild yq
set -eu -o pipefail
catalog=${1-}
if [ -z "$catalog" ]; then
echo "usage: get-sdks-from-catalog.sh <catalog>"
echo " <catalog> Apple software update catalog (may be gzipped)" >&2
exit 1
fi
scratch=$(mktemp)
trap 'rm -f -- "$scratch"' EXIT
if [[ "$(file "$catalog")" =~ gzip ]]; then
gzcat "$catalog" > "$scratch"
else
cp --reflink=auto "$catalog" "$scratch"
fi
# Grab all SDK packages from the catalog
filter='.Products[].Packages[] | select(.URL | test(".*CLTools_macOSNMOS_SDK.pkg")) | "\(.URL)|\(.MetadataURL)"'
declare -A package_list
for package in $(plutil -convert json -o - "$scratch" | jq -r "$filter"); do
package_list[${package%%|*}]=${package#*|}
done
truncate --size 0 "$scratch"
for pkg in "${!package_list[@]}"; do
ver=$(curl --silent "${package_list[$pkg]}" | xq -r '."pkg-info"."@version"')
echo "{\"url\": \"$pkg\", \"version\": \"$(cut -d. -f1-3 <<< "$ver")\", \"long_version\": \"$ver\"}" >> "$scratch"
done
jq -r --slurp '
group_by(.version | split(".")[0])
| map(max_by(.version))
| sort_by(.version)[]
| "Package URL: \(.url)\n Xcode Ver: \(.version) (\(.long_version))\n"' "$scratch"

View File

@ -0,0 +1,69 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p coreutils curl git gnutar jq moreutils nix
set -eu -o pipefail
if [ ! -v 2 ]; then
echo "usage: lock-sdk-deps.sh <SDK version> <Packages>" >&2
echo " <SDK version> Decimal-separated version number." >&2
echo " Must correspond to a tag in https://github.com/apple-oss-distributions/distribution-macOS" >&2
echo " <Packages> List of packages from the distributions-macOS repository." >&2
echo " Packages not in the repository at the tag for <SDK version> will be ignored."
exit 1
fi
pkgdir=$(dirname "$(dirname "$(realpath "$0")")")
lockfile=$pkgdir/metadata/apple-oss-lockfile.json
if [ ! -e "$lockfile" ]; then
touch "$lockfile"
fi
workdir=$(mktemp -d)
trap 'rm -rf -- "$workdir"' EXIT
sdkVersion=$1; shift
tag="macos-${sdkVersion//.}"
declare -a packages=("$@")
echo "Locking versions for macOS $sdkVersion using tag '$tag'..."
pushd "$workdir" > /dev/null
git clone --branch "$tag" https://github.com/apple-oss-distributions/distribution-macOS.git &> /dev/null
cd distribution-macOS
for package in "${packages[@]}"; do
# If the tag exists in `release.json`, use that as an optimization to avoid downloading unnecessarily from Github.
packageTag=$(jq -r --arg package "$package" '.projects[] | select(.project == $package) | .tag' release.json)
packageCommit=$(git ls-tree -d HEAD "$package" | awk '{print $3}')
if [ ! -d "$package" ]; then
packageCommit=HEAD
fi
# However, sometimes it doesnt exist. In that case, fall back to cloning the repo and check manually
# which tag corresponds to the commit from the submodule.
if [ -z "$packageTag" ]; then
git clone --no-checkout "https://github.com/apple-oss-distributions/$package.git" ../source &> /dev/null
pushd ../source > /dev/null
packageTag=$(git tag --points-at "$packageCommit")
popd > /dev/null
rm -rf ../source
fi
packageVersion=${packageTag##"$package"-}
curl -OL "https://github.com/apple-oss-distributions/$package/archive/$packageTag.tar.gz" &> /dev/null
tar axf "$packageTag.tar.gz"
packageHash=$(nix --extra-experimental-features nix-command hash path "$package-$packageTag")
pkgsjson="{\"$package\": {\"version\": \"$packageVersion\", \"hash\": \"$packageHash\"}}"
echo " - Locking $package to version $packageVersion with hash '$packageHash'"
jq --argjson pkg "$pkgsjson" -S '. * $pkg' "$lockfile" | sponge "$lockfile"
done
popd > /dev/null

View File

@ -0,0 +1,62 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p coreutils jq
set -eu -o pipefail
pkgdir=$(dirname "$(dirname "$(realpath "$0")")")
echo '{}' > "$pkgdir/metadata/apple-oss-lockfile.json"
declare -a versions
readarray -t versions < <(jq -r '.[].version' "$pkgdir/metadata/versions.json")
declare -a packages=(
CarbonHeaders
CommonCrypto
IOAudioFamily
IOFireWireFamily
IOFWDVComponents
IOFireWireAVC
IOFireWireSBP2
IOFireWireSerialBusProtocolTransport
IOGraphics
IOHIDFamily
IONetworkingFamily
IOSerialFamily
IOStorageFamily
IOBDStorageFamily
IOCDStorageFamily
IODVDStorageFamily
IOUSBFamily
IOKitUser
Libc
Libinfo
Libm
Libnotify
Librpcsvc
Libsystem
OpenDirectory
Security
architecture
configd
copyfile
dtrace
dyld
eap8021x
hfs
launchd
libclosure
libdispatch
libmalloc
libplatform
libpthread
mDNSResponder
objc4
ppp
removefile
xnu
)
for version in "${versions[@]}"; do
"$pkgdir/scripts/lock-sdk-deps.sh" "$version" "${packages[@]}"
done

View File

@ -0,0 +1,6 @@
function enablePrivateFrameworks() {
export NIX_CFLAGS_COMPILE+=" -iframework $DEVELOPER_DIR/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/PrivateFrameworks"
export NIX_LDFLAGS+=" -F$DEVELOPER_DIR/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/PrivateFrameworks"
}
preConfigureHooks+=(enablePrivateFrameworks)

View File

@ -0,0 +1,71 @@
# Since the same derivation can be depended on in multiple ways, we need to
# accumulate *each* role (i.e. host and target platforms relative the depending
# derivation) in which the derivation is used.
#
# The role is intended to be used as part of other variables names like
# - $NIX_SOMETHING${role_post}
function getRole() {
case $1 in
-1)
role_post='_FOR_BUILD'
;;
0)
role_post=''
;;
1)
role_post='_FOR_TARGET'
;;
*)
echo "@name@: used as improper sort of dependency" >&2
return 1
;;
esac
}
# `hostOffset` describes how the host platform of the package is slid relative
# to the depending package. `targetOffset` likewise describes the target
# platform of the package. Both are brought into scope of the setup hook defined
# for dependency whose setup hook is being processed relative to the package
# being built.
function getHostRole() {
getRole "$hostOffset"
}
function getTargetRole() {
getRole "$targetOffset"
}
# `depHostOffset` describes how the host platform of the dependencies are slid
# relative to the depending package. `depTargetOffset` likewise describes the
# target platform of dependenices. Both are brought into scope of the
# environment hook defined for the dependency being applied relative to the
# package being built.
function getHostRoleEnvHook() {
getRole "$depHostOffset"
}
function getTargetRoleEnvHook() {
getRole "$depTargetOffset"
}
# This variant is intended specifically for code-producing tool wrapper scripts
# `NIX_@wrapperName@_TARGET_*_@suffixSalt@` tracks this (needs to be an exported
# env var so can't use fancier data structures).
function getTargetRoleWrapper() {
case $targetOffset in
-1)
export NIX_@wrapperName@_TARGET_BUILD_@suffixSalt@=1
;;
0)
export NIX_@wrapperName@_TARGET_HOST_@suffixSalt@=1
;;
1)
export NIX_@wrapperName@_TARGET_TARGET_@suffixSalt@=1
;;
*)
echo "@name@: used as improper sort of dependency" >&2
return 1
;;
esac
}

View File

@ -0,0 +1,17 @@
local role_post
getHostRole
local sdkVersionVar=NIX_APPLE_SDK_VERSION${role_post}
local developerDirVar=DEVELOPER_DIR${role_post}
local sdkVersionArr=(@sdkVersion@)
local sdkVersion
sdkVersion=$(printf "%02d%02d%02d" "${sdkVersionArr[0]-0}" "${sdkVersionArr[1]-0}" "${sdkVersionArr[2]-0}")
if [ "$sdkVersion" -gt "${!sdkVersionVar-000000}" ]; then
export "$developerDirVar"='@out@'
export "$sdkVersionVar"="$sdkVersion"
export "SDKROOT${role_post}"="${!developerDirVar}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
fi
unset -v role_post developerDirVar sdkVersion sdkVersionArr sdkVersionVar

View File

@ -3,7 +3,6 @@
stdenv,
fetchFromGitHub,
buildPackages,
darwin,
ld64,
llvm,
memstreamHook,
@ -38,6 +37,7 @@ stdenv.mkDerivation (finalAttrs: {
"dev"
"man"
"gas"
"libtool"
];
src = fetchFromGitHub {
@ -127,13 +127,10 @@ stdenv.mkDerivation (finalAttrs: {
openssl
];
buildInputs =
[
ld64
llvm
]
++ lib.optionals stdenv.hostPlatform.isDarwin [ darwin.objc4 ]
++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) [ memstreamHook ];
buildInputs = [
ld64
llvm
] ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) [ memstreamHook ];
mesonBuildType = "release";
@ -153,6 +150,10 @@ stdenv.mkDerivation (finalAttrs: {
for arch in arm i386 x86_64; do
mv "$gas/libexec/as/$arch/as-$arch" "$gas/libexec/as/$arch/as"
done
# Move libtool to its own output to allow packages to add it without pulling in all of cctools
moveToOutput bin/${targetPrefix}libtool "$libtool"
ln -s "$libtool/bin/${targetPrefix}libtool" "$out/bin/${targetPrefix}libtool"
'';
__structuredAttrs = true;

View File

@ -181,6 +181,14 @@ stdenv.mkDerivation (finalAttrs: {
sed -i 's|bin/cmake|${buildPackages.cmakeMinimal}/bin/cmake|g' Makefile
'';
# Undo some of `fixCmakeFiles` for Darwin to make sure that checks for libraries in the SDK find them
# (e.g., `find_library(MATH_LIBRARY m)` should find `$SDKROOT/usr/lib/libm.tbd`).
postFixup = lib.optionalString stdenv.hostPlatform.isDarwin ''
substituteInPlace "$out/share/cmake-${lib.versions.majorMinor finalAttrs.version}/Modules/Platform/Darwin.cmake" \
--replace-fail '/var/empty/include' '/usr/include' \
--replace-fail '/var/empty/lib' '/usr/lib'
'';
dontUseCmakeConfigure = true;
enableParallelBuilding = true;

View File

@ -57,9 +57,6 @@ cmakeConfigurePhase() {
# because we usually do not package the framework
prependToVar cmakeFlags "-DCMAKE_FIND_FRAMEWORK=LAST"
# we never want to use the global macOS SDK
prependToVar cmakeFlags "-DCMAKE_OSX_SYSROOT="
# correctly detect our clang compiler
prependToVar cmakeFlags "-DCMAKE_POLICY_DEFAULT_CMP0025=NEW"

View File

@ -90,7 +90,6 @@ configure_h = custom_target(
incdirs = include_directories(
'compat',
'include',
'src/abstraction',
'src/ld',
'src/ld/code-sign-blobs',

View File

@ -1,11 +1,13 @@
{
lib,
stdenv,
stdenvNoCC,
fetchFromGitHub,
fetchurl,
apple-sdk,
cctools,
darwin,
libtapi,
libunwind,
llvm,
meson,
ninja,
@ -30,16 +32,53 @@ let
hash = "sha256-0ybVcwHuGEdThv0PPjYQc3SW0YVOyrM3/L9zG/l1Vtk=";
};
dyld = fetchFromGitHub {
owner = "apple-oss-distributions";
repo = "dyld";
rev = "dyld-1162";
hash = "sha256-uyFg8QnnP6NWv5lAOTCiFZ0SnFOA/aO/kpjkyvILVsk=";
};
libdispatchPrivate = apple-sdk.sourceRelease "libdispatch";
# First version with all the required definitions. This is used in preference to darwin.xnu to make it easier
# to support Linux and because the version of darwin.xnu available on x86_64-darwin in the 10.12 SDK is too old.
xnu = fetchFromGitHub {
name = "xnu-src";
owner = "apple-oss-distributions";
repo = "xnu";
rev = "xnu-6153.11.26";
hash = "sha256-dcnGcp7bIjQxeAn5pXt+mHSYEXb2Ad9Smhd/WUG4kb4=";
};
privateHeaders = stdenvNoCC.mkDerivation {
name = "ld64-deps-private-headers";
buildCommand = ''
mkdir -p "$out/include/System"
for dir in arm i386 machine; do
cp -r '${xnu}/osfmk/'$dir "$out/include/System/$dir"
done
substitute '${crashreporter_h}' "$out/include/CrashReporterClient.h" \
--replace-fail 'USE(APPLE_INTERNAL_SDK)' '0'
cp -r '${libdispatchPrivate}/private' "$out/include/dispatch"
install -D -t "$out/include/mach-o" \
'${dyld}/include/mach-o/dyld_priv.h' \
'${cctools.src}/include/mach-o/loader.h'
install -D -t "$out/include/mach-o/arm" \
'${cctools.src}/include/mach-o/arm/reloc.h'
install -D -t "$out/include/sys" \
'${xnu}/bsd/sys/commpage.h'
substituteInPlace "$out/include/mach-o/dyld_priv.h" \
--replace-fail ', bridgeos(3.0)' ""
'';
};
# Avoid pulling in all of Swift just to build libdispatch
libdispatch = swiftPackages.Dispatch.override { useSwift = false; };
in
@ -63,8 +102,6 @@ stdenv.mkDerivation (finalAttrs: {
xcodeHash = "sha256-+j7Ed/6aD46SJnr3DWPfWuYWylb2FNJRPmWsUVxZJHM=";
postUnpack = ''
unpackFile '${xnu}'
# Verify that the Xcode project has not changed unexpectedly.
hashType=$(echo $xcodeHash | cut -d- -f1)
expectedHash=$(echo $xcodeHash | cut -d- -f2)
@ -100,19 +137,6 @@ stdenv.mkDerivation (finalAttrs: {
--subst-var version
cp ${./meson.options} meson.options
# Copy headers for certain private APIs
mkdir -p include
substitute ${crashreporter_h} include/CrashReporterClient.h \
--replace-fail 'USE(APPLE_INTERNAL_SDK)' '0'
# Copy from the source so the headers can be used on Linux and x86_64-darwin
mkdir -p include/System
for dir in arm i386 machine; do
cp -r ../xnu-src/osfmk/$dir include/System/$dir
done
mkdir -p include/sys
cp ../xnu-src/bsd/sys/commpage.h include/sys
# Match the version format used by upstream.
sed -i src/ld/Options.cpp \
-e '1iconst char ld_classicVersionString[] = "@(#)PROGRAM:ld PROJECT:ld64-${finalAttrs.version}\\n";'
@ -134,6 +158,8 @@ stdenv.mkDerivation (finalAttrs: {
strictDeps = true;
env.NIX_CFLAGS_COMPILE = "-DTARGET_OS_BRIDGE=0 -I${privateHeaders}/include";
nativeBuildInputs = [
meson
ninja
@ -146,7 +172,6 @@ stdenv.mkDerivation (finalAttrs: {
[
libtapi
llvm
libunwind
openssl
xar
]
@ -173,6 +198,7 @@ stdenv.mkDerivation (finalAttrs: {
cd "$NIX_BUILD_TOP/$sourceRoot"
export NIX_CFLAGS_COMPILE+=" --ld-path=$out/bin/${targetPrefix}ld"
export NIX_CFLAGS_LINK+=" -L$SDKROOT/usr/lib"
meson setup build-install-check -Db_lto=true --buildtype=$mesonBuildType${
lib.optionalString (targetPrefix != "") " -Dtarget_prefix=${targetPrefix}"
}

View File

@ -1,119 +0,0 @@
{
lib,
stdenv,
fetchFromGitHub,
atf,
gperf,
libiconvReal,
meson,
ninja,
pkg-config,
gitUpdater,
}:
let
inherit (stdenv) hostPlatform;
in
stdenv.mkDerivation (finalAttrs: {
pname = "libiconv";
version = "99";
outputs = [
"out"
"dev"
];
# Propagate `out` only when there are dylibs to link (i.e., dont propagate when doing a static build).
propagatedBuildOutputs = lib.optionalString (!hostPlatform.isStatic) "out";
src = fetchFromGitHub {
owner = "apple-oss-distributions";
repo = "libiconv";
rev = "libiconv-${finalAttrs.version}";
hash = "sha256-TGt6rsU52ztfW2rCqwnhMAExLbexI/59IoDOGY+XGu0=";
};
setupHooks =
libiconvReal.setupHooks
++ lib.optionals hostPlatform.isStatic [ ./static-setup-hook.sh ];
patches = lib.optionals hostPlatform.isStatic [ ./0001-Support-static-module-loading.patch ] ++ [
./0002-Fix-ISO-2022-out-of-bounds-write-with-encoded-charac.patch
];
postPatch =
''
substitute ${./meson.build} meson.build --subst-var version
cp ${./meson.options} meson.options
# Work around unnecessary private API usage in libcharset
mkdir -p libcharset/os && cat <<-header > libcharset/os/variant_private.h
#pragma once
#include <stdbool.h>
static inline bool os_variant_has_internal_content(const char*) { return false; }
header
cp ${./nixpkgs_test.c} tests/libiconv/nixpkgs_test.c
''
+ lib.optionalString hostPlatform.isStatic ''
cp ${./static-modules.gperf} static-modules.gperf
'';
strictDeps = true;
nativeBuildInputs =
[
meson
ninja
]
# Dynamic builds use `dlopen` to load modules, but static builds have to link them all.
# `gperf` is used to generate a lookup table from module to ops functions.
++ lib.optionals hostPlatform.isStatic [ gperf ];
mesonBuildType = "release";
mesonFlags = [ (lib.mesonBool "tests" finalAttrs.doInstallCheck) ];
postInstall =
lib.optionalString (stdenv.hostPlatform.isDarwin && !hostPlatform.isStatic) ''
${stdenv.cc.targetPrefix}install_name_tool "$out/lib/libiconv.2.dylib" \
-change '@rpath/libcharset.1.dylib' "$out/lib/libcharset.1.dylib"
''
# Move the static library to the `dev` output
+ lib.optionalString hostPlatform.isStatic ''
moveToOutput lib "$dev"
'';
# Tests have to be run in `installCheckPhase` because libiconv expects to `dlopen`
# modules from `$out/lib/i18n`.
nativeInstallCheckInputs = [ pkg-config ];
installCheckInputs = [ atf ];
doInstallCheck = stdenv.buildPlatform.canExecute hostPlatform;
# Cant use `mesonCheckPhase` because it runs the wrong hooks for `installCheckPhase`.
installCheckPhase = ''
runHook preInstallCheck
meson test --no-rebuild
runHook postInstallCheck
'';
passthru.updateScript = gitUpdater { rev-prefix = "libiconv-"; };
__structuredAttrs = true;
meta = {
description = "Iconv(3) implementation";
homepage = "https://opensource.apple.com/releases/";
license =
with lib.licenses;
[
bsd2
bsd3
]
++ lib.optional finalAttrs.doInstallCheck apsl10;
mainProgram = "iconv";
maintainers = with lib.maintainers; [ reckenrode ];
platforms = lib.platforms.darwin;
};
})

View File

@ -0,0 +1,70 @@
{
lib,
autoreconfHook,
bash,
libtool,
fetchFromGitHub,
nix-update-script,
perl,
stdenv,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "libxo";
version = "1.7.5";
src = fetchFromGitHub {
owner = "Juniper";
repo = "libxo";
rev = finalAttrs.version;
hash = "sha256-ElSxegY2ejw7IuIMznfVpl29Wyvpx9k1BdXregzYsoQ=";
};
postPatch = ''
substituteInPlace configure.ac \
--replace-fail LIBTOOL=glibtool 'LIBTOOL=${lib.getExe libtool}'
# Remove impurities
substituteInPlace libxo/Makefile.am \
--replace-fail '-L/opt/local/lib' ""
'';
outputs = [
"bin"
"out"
"dev"
"man"
];
configureFlags = lib.optionals stdenv.hostPlatform.isDarwin [
# libxo misdetects malloc and realloc when cross-compiling on Darwin
"ac_cv_func_malloc_0_nonnull=yes"
"ac_cv_func_realloc_0_nonnull=yes"
];
strictDeps = true;
nativeBuildInputs = [ autoreconfHook ];
buildInputs = [
autoreconfHook
# For patchShebangs in postInstall
bash
perl
];
postInstall = ''
moveToOutput "bin/libxo-config" "$dev"
patchShebangs --host "$out/bin"
'';
__structuredAttrs = true;
passthru.updateScript = nix-update-script { };
meta = {
description = "Library to generate text, XML, JSON, and HTML";
license = lib.licenses.bsd2;
maintainers = [ lib.maintainers.reckenrode ];
platforms = lib.platforms.unix;
};
})

View File

@ -30,14 +30,14 @@
xar,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "xar";
version = "498";
pname = "xar${lib.optionalString (e2fsprogs == null) "-minimal"}";
version = "501";
src = fetchFromGitHub {
owner = "apple-oss-distributions";
repo = "xar";
rev = "xar-${finalAttrs.version}";
hash = "sha256-RyWeR/ZnDBHIZhwzVxETdrTTPQA2VgsLZegRkxX1240=";
hash = "sha256-Fq+Re0LCBIGhW2FR+pgV8SWtaDOEFgTh+rQ8JFWK/k0=";
};
# Update patch set with

View File

@ -0,0 +1,161 @@
{
lib,
cmake,
darwin,
fetchFromGitHub,
libpng,
libxml2,
makeBinaryWrapper,
ninja,
stdenv,
zlib,
# These arguments are obsolete but required to avoid evaluation errors (for now).
CoreGraphics ? null,
CoreServices ? null,
ImageIO ? null,
# These are deprecated and do nothing. Theyre needed for compatibility and will
# warn eventually once in-tree uses are cleaned up.
xcodePlatform ? null,
xcodeVer ? null,
sdkVer ? null,
productBuildVer ? null,
}:
# TODO(@reckenrode) enable this warning after uses in nixpkgs have been fixed
#let
# attrs = {
# inherit
# xcodePlatform
# xcodeVer
# sdkVer
# productBuildVer
# ;
# };
#in
#assert lib.warnIf (lib.any (attr: attr != null) (lib.attrValues attrs)) ''
# The following arguments are deprecated and do nothing: ${
# lib.concatStringsSep ", " (lib.attrNames (lib.filterAttrs (_: value: value != null) attrs))
# }
#
# xcbuild will dynamically pick up the SDK and SDK version based
# on the SDK used in nixpkgs. If you need to use a different SDK,
# add the appropriate SDK to your packages `buildInputs`.
#
# See the stdenv documentation for how to use `apple-sdk`.
#'' true;
let
googletest = fetchFromGitHub {
owner = "google";
repo = "googletest";
rev = "43359642a1c16ad3f4fc575c7edd0cb935810815";
sha256 = "sha256-mKjXaawFHSRrbJBtADJ1Pdk6vtuD+ax0HFk6YaBSnXg=";
};
linenoise = fetchFromGitHub {
owner = "antirez";
repo = "linenoise";
rev = "c894b9e59f02203dbe4e2be657572cf88c4230c3";
sha256 = "sha256-nKxwWuSqr89lvI9Y3QAW5Mo7/iFfMNj/OOQVeA/FWnE=";
};
in
stdenv.mkDerivation (finalAttrs: {
pname = "xcbuild";
outputs = [
"out"
"xcrun"
];
version = "0.1.1-unstable-2019-11-20";
src = fetchFromGitHub {
owner = "facebook";
repo = "xcbuild";
rev = "dbaee552d2f13640773eb1ad3c79c0d2aca7229c";
hash = "sha256-7mvSuRCWU/LlIBdmnC59F4SSzJPEcQhlmEK13PNe1xc=";
};
patches = [
# Add missing header for `abort`
./patches/includes.patch
# Prevent xcrun from recursively invoking itself
./patches/Avoid-fork-bomb-when-searching-system-paths.patch
];
prePatch = ''
rmdir ThirdParty/*
cp -r --no-preserve=all ${googletest} ThirdParty/googletest
cp -r --no-preserve=all ${linenoise} ThirdParty/linenoise
'';
postPatch =
lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
# Fix build on gcc-13 due to missing includes
sed -e '1i #include <cstdint>' -i \
Libraries/libutil/Headers/libutil/Permissions.h \
Libraries/pbxbuild/Headers/pbxbuild/Tool/AuxiliaryFile.h \
Libraries/pbxbuild/Headers/pbxbuild/Tool/Invocation.h
# Avoid a glibc >= 2.25 deprecation warning that gets fatal via -Werror.
sed 1i'#include <sys/sysmacros.h>' \
-i Libraries/xcassets/Headers/xcassets/Slot/SystemVersion.h
''
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
# Apple Open Sourced LZFSE, but not libcompression, and it isn't
# part of an impure framework we can add
substituteInPlace Libraries/libcar/Sources/Rendition.cpp \
--replace "#if HAVE_LIBCOMPRESSION" "#if 0"
'';
strictDeps = true;
env.NIX_CFLAGS_COMPILE = "-Wno-error";
nativeBuildInputs = [
cmake
makeBinaryWrapper
ninja
];
buildInputs = [
libpng
libxml2
zlib
];
# TODO: instruct cmake not to put it in /usr, rather than cleaning up
postInstall = ''
mv $out/usr/* $out
rmdir $out/usr
cp liblinenoise.* $out/lib/
mkdir -p "$xcrun/bin"
ln -s "$out/bin/xcrun" "$xcrun/bin/xcrun"
# xcbuild and xcrun support absolute paths, but they cant find the SDK with the way its set up in
# the store. Fortunately, the combination of `DEVELOPER_DIR` and a plain `SDKROOT` is enough.
wrapProgram "$out/bin/xcbuild" --set SDKROOT macosx
wrapProgram "$out/bin/xcrun" --set SDKROOT macosx
'';
__structuredAttrs = true;
passthru = {
xcbuild =
# lib.warn "xcbuild.xcbuild is deprecated and will be removed; use xcbuild instead."
finalAttrs.finalPackage;
};
meta = {
description = "Xcode-compatible build tool";
homepage = "https://github.com/facebook/xcbuild";
license = with lib.licenses; [
bsd2
bsd3
];
maintainers = lib.teams.darwin.members;
platforms = lib.platforms.unix;
};
})

View File

@ -0,0 +1,47 @@
diff --git a/Libraries/xcsdk/Tools/xcrun.cpp b/Libraries/xcsdk/Tools/xcrun.cpp
index 9d6d4576d7..7400267c2b 100644
--- a/Libraries/xcsdk/Tools/xcrun.cpp
+++ b/Libraries/xcsdk/Tools/xcrun.cpp
@@ -23,6 +23,8 @@
#include <process/DefaultUser.h>
#include <pbxsetting/Type.h>
+#include <algorithm>
+
using libutil::DefaultFilesystem;
using libutil::Filesystem;
using libutil::FSUtil;
@@ -398,6 +400,8 @@
fprintf(stderr, "\n");
}
+ std::unordered_map<std::string, std::string> environment = processContext->environmentVariables();
+
/*
* Collect search paths for the tool.
* Can be in toolchains, target (if one is provided), developer root,
@@ -408,6 +412,15 @@
executablePaths.insert(executablePaths.end(), defaultExecutablePaths.begin(), defaultExecutablePaths.end());
/*
+ * Dont look for tools in `/usr/bin` because it can cause an infinite recursion when `xcrun` finds a shim
+ * that tries to invoke `xcrun` to run the tool.
+ */
+ executablePaths.erase(
+ std::remove(executablePaths.begin(), executablePaths.end(), "/usr/bin"),
+ executablePaths.end()
+ );
+
+ /*
* Find the tool to execute.
*/
ext::optional<std::string> executable = filesystem->findExecutable(*options.tool(), executablePaths);
@@ -428,8 +441,6 @@
} else {
/* Run is the default. */
- std::unordered_map<std::string, std::string> environment = processContext->environmentVariables();
-
if (target != nullptr) {
/*
* Update effective environment to include the target path.

View File

@ -7,10 +7,11 @@
, src ? null
, monorepoSrc ? null
, runCommand
, apple-sdk
, apple-sdk_10_13
, cmake
, ninja
, python3
, xcbuild
, libllvm
, libcxx
, linuxHeaders
@ -46,6 +47,14 @@ let
baseName = "compiler-rt";
pname = baseName + lib.optionalString (haveLibc) "-libc";
# Sanitizers require 10.13 or newer. Instead of disabling them for most x86_64-darwin users,
# build them with a newer SDK and the default (10.12) deployment target.
apple-sdk' =
if lib.versionOlder (lib.getVersion apple-sdk) "10.13" then
apple-sdk_10_13.override { enableBootstrap = true; }
else
apple-sdk.override { enableBootstrap = true; };
src' = if monorepoSrc != null then
runCommand "${baseName}-src-${version}" {} ''
mkdir -p "$out"
@ -67,22 +76,29 @@ stdenv.mkDerivation ({
nativeBuildInputs = [ cmake ]
++ (lib.optional (lib.versionAtLeast release_version "15") ninja)
++ [ python3 libllvm.dev ]
++ lib.optional stdenv.hostPlatform.isDarwin xcbuild.xcrun;
++ [ python3 libllvm.dev ];
buildInputs =
lib.optional (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isRiscV) linuxHeaders
++ lib.optional (stdenv.hostPlatform.isFreeBSD) freebsd.include;
++ lib.optional (stdenv.hostPlatform.isFreeBSD) freebsd.include
# Adding the bootstrap SDK to `buildInputs` on static builds propagates it, breaking `xcrun`.
# This can be removed once the minimum SDK >10.12 on x86_64-darwin.
++ lib.optionals (stdenv.hostPlatform.isDarwin && !stdenv.hostPlatform.isStatic) [ apple-sdk' ];
env.NIX_CFLAGS_COMPILE = toString ([
"-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0"
] ++ lib.optionals (!haveLibc) [
# The compiler got stricter about this, and there is a usellvm patch below
# which patches out the assert include causing an implicit definition of
# assert. It would be nicer to understand why compiler-rt thinks it should
# be able to #include <assert.h> in the first place; perhaps it's in the
# wrong, or perhaps there is a way to provide an assert.h.
"-Wno-error=implicit-function-declaration"
]);
env = {
NIX_CFLAGS_COMPILE = toString ([
"-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0"
] ++ lib.optionals (!haveLibc) [
# The compiler got stricter about this, and there is a usellvm patch below
# which patches out the assert include causing an implicit definition of
# assert. It would be nicer to understand why compiler-rt thinks it should
# be able to #include <assert.h> in the first place; perhaps it's in the
# wrong, or perhaps there is a way to provide an assert.h.
"-Wno-error=implicit-function-declaration"
]);
} // lib.optionalAttrs (stdenv.hostPlatform.isDarwin) {
# Work around clangs trying to invoke unprefixed-ld on Darwin when `-target` is passed.
NIX_CFLAGS_LINK = "--ld-path=${stdenv.cc.bintools}/bin/${stdenv.cc.targetPrefix}ld";
};
cmakeFlags = [
"-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON"
@ -125,33 +141,30 @@ stdenv.mkDerivation ({
"-DCOMPILER_RT_OS_DIR=baremetal"
] ++ lib.optionals (stdenv.hostPlatform.isDarwin) (lib.optionals (lib.versionAtLeast release_version "16") [
"-DCMAKE_LIPO=${lib.getBin stdenv.cc.bintools.bintools}/bin/${stdenv.cc.targetPrefix}lipo"
] ++ lib.optionals (!haveLibcxx) [
# Darwin fails to detect that the compiler supports the `-g` flag when there is no libc++ during the
# compiler-rt bootstrap, which prevents compiler-rt from building. The `-g` flag is required by the
# Darwin support, so force it to be enabled during the first stage of the compiler-rt bootstrap.
"-DCOMPILER_RT_HAS_G_FLAG=ON"
] ++ [
"-DDARWIN_macosx_OVERRIDE_SDK_VERSION=ON"
"-DDARWIN_macosx_CACHED_SYSROOT=${apple-sdk'.sdkroot}"
"-DDARWIN_macosx_OVERRIDE_SDK_VERSION=${lib.versions.majorMinor (lib.getVersion apple-sdk)}"
"-DDARWIN_osx_ARCHS=${stdenv.hostPlatform.darwinArch}"
"-DDARWIN_osx_BUILTIN_ARCHS=${stdenv.hostPlatform.darwinArch}"
"-DSANITIZER_MIN_OSX_VERSION=${stdenv.hostPlatform.darwinMinVersion}"
] ++ lib.optionals (lib.versionAtLeast release_version "15") [
# `COMPILER_RT_DEFAULT_TARGET_ONLY` does not apply to Darwin:
# https://github.com/llvm/llvm-project/blob/27ef42bec80b6c010b7b3729ed0528619521a690/compiler-rt/cmake/base-config-ix.cmake#L153
"-DCOMPILER_RT_ENABLE_IOS=OFF"
]) ++ lib.optionals (lib.versionAtLeast version "19" && stdenv.hostPlatform.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinMinVersion "10.13") [
"-DSANITIZER_MIN_OSX_VERSION=10.10"
] ++ lib.optionals (noSanitizers && lib.versionAtLeast release_version "19") [
]) ++ lib.optionals (noSanitizers && lib.versionAtLeast release_version "19") [
"-DCOMPILER_RT_BUILD_CTX_PROFILE=OFF"
] ++ devExtraCmakeFlags;
outputs = [ "out" "dev" ];
# TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
# to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra
# can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd
# get no binary cache for the entire platform. If you really find yourself wanting the TSAN, make this controllable by
# a flag and turn the flag off during the stdenv build.
postPatch = lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
substituteInPlace cmake/builtin-config-ix.cmake \
--replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)'
'' + lib.optionalString stdenv.hostPlatform.isDarwin ''
substituteInPlace cmake/config-ix.cmake \
--replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)'
'' + lib.optionalString (!haveLibc) ((lib.optionalString (lib.versionAtLeast release_version "18") ''
substituteInPlace lib/builtins/aarch64/sme-libc-routines.c \
--replace "<stdlib.h>" "<stddef.h>"

View File

@ -546,6 +546,23 @@ let
libllvmLibdir = "${tools.libllvm.lib}/lib";
})
]
# Backport version logic from Clang 16. This is needed by the following patch.
++ lib.optional (lib.versionOlder (lib.versions.major metadata.release_version) "16") (fetchpatch {
name = "clang-darwin-Use-consistent-version-define-stringifying-logic.patch";
url = "https://github.com/llvm/llvm-project/commit/60a33ded751c86fff9ac1c4bdd2b341fbe4b0649.patch?full_index=1";
includes = [ "lib/Basic/Targets/OSTargets.cpp" ];
stripLen = 1;
hash = "sha256-YVTSg5eZLz3po2AUczPNXCK26JA3CuTh6Iqp7hAAKIs=";
})
# Backport `__ENVIRONMENT_OS_VERSION_MIN_REQUIRED__` support from Clang 17.
# This is needed by newer SDKs (14+).
++ lib.optional (lib.versionOlder (lib.versions.major metadata.release_version) "17") (fetchpatch {
name = "clang-darwin-An-OS-version-preprocessor-define.patch";
url = "https://github.com/llvm/llvm-project/commit/c8e2dd8c6f490b68e41fe663b44535a8a21dfeab.patch?full_index=1";
includes = [ "lib/Basic/Targets/OSTargets.cpp" ];
stripLen = 1;
hash = "sha256-Vs32kql7N6qtLqc12FtZHURcbenA7+N3E/nRRX3jdig=";
})
++ lib.optional (lib.versions.major metadata.release_version == "18") (fetchpatch {
name = "tweak-tryCaptureVariable-for-unevaluated-lambdas.patch";
url = "https://github.com/llvm/llvm-project/commit/3d361b225fe89ce1d8c93639f27d689082bd8dad.patch";
@ -770,16 +787,20 @@ let
bintools = bintools';
extraPackages =
[ targetLlvmLibraries.compiler-rt-no-libc ]
++ lib.optionals (!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD) [
targetLlvmLibraries.libunwind
];
++ lib.optionals
(
!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD && !stdenv.targetPlatform.isDarwin
)
[
targetLlvmLibraries.libunwind
];
extraBuildCommands =
lib.optionalString (lib.versions.major metadata.release_version == "13") (
''
echo "-rtlib=compiler-rt -Wno-unused-command-line-argument" >> $out/nix-support/cc-cflags
echo "-B${targetLlvmLibraries.compiler-rt-no-libc}/lib" >> $out/nix-support/cc-cflags
''
+ lib.optionalString (!stdenv.targetPlatform.isWasm) ''
+ lib.optionalString (!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isDarwin) ''
echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags
echo "-L${targetLlvmLibraries.libunwind}/lib" >> $out/nix-support/cc-ldflags
''
@ -800,7 +821,7 @@ let
"-B${targetLlvmLibraries.compiler-rt-no-libc}/lib"
]
++ lib.optional (
!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD
!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD && !stdenv.targetPlatform.isDarwin
) "--unwindlib=libunwind"
++ lib.optional (
!stdenv.targetPlatform.isWasm
@ -809,7 +830,7 @@ let
) "-lunwind"
++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
nixSupport.cc-ldflags = lib.optionals (
!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD
!stdenv.targetPlatform.isWasm && !stdenv.targetPlatform.isFreeBSD && !stdenv.targetPlatform.isDarwin
) [ "-L${targetLlvmLibraries.libunwind}/lib" ];
}
);
@ -997,14 +1018,11 @@ let
let
# temp rename to avoid infinite recursion
stdenv =
if args.stdenv.hostPlatform.useLLVM or false then
# Darwin needs to use a bootstrap stdenv to avoid an infinite recursion when cross-compiling.
if args.stdenv.hostPlatform.isDarwin then
overrideCC darwin.bootstrapStdenv buildLlvmTools.clangWithLibcAndBasicRtAndLibcxx
else if args.stdenv.hostPlatform.useLLVM or false then
overrideCC args.stdenv buildLlvmTools.clangWithLibcAndBasicRtAndLibcxx
else if
lib.versionAtLeast metadata.release_version "16"
&& args.stdenv.hostPlatform.isDarwin
&& args.stdenv.hostPlatform.isStatic
then
overrideCC args.stdenv buildLlvmTools.clangNoCompilerRtWithLibc
else
args.stdenv;
in
@ -1023,10 +1041,10 @@ let
patches = compiler-rtPatches;
doFakeLibgcc = stdenv.hostPlatform.useLLVM or false;
stdenv =
if stdenv.hostPlatform.isDarwin && stdenv.hostPlatform == stdenv.buildPlatform then
stdenv
# Darwin needs to use a bootstrap stdenv to avoid an infinite recursion when cross-compiling.
if stdenv.hostPlatform.isDarwin then
overrideCC darwin.bootstrapStdenv buildLlvmTools.clangNoLibcNoRt
else
# TODO: make this branch unconditional next rebuild
overrideCC stdenv buildLlvmTools.clangNoLibcNoRt;
};
@ -1108,7 +1126,11 @@ let
)
# https://github.com/llvm/llvm-project/issues/64226
(metadata.getVersionFile "libcxx/0001-darwin-10.12-mbstate_t-fix.patch");
stdenv = overrideCC stdenv buildLlvmTools.clangWithLibcAndBasicRt;
stdenv =
if stdenv.hostPlatform.isDarwin then
overrideCC darwin.bootstrapStdenv buildLlvmTools.clangWithLibcAndBasicRt
else
overrideCC stdenv buildLlvmTools.clangWithLibcAndBasicRt;
}
// lib.optionalAttrs (lib.versionOlder metadata.release_version "14") {
# TODO: remove this, causes LLVM 13 packages rebuild.

View File

@ -17,6 +17,7 @@
# TODO: Can this memory corruption bug still occur?
# <https://github.com/llvm/llvm-project/issues/61350>
, enableGoldPlugin ? libbfd.hasPluginAPI
, ld64
, libbfd
, libpfm
, libxml2
@ -46,6 +47,11 @@
let
inherit (lib) optional optionals optionalString;
# Is there a better way to do this? Darwin wants to disable tests in the first
# LLVM rebuild, but overriding doesnt work when building libc++, libc++abi,
# and libunwind. It also wants to disable LTO in the first rebuild.
isDarwinBootstrap = lib.getName stdenv == "bootstrap-stage-xclang-stdenv-darwin";
# Used when creating a version-suffixed symlink of libLLVM.dylib
shortVersion = lib.concatStringsSep "." (lib.take 1 (lib.splitString "." release_version));
@ -66,7 +72,7 @@ let
#
# So, we "manually" assemble one python derivation for the package to depend
# on, taking into account whether checks are enabled or not:
python = if doCheck then
python = if doCheck && !isDarwinBootstrap then
# Note that we _explicitly_ ask for a python interpreter for our host
# platform here; the splicing that would ordinarily take care of this for
# us does not seem to work once we use `withPackages`.
@ -91,14 +97,14 @@ let
patches' = patches ++ lib.optionals enablePolly pollyPatches;
in
stdenv.mkDerivation (rec {
stdenv.mkDerivation (finalAttrs: {
inherit pname version;
src = src';
patches = patches';
sourceRoot = if lib.versionOlder release_version "13" then null
else "${src.name}/${pname}";
else "${finalAttrs.src.name}/${pname}";
outputs = [ "out" "lib" "dev" "python" ];
@ -342,13 +348,13 @@ stdenv.mkDerivation (rec {
];
in flagsForLlvmConfig ++ [
"-DLLVM_INSTALL_UTILS=ON" # Needed by rustc
"-DLLVM_BUILD_TESTS=${if doCheck then "ON" else "OFF"}"
"-DLLVM_BUILD_TESTS=${if finalAttrs.finalPackage.doCheck then "ON" else "OFF"}"
"-DLLVM_ENABLE_FFI=ON"
"-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}"
"-DLLVM_DEFAULT_TARGET_TRIPLE=${stdenv.hostPlatform.config}"
"-DLLVM_ENABLE_DUMP=ON"
(lib.cmakeBool "LLVM_ENABLE_TERMINFO" enableTerminfo)
] ++ optionals (!doCheck) [
] ++ optionals (!finalAttrs.finalPackage.doCheck) [
"-DLLVM_INCLUDE_TESTS=OFF"
] ++ optionals stdenv.hostPlatform.isStatic [
# Disables building of shared libs, -fPIC is still injected by cc-wrapper
@ -428,7 +434,7 @@ stdenv.mkDerivation (rec {
cp NATIVE/bin/llvm-config $dev/bin/llvm-config-native
'');
inherit doCheck;
doCheck = !isDarwinBootstrap && doCheck;
checkTarget = "check-all";

View File

@ -11,7 +11,7 @@
, tcl ? null, tk ? null, tix ? null, libX11 ? null, x11Support ? false
, zlib
, self
, configd, coreutils
, coreutils
, autoreconfHook
, python-setup-hook
# Some proprietary libs assume UCS2 unicode, especially on darwin :(
@ -239,8 +239,7 @@ let
buildInputs =
lib.optional (stdenv ? cc && stdenv.cc.libc != null) stdenv.cc.libc ++
[ bzip2 openssl zlib libffi expat db gdbm ncurses sqlite readline ]
++ lib.optionals x11Support [ tcl tk libX11 ]
++ lib.optional (stdenv.hostPlatform.isDarwin && configd != null) configd;
++ lib.optionals x11Support [ tcl tk libX11 ];
nativeBuildInputs =
[ autoreconfHook ]
++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform)

View File

@ -25,7 +25,7 @@
# platform-specific dependencies
, bash
, configd
, apple-sdk_11
, darwin
, windows
@ -178,11 +178,12 @@ let
bluez
] ++ optionals enableFramework [
darwin.apple_sdk.frameworks.Cocoa
] ++ optionals stdenv.hostPlatform.isDarwin [
# Work around for ld64 crashes on x86_64-darwin. Remove once 11.0 becomes the default.
apple-sdk_11
] ++ optionals stdenv.hostPlatform.isMinGW [
windows.dlfcn
windows.mingw_w64_pthreads
] ++ optionals stdenv.hostPlatform.isDarwin [
configd
] ++ optionals tzdataSupport [
tzdata
] ++ optionals withGdbm [
@ -362,9 +363,6 @@ in with passthru; stdenv.mkDerivation (finalAttrs: {
(enableFeature enableGIL "gil")
] ++ optionals enableOptimizations [
"--enable-optimizations"
] ++ optionals (stdenv.hostPlatform.isDarwin && configd == null) [
# Make conditional on Darwin for now to avoid causing Linux rebuilds.
"py_cv_module__scproxy=n/a"
] ++ optionals (sqlite != null) [
"--enable-loadable-sqlite-extensions"
] ++ optionals (libxcrypt != null) [

View File

@ -38,7 +38,6 @@ in {
suffix = ".8"; # ActiveState's Python 2 extended support
};
hash = "sha256-HUOzu3uJbtd+3GbmGD35KOk/CDlwL4S7hi9jJGRFiqI=";
inherit (darwin) configd;
inherit passthruFun;
};
@ -51,7 +50,6 @@ in {
suffix = "";
};
hash = "sha256-aygSee/YUpTS1pk+FzmDpXRkwBM5Vvu7VTbslka+rww=";
inherit (darwin) configd;
inherit passthruFun;
};
@ -64,7 +62,6 @@ in {
suffix = "";
};
hash = "sha256-qrCVCBdzUXJgGHmHLZN8HkkopXxAmuAjaew9kdzOvnk=";
inherit (darwin) configd;
inherit passthruFun;
};
@ -77,13 +74,11 @@ in {
suffix = "";
};
hash = "sha256-B6Q1bpEpAOYaFcsJSaBsSgUBLiE+zWtOhND2equ+43I=";
inherit (darwin) configd;
inherit passthruFun;
};
python312 = callPackage ./cpython ({
self = __splicedPackages.python312;
inherit (darwin) configd;
inherit passthruFun;
} // sources.python312);
@ -96,7 +91,6 @@ in {
suffix = "";
};
hash = "sha256-CG3liC48sxDU3KSEV1IuLkgBjs1D2pzfgn9qB1nvsH0=";
inherit (darwin) configd;
inherit passthruFun;
};
# Minimal versions of Python (built without optional dependencies)
@ -109,7 +103,6 @@ in {
readline = null;
ncurses = null;
gdbm = null;
configd = null;
sqlite = null;
tzdata = null;
libffi = libffiBoot; # without test suite

View File

@ -3,6 +3,7 @@
, fetchFromGitHub
, autoconf
, automake
, darwin
, libtool
, pkg-config
, pkgsStatic
@ -86,6 +87,8 @@ stdenv.mkDerivation (finalAttrs: {
nativeBuildInputs = [ automake autoconf libtool pkg-config ];
buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ darwin.libutil ];
preConfigure = ''
LIBTOOLIZE=libtoolize ./autogen.sh
'';

View File

@ -1,80 +0,0 @@
{ lib, stdenv, cmake, fetchFromGitHub, zlib, libxml2, libpng
, CoreServices, CoreGraphics, ImageIO, ninja }:
let
googletest = fetchFromGitHub {
owner = "google";
repo = "googletest";
rev = "43359642a1c16ad3f4fc575c7edd0cb935810815";
sha256 = "0y4xaah62fjr3isaryc3vfz3mn9xflr00vchdimj8785milxga4q";
};
linenoise = fetchFromGitHub {
owner = "antirez";
repo = "linenoise";
rev = "c894b9e59f02203dbe4e2be657572cf88c4230c3";
sha256 = "0wasql7ph5g473zxhc2z47z3pjp42q0dsn4gpijwzbxawid71b4w";
};
in stdenv.mkDerivation {
pname = "xcbuild";
# Once a version is released that includes
# https://github.com/facebook/xcbuild/commit/183c087a6484ceaae860c6f7300caf50aea0d710,
# we can stop doing this -pre thing.
version = "0.1.2-pre";
src = fetchFromGitHub {
owner = "facebook";
repo = "xcbuild";
rev = "32b9fbeb69bfa2682bd0351ec2f14548aaedd554";
sha256 = "1xxwg2849jizxv0g1hy0b1m3i7iivp9bmc4f5pi76swsn423d41m";
};
patches = [ ./includes.patch ];
prePatch = ''
rmdir ThirdParty/*
cp -r --no-preserve=all ${googletest} ThirdParty/googletest
cp -r --no-preserve=all ${linenoise} ThirdParty/linenoise
'';
postPatch = lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
# Fix build on gcc-13 due to missing includes
sed -e '1i #include <cstdint>' -i \
Libraries/libutil/Headers/libutil/Permissions.h \
Libraries/pbxbuild/Headers/pbxbuild/Tool/AuxiliaryFile.h \
Libraries/pbxbuild/Headers/pbxbuild/Tool/Invocation.h
# Avoid a glibc >= 2.25 deprecation warning that gets fatal via -Werror.
sed 1i'#include <sys/sysmacros.h>' \
-i Libraries/xcassets/Headers/xcassets/Slot/SystemVersion.h
'' + lib.optionalString stdenv.hostPlatform.isDarwin ''
# Apple Open Sourced LZFSE, but not libcompression, and it isn't
# part of an impure framework we can add
substituteInPlace Libraries/libcar/Sources/Rendition.cpp \
--replace "#if HAVE_LIBCOMPRESSION" "#if 0"
'';
# TODO: instruct cmake not to put it in /usr, rather than cleaning up
postInstall = ''
mv $out/usr/* $out
rmdir $out/usr
cp liblinenoise.* $out/lib/
'';
env.NIX_CFLAGS_COMPILE = "-Wno-error";
cmakeFlags = [ "-GNinja" ];
nativeBuildInputs = [ cmake ninja ];
buildInputs = [ zlib libxml2 libpng ]
++ lib.optionals stdenv.hostPlatform.isDarwin [ CoreServices CoreGraphics ImageIO ];
meta = with lib; {
description = "Xcode-compatible build tool";
homepage = "https://github.com/facebook/xcbuild";
platforms = platforms.unix;
maintainers = with maintainers; [ copumpkin matthewbauer ];
license = with licenses; [ bsd2 bsd3 ];
};
}

View File

@ -1,32 +0,0 @@
{ runCommand, lib, toolchainName, sdkName
, writeText, xcodePlatform, sdkVer, productBuildVer }:
let
inherit (lib.generators) toPlist toJSON;
SDKSettings = {
CanonicalName = sdkName;
DisplayName = sdkName;
Toolchains = [ toolchainName ];
Version = sdkVer;
MaximumDeploymentTarget = sdkVer;
isBaseSDK = "YES";
};
SystemVersion = lib.optionalAttrs (productBuildVer != null) {
ProductBuildVersion = productBuildVer;
} // {
ProductName = "Mac OS X";
ProductVersion = sdkVer;
};
in
runCommand "SDKs" {} ''
sdk=$out/${sdkName}.sdk
install -D ${writeText "SDKSettings.plist" (toPlist {} SDKSettings)} $sdk/SDKSettings.plist
install -D ${writeText "SDKSettings.json" (toJSON {} SDKSettings)} $sdk/SDKSettings.json
install -D ${writeText "SystemVersion.plist" (toPlist {} SystemVersion)} $sdk/System/Library/CoreServices/SystemVersion.plist
ln -s $sdk $sdk/usr
ln -s $sdk $out/${xcodePlatform}.sdk
''

View File

@ -1,73 +0,0 @@
{ runCommand, toolchainName, fetchurl, stdenv
, buildPackages, lib, writeText }:
let
inherit (lib) getBin optionalString;
inherit (lib.generators) toPlist;
ToolchainInfo = {
Identifier = toolchainName;
};
# We could pull this out of developer_cmds but it adds an annoying
# loop if we want to bootstrap and this is just a tiny script so I'm
# not going to bother.
mkdep-darwin-src = fetchurl {
url = "https://opensource.apple.com/source/developer_cmds/developer_cmds-63/mkdep/mkdep.sh";
sha256 = "0n4wpqfslfjs5zbys5yri8pfi2awyhlmknsf6laa5jzqbzq9x541";
executable = true;
};
in
runCommand "Toolchains" {} (''
toolchain=$out/XcodeDefault.xctoolchain
mkdir -p $toolchain
install -D ${writeText "ToolchainInfo.plist" (toPlist {} ToolchainInfo)} $toolchain/ToolchainInfo.plist
ln -s $toolchain $toolchain/usr
mkdir -p $toolchain/include
mkdir -p $toolchain/lib
mkdir -p $toolchain/libexec
mkdir -p $toolchain/share
mkdir -p $toolchain/bin
for bin in ${getBin stdenv.cc}/bin/*; do
ln -s $bin $toolchain/bin
done
for bin in ${getBin stdenv.cc.bintools.bintools}/bin/*; do
if ! [ -e "$toolchain/bin/$(basename $bin)" ]; then
ln -s $bin $toolchain/bin
fi
done
ln -s ${buildPackages.bison}/bin/yacc $toolchain/bin/yacc
ln -s ${buildPackages.bison}/bin/bison $toolchain/bin/bison
ln -s ${buildPackages.flex}/bin/flex $toolchain/bin/flex
ln -s ${buildPackages.flex}/bin/flex++ $toolchain/bin/flex++
ln -s $toolchain/bin/flex $toolchain/bin/lex
ln -s ${buildPackages.m4}/bin/m4 $toolchain/bin/m4
ln -s $toolchain/bin/m4 $toolchain/bin/gm4
ln -s ${buildPackages.unifdef}/bin/unifdef $toolchain/bin/unifdef
ln -s ${buildPackages.unifdef}/bin/unifdefall $toolchain/bin/unifdefall
ln -s ${buildPackages.gperf}/bin/gperf $toolchain/bin/gperf
ln -s ${buildPackages.indent}/bin/indent $toolchain/bin/indent
ln -s ${buildPackages.ctags}/bin/ctags $toolchain/bin/ctags
'' + optionalString stdenv.hostPlatform.isDarwin ''
for bin in ${getBin buildPackages.cctools}/bin/*; do
if ! [ -e "$toolchain/bin/$(basename $bin)" ]; then
ln -s $bin $toolchain/bin
fi
done
ln -s ${buildPackages.darwin.bootstrap_cmds}/bin/mig $toolchain/bin
mkdir -p $toolchain/libexec
ln -s ${buildPackages.darwin.bootstrap_cmds}/libexec/migcom $toolchain/libexec
ln -s ${mkdep-darwin-src} $toolchain/bin/mkdep
'')

View File

@ -1,167 +0,0 @@
{ lib, stdenv, makeWrapper, writeText, writeTextFile, runCommand, callPackage
, CoreServices, ImageIO, CoreGraphics
, xcodePlatform ? stdenv.targetPlatform.xcodePlatform or "MacOSX"
, xcodeVer ? stdenv.targetPlatform.xcodeVer or "9.4.1"
, sdkVer ? stdenv.targetPlatform.darwinSdkVersion or "10.12"
, productBuildVer ? null
}:
let
toolchainName = "com.apple.dt.toolchain.XcodeDefault";
sdkName = "${xcodePlatform}${sdkVer}";
xcrunSdkName = lib.toLower xcodePlatform;
# TODO: expose MACOSX_DEPLOYMENT_TARGET in nix so we can use it here.
sdkBuildVersion = "17E189";
xcodeSelectVersion = "2349";
xcbuild = callPackage ./default.nix {
inherit CoreServices ImageIO CoreGraphics stdenv;
};
toolchains = callPackage ./toolchains.nix {
inherit toolchainName stdenv;
};
sdks = callPackage ./sdks.nix {
inherit toolchainName sdkName xcodePlatform sdkVer productBuildVer;
};
platforms = callPackage ./platforms.nix {
inherit sdks xcodePlatform stdenv;
};
xcconfig = writeText "nix.xcconfig" ''
SDKROOT=${sdkName}
'';
xcode-select = writeText "xcode-select" ''
#!${stdenv.shell}
while [ $# -gt 0 ]; do
case "$1" in
-h | --help) ;; # noop
-s | --switch) shift;; # noop
-r | --reset) ;; # noop
-v | --version) echo xcode-select version ${xcodeSelectVersion} ;;
-p | -print-path | --print-path) echo @DEVELOPER_DIR@ ;;
--install) ;; # noop
esac
shift
done
'';
xcrun = writeTextFile {
name = "xcrun";
executable = true;
destination = "/bin/xcrun";
text = ''
#!${stdenv.shell}
args=( "$@" )
# If an SDK was requested, check that it matches.
for ((i = 0; i < ''${#args[@]}; i++)); do
case "''${args[i]}" in
--sdk | -sdk)
i=$((i + 1))
if [[ "''${args[i]}" != '${xcrunSdkName}' ]]; then
echo >&2 "xcodebuild: error: SDK \"''${args[i]}\" cannot be located."
exit 1
fi
;;
esac
done
while [ $# -gt 0 ]; do
case "$1" in
--sdk | -sdk) shift ;;
--toolchain | -toolchain) shift ;;
--find | -find | -f)
shift
command -v $1 || exit 1 ;;
--log | -log) ;; # noop
--verbose | -verbose) ;; # noop
--no-cache | -no-cache) ;; # noop
--kill-cache | -kill-cache) ;; # noop
--show-sdk-path | -show-sdk-path)
echo ${sdks}/${sdkName}.sdk ;;
--show-sdk-platform-path | -show-sdk-platform-path)
echo ${platforms}/${xcodePlatform}.platform ;;
--show-sdk-version | -show-sdk-version)
echo ${sdkVer} ;;
--show-sdk-build-version | -show-sdk-build-version)
echo ${sdkBuildVersion} ;;
*) break ;;
esac
shift
done
if ! [[ -z "$@" ]]; then
exec "$@"
fi
'';
checkPhase = ''
${stdenv.shellDryRun} "$target"
'';
};
in
runCommand "xcodebuild-${xcbuild.version}" {
nativeBuildInputs = [ makeWrapper ];
inherit (xcbuild) meta;
# ensure that the toolchain goes in PATH
propagatedBuildInputs = [ "${toolchains}/XcodeDefault.xctoolchain" ];
passthru = {
inherit xcbuild xcrun;
toolchain = "${toolchains}/XcodeDefault.xctoolchain";
sdk = "${sdks}/${sdkName}";
platform = "${platforms}/${xcodePlatform}.platform";
};
preferLocalBuild = true;
} ''
mkdir -p $out/bin
ln -s $out $out/usr
mkdir -p $out/Library/Xcode
ln -s ${xcbuild}/Library/Xcode/Specifications $out/Library/Xcode/Specifications
ln -s ${platforms} $out/Platforms
ln -s ${toolchains} $out/Toolchains
mkdir -p $out/Applications/Xcode.app/Contents
ln -s $out $out/Applications/Xcode.app/Contents/Developer
# The native xcodebuild command supports an invocation like "xcodebuild -version -sdk" without specifying the specific SDK, so we simulate this by
# detecting this case and simulating the output; printing the header and appending the normal output via appending the sdk version to the positional
# arguments we pass through to the wrapped xcodebuild.
makeWrapper ${xcbuild}/bin/xcodebuild $out/bin/xcodebuild \
--add-flags "-xcconfig ${xcconfig}" \
--add-flags "DERIVED_DATA_DIR=." \
--set DEVELOPER_DIR "$out" \
--set SDKROOT ${sdkName} \
--run '[ "$#" -eq 2 ] && [ "$1" = "-version" ] && [ "$2" = "-sdk" ] && echo ${sdkName}.sdk - macOS ${sdkVer} \(macosx${sdkVer}\) && set -- "$@" "${sdkName}"' \
--run '[ "$1" = "-version" ] && [ "$#" -eq 1 ] && (echo Xcode ${xcodeVer}; echo Build version ${sdkBuildVersion}) && exit 0' \
--run '[ "$1" = "-license" ] && exit 0'
substitute ${xcode-select} $out/bin/xcode-select \
--subst-var-by DEVELOPER_DIR $out/Applications/Xcode.app/Contents/Developer
chmod +x $out/bin/xcode-select
cp ${xcrun}/bin/xcrun $out/bin/xcrun
for bin in PlistBuddy actool builtin-copy builtin-copyPlist \
builtin-copyStrings builtin-copyTiff \
builtin-embeddedBinaryValidationUtility \
builtin-infoPlistUtility builtin-lsRegisterURL \
builtin-productPackagingUtility builtin-validationUtility \
lsbom plutil; do
ln -s ${xcbuild}/bin/$bin $out/bin/$bin
done
fixupPhase
''

View File

@ -1,58 +0,0 @@
{
lib,
fetchFromGitHub,
fetchpatch,
stdenvNoCC,
darwin-stubs,
}:
stdenvNoCC.mkDerivation (finalAttrs: {
pname = "CoreSymbolication";
inherit (darwin-stubs) version;
src = fetchFromGitHub {
repo = "CoreSymbolication";
owner = "matthewbauer";
rev = "24c87c23664b3ee05dc7a5a87d647ae476a680e4";
hash = "sha256-PzvLq94eNhP0+rLwGMKcMzxuD6MlrNI7iT/eV0obtSE=";
};
patches = [
# Add missing symbol definitions needed to build `zlog` in system_cmds.
# https://github.com/matthewbauer/CoreSymbolication/pull/2
(fetchpatch {
url = "https://github.com/matthewbauer/CoreSymbolication/commit/ae7ac6a7043dbae8e63d6ce5e63dfaf02b5977fe.patch";
hash = "sha256-IuXGMsaR1LIGs+BpDU1b4YlznKm9VhK5DQ+Dthtb1mI=";
})
(fetchpatch {
url = "https://github.com/matthewbauer/CoreSymbolication/commit/6531da946949a94643e6d8424236174ae64fe0ca.patch";
hash = "sha256-+nDX04yY92yVT9KxiAFY2LxKcS7P8JpU539K+YVRqV4=";
})
];
dontBuild = true;
installPhase = ''
runHook preInstall
mkdir -p $out/Library/Frameworks/CoreSymbolication.framework/Versions/A/Headers
ln -s A $out/Library/Frameworks/CoreSymbolication.framework/Versions/Current
ln -s Versions/Current/Headers $out/Library/Frameworks/CoreSymbolication.framework/Headers
ln -s Versions/Current/CoreSymbolication.tbd $out/Library/Frameworks/CoreSymbolication.framework/CoreSymbolication.tbd
cp *.h $out/Library/Frameworks/CoreSymbolication.framework/Versions/A/Headers
cp ${darwin-stubs}/System/Library/PrivateFrameworks/CoreSymbolication.framework/Versions/A/CoreSymbolication.tbd \
$out/Library/Frameworks/CoreSymbolication.framework/Versions/A/CoreSymbolication.tbd
runHook postInstall
'';
meta = with lib; {
description = "Reverse engineered headers for Apple's CoreSymbolication framework";
homepage = "https://github.com/matthewbauer/CoreSymbolication";
license = licenses.mit;
platforms = platforms.darwin;
maintainers = with maintainers; [ matthewbauer ];
};
})

View File

@ -1,268 +0,0 @@
{ lib, stdenvNoCC, buildPackages, fetchurl, xar, cpio, pkgs, python3, pbzx, MacOSX-SDK }:
# TODO: reorganize to make this just frameworks, and move libs to default.nix
let
stdenv = stdenvNoCC;
standardFrameworkPath = name: private:
"/System/Library/${lib.optionalString private "Private"}Frameworks/${name}.framework";
mkDepsRewrites = deps:
let
mergeRewrites = x: y: {
prefix = lib.mergeAttrs (x.prefix or {}) (y.prefix or {});
const = lib.mergeAttrs (x.const or {}) (y.const or {});
};
rewriteArgs = { prefix ? {}, const ? {} }: lib.concatLists (
(lib.mapAttrsToList (from: to: [ "-p" "${from}:${to}" ]) prefix) ++
(lib.mapAttrsToList (from: to: [ "-c" "${from}:${to}" ]) const)
);
rewrites = depList: lib.fold mergeRewrites {}
(map (dep: dep.tbdRewrites)
(lib.filter (dep: dep ? tbdRewrites) depList));
in
lib.escapeShellArgs (rewriteArgs (rewrites (builtins.attrValues deps)));
mkFramework = { name, deps, private ? false }:
let self = stdenv.mkDerivation {
pname = "apple-${lib.optionalString private "private-"}framework-${name}";
version = MacOSX-SDK.version;
dontUnpack = true;
# because we copy files from the system
preferLocalBuild = true;
disallowedRequisites = [ MacOSX-SDK ];
nativeBuildInputs = [ buildPackages.darwin.rewrite-tbd ];
installPhase = ''
mkdir -p $out/Library/Frameworks
cp -r ${MacOSX-SDK}${standardFrameworkPath name private} $out/Library/Frameworks
if [[ -d ${MacOSX-SDK}/usr/lib/swift/${name}.swiftmodule ]]; then
mkdir -p $out/lib/swift
cp -r -t $out/lib/swift \
${MacOSX-SDK}/usr/lib/swift/${name}.swiftmodule \
${MacOSX-SDK}/usr/lib/swift/libswift${name}.tbd
fi
# Fix and check tbd re-export references
chmod u+w -R $out
find $out -name '*.tbd' -type f | while read tbd; do
echo "Fixing re-exports in $tbd"
rewrite-tbd \
-p ${standardFrameworkPath name private}/:$out/Library/Frameworks/${name}.framework/ \
-p /usr/lib/swift/:$out/lib/swift/ \
${mkDepsRewrites deps} \
-r ${builtins.storeDir} \
"$tbd"
done
'';
propagatedBuildInputs = builtins.attrValues deps;
passthru = {
tbdRewrites = {
prefix."${standardFrameworkPath name private}/" = "${self}/Library/Frameworks/${name}.framework/";
};
};
meta = with lib; {
description = "Apple SDK framework ${name}";
maintainers = with maintainers; [ copumpkin ];
platforms = platforms.darwin;
};
};
in self;
framework = name: deps: mkFramework { inherit name deps; private = false; };
privateFramework = name: deps: mkFramework { inherit name deps; private = true; };
in rec {
libs = {
xpc = stdenv.mkDerivation {
name = "apple-lib-xpc";
dontUnpack = true;
installPhase = ''
mkdir -p $out/include
pushd $out/include >/dev/null
cp -r "${MacOSX-SDK}/usr/include/xpc" $out/include/xpc
cp "${MacOSX-SDK}/usr/include/launch.h" $out/include/launch.h
popd >/dev/null
'';
};
Xplugin = stdenv.mkDerivation {
name = "apple-lib-Xplugin";
dontUnpack = true;
propagatedBuildInputs = with frameworks; [
OpenGL ApplicationServices Carbon IOKit CoreGraphics CoreServices CoreText
];
installPhase = ''
mkdir -p $out/include $out/lib
ln -s "${MacOSX-SDK}/include/Xplugin.h" $out/include/Xplugin.h
cp ${MacOSX-SDK}/usr/lib/libXplugin.1.tbd $out/lib
ln -s libXplugin.1.tbd $out/lib/libXplugin.tbd
'';
};
utmp = stdenv.mkDerivation {
name = "apple-lib-utmp";
dontUnpack = true;
installPhase = ''
mkdir -p $out/include
pushd $out/include >/dev/null
ln -s "${MacOSX-SDK}/include/utmp.h"
ln -s "${MacOSX-SDK}/include/utmpx.h"
popd >/dev/null
'';
};
sandbox = stdenv.mkDerivation {
name = "apple-lib-sandbox";
dontUnpack = true;
dontBuild = true;
installPhase = ''
mkdir -p $out/include $out/lib
ln -s "${MacOSX-SDK}/usr/include/sandbox.h" $out/include/sandbox.h
cp "${MacOSX-SDK}/usr/lib/libsandbox.1.tbd" $out/lib
ln -s libsandbox.1.tbd $out/lib/libsandbox.tbd
'';
};
libDER = stdenv.mkDerivation {
name = "apple-lib-libDER";
dontUnpack = true;
installPhase = ''
mkdir -p $out/include
cp -r ${MacOSX-SDK}/usr/include/libDER $out/include
'';
};
simd = stdenv.mkDerivation {
name = "apple-lib-simd";
dontUnpack = true;
installPhase = ''
mkdir -p $out/include
cp -r ${MacOSX-SDK}/usr/include/simd $out/include
'';
};
};
frameworks = let
# Dependency map created by gen-frameworks.py.
generatedDeps = import ./frameworks.nix {
inherit frameworks libs;
};
# Additional dependencies that are not picked up by gen-frameworks.py.
# Some of these are simply private frameworks the generator does not see.
extraDeps = with libs; with frameworks; let
inherit (pkgs.darwin.apple_sdk_11_0) libnetwork;
libobjc = pkgs.darwin.apple_sdk_11_0.objc4;
in {
# Below this comment are entries migrated from before the generator was
# added. If, for a given framework, you are able to reverify the extra
# deps are really necessary on top of the generator deps, move it above
# this comment (and maybe document your findings).
AVFoundation = { inherit ApplicationServices AVFCapture AVFCore; };
Accelerate = { inherit CoreWLAN IOBluetooth; };
AddressBook = { inherit AddressBookCore ContactsPersistence libobjc; };
AppKit = { inherit AudioToolbox AudioUnit UIFoundation; };
AudioToolbox = { inherit AudioToolboxCore; };
AudioUnit = { inherit Carbon CoreAudio; };
Carbon = { inherit IOKit QuartzCore libobjc; };
CoreAudio = { inherit IOKit; };
CoreFoundation = { inherit libobjc; };
CoreGraphics = { inherit SystemConfiguration; };
CoreMIDIServer = { inherit CoreMIDI; };
CoreMedia = { inherit ApplicationServices AudioToolbox AudioUnit; };
CoreServices = { inherit CoreAudio NetFS ServiceManagement; };
CoreWLAN = { inherit SecurityFoundation; };
DiscRecording = { inherit IOKit libobjc; };
Foundation = { inherit SystemConfiguration libobjc; };
GameKit = { inherit GameCenterFoundation GameCenterUI GameCenterUICore ReplayKit; };
ICADevices = { inherit Carbon libobjc; };
IOBluetooth = { inherit CoreBluetooth; };
JavaScriptCore = { inherit libobjc; };
Kernel = { inherit IOKit; };
LinkPresentation = { inherit URLFormatting; };
MediaToolbox = { inherit AudioUnit; };
MetricKit = { inherit SignpostMetrics; };
Network = { inherit libnetwork; };
PCSC = { inherit CoreData; };
PassKit = { inherit PassKitCore; };
QTKit = { inherit CoreMedia CoreMediaIO MediaToolbox VideoToolbox; };
Quartz = { inherit QTKit; };
QuartzCore = { inherit ApplicationServices CoreImage CoreVideo Metal OpenCL libobjc; };
Security = { inherit IOKit libDER; };
TWAIN = { inherit Carbon; };
VideoDecodeAcceleration = { inherit CoreVideo; };
WebKit = { inherit ApplicationServices Carbon libobjc; };
};
# Overrides for framework derivations.
overrides = super: {
CoreFoundation = lib.overrideDerivation super.CoreFoundation (drv: {
setupHook = ./cf-setup-hook.sh;
});
# This framework doesn't exist in newer SDKs (somewhere around 10.13), but
# there are references to it in nixpkgs.
QuickTime = throw "QuickTime framework not available";
# Seems to be appropriate given https://developer.apple.com/forums/thread/666686
JavaVM = super.JavaNativeFoundation;
CoreVideo = lib.overrideDerivation super.CoreVideo (drv: {
installPhase = drv.installPhase + ''
# When used as a module, complains about a missing import for
# Darwin.C.stdint. Apparently fixed in later SDKs.
sed -e "/CFBase.h/ i #include <stdint.h>" \
-i $out/Library/Frameworks/CoreVideo.framework/Headers/CVBase.h
'';
});
System = lib.overrideDerivation super.System (drv: {
installPhase = drv.installPhase + ''
# Contrarily to the other frameworks, System framework's TBD file
# is a symlink pointing to ${MacOSX-SDK}/usr/lib/libSystem.B.tbd.
# This produces an error when installing the framework as:
# 1. The original file is not copied into the output directory
# 2. Even if it was copied, the relative path wouldn't match
# Thus, it is easier to replace the file than to fix the symlink.
cp --remove-destination ${MacOSX-SDK}/usr/lib/libSystem.B.tbd \
$out/Library/Frameworks/System.framework/Versions/B/System.tbd
'';
});
};
# Merge extraDeps into generatedDeps.
deps = generatedDeps // (
lib.mapAttrs
(name: deps: generatedDeps.${name} // deps)
extraDeps
);
# Create derivations, and add private frameworks.
bareFrameworks = (lib.mapAttrs framework deps) // (
lib.mapAttrs privateFramework (import ./private-frameworks.nix {
inherit frameworks;
libobjc = pkgs.darwin.apple_sdk_11_0.objc4;
})
);
in
# Apply derivation overrides.
bareFrameworks // overrides bareFrameworks;
}

View File

@ -1,6 +0,0 @@
forceLinkCoreFoundationFramework() {
NIX_CFLAGS_COMPILE="-F@out@/Library/Frameworks${NIX_CFLAGS_COMPILE:+ }${NIX_CFLAGS_COMPILE-}"
NIX_LDFLAGS+=" @out@/Library/Frameworks/CoreFoundation.framework/CoreFoundation.tbd"
}
preConfigureHooks+=(forceLinkCoreFoundationFramework)

View File

@ -1,160 +1,303 @@
{ stdenvNoCC, fetchurl, newScope, lib, pkgs
, stdenv, overrideCC
, xar, cpio, python3, pbzx }:
# Compatibility stubs for packages that used the old SDK frameworks.
# TODO(@reckenrode) Make these stubs warn after framework usage has been cleaned up in nixpkgs.
{
lib,
callPackage,
newScope,
overrideSDK,
pkgs,
stdenv,
stdenvNoCC,
}:
let
mkSusDerivation = args: stdenvNoCC.mkDerivation (args // {
dontBuild = true;
darwinDontCodeSign = true;
mkStub = callPackage ../apple-sdk/mk-stub.nix { } "11.0";
nativeBuildInputs = [ cpio pbzx ];
stdenvs =
{
stdenv = overrideSDK stdenv "11.0";
}
// builtins.listToAttrs (
map
(v: {
name = "llvmPackages_${v}";
value = pkgs."llvmPackages_${v}" // {
stdenv = overrideSDK pkgs."llvmPackages_${v}".stdenv "11.0";
};
})
[
"12"
"13"
"14"
"15"
"16"
]
);
in
stdenvs
// lib.genAttrs [
"CLTools_Executables"
"IOKit"
"Libsystem"
"LibsystemCross"
"MacOSX-SDK"
"configd"
"darwin-stubs"
"libcharset"
"libcompression"
"libnetwork"
"libpm"
"libunwind"
"objc4"
"sdkRoot"
] mkStub
// {
frameworks = lib.genAttrs [
"AGL"
"AVFCapture"
"AVFCore"
"AVFoundation"
"AVKit"
"Accelerate"
"Accessibility"
"Accounts"
"AdServices"
"AdSupport"
"AddressBook"
"AddressBookCore"
"AppKit"
"AppTrackingTransparency"
"Apple80211"
"AppleScriptKit"
"AppleScriptObjC"
"ApplicationServices"
"AudioToolbox"
"AudioToolboxCore"
"AudioUnit"
"AudioVideoBridging"
"AuthenticationServices"
"AutomaticAssessmentConfiguration"
"Automator"
"BackgroundTasks"
"BusinessChat"
"CFNetwork"
"CalendarStore"
"CallKit"
"Carbon"
"ClassKit"
"CloudKit"
"Cocoa"
"Collaboration"
"ColorSync"
"Combine"
"Contacts"
"ContactsPersistence"
"ContactsUI"
"CoreAudio"
"CoreAudioKit"
"CoreAudioTypes"
"CoreBluetooth"
"CoreData"
"CoreDisplay"
"CoreFoundation"
"CoreGraphics"
"CoreHaptics"
"CoreImage"
"CoreLocation"
"CoreMIDI"
"CoreMIDIServer"
"CoreML"
"CoreMedia"
"CoreMediaIO"
"CoreMotion"
"CoreServices"
"CoreSpotlight"
"CoreSymbolication"
"CoreTelephony"
"CoreText"
"CoreVideo"
"CoreWLAN"
"CryptoKit"
"CryptoTokenKit"
"DVDPlayback"
"DebugSymbols"
"DeveloperToolsSupport"
"DeviceCheck"
"DirectoryService"
"DiscRecording"
"DiscRecordingUI"
"DiskArbitration"
"DisplayServices"
"DriverKit"
"EventKit"
"ExceptionHandling"
"ExecutionPolicy"
"ExternalAccessory"
"FWAUserLib"
"FileProvider"
"FileProviderUI"
"FinderSync"
"ForceFeedback"
"Foundation"
"GLKit"
"GLUT"
"GSS"
"GameCenterFoundation"
"GameCenterUI"
"GameCenterUICore"
"GameController"
"GameKit"
"GameplayKit"
"HIDDriverKit"
"Hypervisor"
"ICADevices"
"IMServicePlugIn"
"IOBluetooth"
"IOBluetoothUI"
"IOKit"
"IOSurface"
"IOUSBHost"
"IdentityLookup"
"ImageCaptureCore"
"ImageIO"
"InputMethodKit"
"InstallerPlugins"
"InstantMessage"
"Intents"
"JavaNativeFoundation"
"JavaRuntimeSupport"
"JavaScriptCore"
"JavaVM"
"Kerberos"
"Kernel"
"KernelManagement"
"LDAP"
"LatentSemanticMapping"
"LinkPresentation"
"LocalAuthentication"
"MLCompute"
"MapKit"
"MediaAccessibility"
"MediaLibrary"
"MediaPlayer"
"MediaRemote"
"MediaToolbox"
"Message"
"Metal"
"MetalKit"
"MetalPerformanceShaders"
"MetalPerformanceShadersGraph"
"MetricKit"
"ModelIO"
"MultipeerConnectivity"
"MultitouchSupport"
"NaturalLanguage"
"NearbyInteraction"
"NetFS"
"Network"
"NetworkExtension"
"NetworkingDriverKit"
"NotificationCenter"
"OSAKit"
"OSLog"
"OpenAL"
"OpenCL"
"OpenDirectory"
"OpenGL"
"PCIDriverKit"
"PCSC"
"PDFKit"
"ParavirtualizedGraphics"
"PassKit"
"PassKitCore"
"PencilKit"
"Photos"
"PhotosUI"
"PreferencePanes"
"PushKit"
"Python"
"QTKit"
"Quartz"
"QuartzCore"
"QuickLook"
"QuickLookThumbnailing"
"QuickTime"
"RealityKit"
"ReplayKit"
"Ruby"
"SafariServices"
"SceneKit"
"ScreenSaver"
"ScreenTime"
"ScriptingBridge"
"Security"
"SecurityFoundation"
"SecurityInterface"
"SensorKit"
"ServiceManagement"
"SignpostMetrics"
"SkyLight"
"Social"
"SoundAnalysis"
"Speech"
"SpriteKit"
"StoreKit"
"SwiftUI"
"SyncServices"
"System"
"SystemConfiguration"
"SystemExtensions"
"TWAIN"
"Tcl"
"Tk"
"UIFoundation"
"URLFormatting"
"USBDriverKit"
"UniformTypeIdentifiers"
"UserNotifications"
"UserNotificationsUI"
"VideoDecodeAcceleration"
"VideoSubscriberAccount"
"VideoToolbox"
"Virtualization"
"Vision"
"WebKit"
"WidgetKit"
"iTunesLibrary"
"vmnet"
] mkStub;
outputs = [ "out" ];
libs = lib.genAttrs [
"Xplugin"
"utmp"
"libDER"
"xpc"
"sandbox"
"simd"
] mkStub;
unpackPhase = ''
pbzx $src | cpio -idm
'';
passthru = {
inherit (args) version;
};
});
MacOSX-SDK = mkSusDerivation {
pname = "MacOSX-SDK";
version = "11.0.0";
# https://swscan.apple.com/content/catalogs/others/index-11-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog
src = fetchurl {
url = "http://swcdn.apple.com/content/downloads/46/21/001-89745-A_56FM390IW5/v1um2qppgfdnam2e9cdqcqu2r6k8aa3lis/CLTools_macOSNMOS_SDK.pkg";
sha256 = "0n425smj4q1vxbza8fzwnk323fyzbbq866q32w288c44hl5yhwsf";
};
installPhase = ''
mv Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk $out
'';
};
CLTools_Executables = mkSusDerivation {
pname = "CLTools_Executables";
version = "11.0.0";
# https://swscan.apple.com/content/catalogs/others/index-11-10.15-10.14-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog
src = fetchurl {
url = "http://swcdn.apple.com/content/downloads/46/21/001-89745-A_56FM390IW5/v1um2qppgfdnam2e9cdqcqu2r6k8aa3lis/CLTools_Executables.pkg";
sha256 = "0nvb1qx7l81l2wcl8wvgbpsg5rcn51ylhivqmlfr2hrrv3zrrpl0";
};
installPhase = ''
mv Library/Developer/CommandLineTools $out
'';
};
mkCc = cc:
if lib.versionAtLeast stdenv.hostPlatform.darwinSdkVersion "11" then cc
else
cc.override {
bintools = stdenv.cc.bintools.override { libc = packages.Libsystem; };
libc = packages.Libsystem;
};
mkStdenv = stdenv:
if lib.versionAtLeast stdenv.hostPlatform.darwinSdkVersion "11" then stdenv
else
let
darwinMinVersion = "10.12";
darwinSdkVersion = "11.0";
in
(overrideCC stdenv (mkCc stdenv.cc)).override {
extraBuildInputs = [ pkgs.darwin.apple_sdk_11_0.frameworks.CoreFoundation ];
buildPlatform = stdenv.buildPlatform // { inherit darwinMinVersion darwinSdkVersion; };
hostPlatform = stdenv.hostPlatform // { inherit darwinMinVersion darwinSdkVersion; };
targetPlatform = stdenv.targetPlatform // { inherit darwinMinVersion darwinSdkVersion; };
};
stdenvs = {
stdenv = mkStdenv stdenv;
} // builtins.listToAttrs (map
(v: {
name = "llvmPackages_${v}";
value = pkgs."llvmPackages_${v}" // {
stdenv = mkStdenv pkgs."llvmPackages_${v}".stdenv;
clang = mkCc pkgs."llvmPackages_${v}".clang;
};
})
[ "12" "13" "14" "15" "16" ]
callPackage = newScope (
lib.optionalAttrs stdenv.isDarwin stdenvs // { inherit (pkgs.darwin.apple_sdk_11_0) rustPlatform; }
);
callPackage = newScope (packages // pkgs.darwin // { inherit MacOSX-SDK; });
packages = stdenvs // {
inherit (callPackage ./apple_sdk.nix { }) frameworks libs;
# TODO: this is nice to be private. is it worth the callPackage above?
# Probably, I don't think that callPackage costs much at all.
inherit MacOSX-SDK CLTools_Executables;
Libsystem = callPackage ./libSystem.nix { };
LibsystemCross = pkgs.darwin.Libsystem;
libcharset = callPackage ./libcharset.nix { };
libcompression = callPackage ./libcompression.nix { };
libunwind = callPackage ./libunwind.nix { };
libnetwork = callPackage ./libnetwork.nix { };
libpm = callPackage ./libpm.nix { };
# Avoid introducing a new objc4 if stdenv already has one, to prevent
# conflicting LLVM modules.
objc4 = stdenv.objc4 or (callPackage ./libobjc.nix { });
sdkRoot = pkgs.callPackage ../apple-sdk/sdkRoot.nix { sdkVersion = "11.0"; };
# questionable aliases
configd = pkgs.darwin.apple_sdk.frameworks.SystemConfiguration;
inherit (pkgs.darwin.apple_sdk.frameworks) IOKit;
xcodebuild = pkgs.xcbuild.override {
inherit (pkgs.darwin.apple_sdk_11_0) stdenv;
inherit (pkgs.darwin.apple_sdk_11_0.frameworks) CoreServices CoreGraphics ImageIO;
};
rustPlatform = pkgs.makeRustPlatform {
rustPlatform =
pkgs.makeRustPlatform {
inherit (pkgs.darwin.apple_sdk_11_0) stdenv;
inherit (pkgs) rustc cargo;
} // {
inherit (pkgs.callPackage ../../../build-support/rust/hooks {
inherit (pkgs.darwin.apple_sdk_11_0) stdenv;
inherit (pkgs) cargo rustc;
clang = mkCc pkgs.clang;
}) bindgenHook;
}
// {
inherit
(pkgs.callPackage ../../../build-support/rust/hooks {
inherit (pkgs.darwin.apple_sdk_11_0) stdenv;
inherit (pkgs) cargo rustc;
})
bindgenHook
;
};
callPackage = newScope (lib.optionalAttrs stdenv.hostPlatform.isDarwin (stdenvs // rec {
inherit (pkgs.darwin.apple_sdk_11_0) xcodebuild rustPlatform;
darwin = pkgs.darwin.overrideScope (_: prev: {
inherit (prev.darwin.apple_sdk_11_0)
IOKit
Libsystem
LibsystemCross
Security
configd
libcharset
libunwind
objc4
;
apple_sdk = prev.darwin.apple_sdk_11_0;
CF = prev.darwin.apple_sdk_11_0.CoreFoundation;
});
xcbuild = xcodebuild;
}));
stdenv = overrideSDK stdenv "11.0";
darwin-stubs = stdenvNoCC.mkDerivation {
pname = "darwin-stubs";
inherit (MacOSX-SDK) version;
xcodebuild = pkgs.xcodebuild;
buildCommand = ''
mkdir -p "$out"
ln -s ${MacOSX-SDK}/System "$out/System"
ln -s ${MacOSX-SDK}/usr "$out/usr"
'';
};
};
in packages
version = "11.0";
}

View File

@ -1,196 +0,0 @@
# This file is generated by gen-frameworks.nix.
# Do not edit, put overrides in apple_sdk.nix instead.
{ libs, frameworks }: with libs; with frameworks;
{
AGL = { inherit Carbon OpenGL; };
AVFoundation = { inherit AudioToolbox CoreAudio CoreAudioTypes CoreFoundation CoreGraphics CoreImage CoreMIDI CoreMedia CoreVideo Foundation IOKit ImageIO MediaToolbox Metal QuartzCore UniformTypeIdentifiers simd; };
AVKit = { inherit AVFoundation AppKit Cocoa Foundation; };
Accelerate = { inherit CoreFoundation CoreGraphics CoreVideo Foundation IOKit Metal; };
Accessibility = { inherit CoreGraphics Foundation; };
Accounts = { inherit Foundation; };
AdServices = { inherit Foundation; };
AdSupport = { inherit Foundation; };
AddressBook = { inherit Carbon Cocoa CoreFoundation Foundation; };
AppKit = { inherit ApplicationServices CloudKit CoreData CoreFoundation CoreGraphics CoreImage CoreLocation Foundation IOKit Metal OpenGL QuartzCore; };
AppTrackingTransparency = { inherit Foundation; };
AppleScriptKit = {};
AppleScriptObjC = { inherit Foundation; };
ApplicationServices = { inherit ColorSync CoreFoundation CoreGraphics CoreServices CoreText ImageIO; };
AudioToolbox = { inherit Carbon CoreAudio CoreAudioTypes CoreFoundation CoreMIDI Foundation; };
AudioUnit = { inherit AudioToolbox; };
AudioVideoBridging = { inherit Foundation IOKit; };
AuthenticationServices = { inherit AppKit Foundation; };
AutomaticAssessmentConfiguration = { inherit Foundation; };
Automator = { inherit AppKit Cocoa Foundation OSAKit; };
BackgroundTasks = { inherit Foundation; };
BusinessChat = { inherit Cocoa Foundation; };
CFNetwork = { inherit CoreFoundation; };
CalendarStore = {};
CallKit = { inherit CoreFoundation CoreGraphics Foundation IOKit; };
Carbon = { inherit ApplicationServices CoreServices Foundation Security; };
ClassKit = { inherit CoreGraphics Foundation; };
CloudKit = { inherit CoreFoundation CoreGraphics CoreLocation Foundation IOKit; };
Cocoa = { inherit AppKit CoreData Foundation; };
Collaboration = { inherit AppKit CoreServices Foundation; };
ColorSync = { inherit CoreFoundation; };
Combine = {};
Contacts = { inherit CoreFoundation CoreGraphics Foundation IOKit; };
ContactsUI = { inherit AppKit; };
CoreAudio = { inherit CoreAudioTypes CoreFoundation; };
CoreAudioKit = { inherit AppKit AudioUnit Cocoa Foundation; };
CoreAudioTypes = { inherit CoreFoundation; };
CoreBluetooth = { inherit Foundation; };
CoreData = { inherit CloudKit Combine CoreFoundation CoreGraphics CoreLocation Foundation IOKit; };
CoreDisplay = {};
CoreFoundation = {};
CoreGraphics = { inherit CoreFoundation IOKit; };
CoreHaptics = { inherit Foundation; };
CoreImage = { inherit ApplicationServices CoreFoundation CoreGraphics CoreVideo Foundation IOKit IOSurface ImageIO Metal OpenGL; };
CoreLocation = { inherit CoreFoundation CoreGraphics Foundation IOKit; };
CoreMIDI = { inherit CoreFoundation CoreGraphics Foundation IOKit; };
CoreMIDIServer = {};
CoreML = { inherit CoreFoundation CoreGraphics CoreVideo Foundation IOKit ImageIO Metal; };
CoreMedia = { inherit CoreAudio CoreAudioTypes CoreFoundation CoreGraphics CoreVideo Foundation IOKit Metal; };
CoreMediaIO = { inherit CoreFoundation CoreMedia; };
CoreMotion = { inherit Foundation; };
CoreServices = { inherit CFNetwork CoreFoundation DiskArbitration Security; };
CoreSpotlight = { inherit Foundation UniformTypeIdentifiers; };
CoreTelephony = {};
CoreText = { inherit CoreFoundation CoreGraphics; };
CoreVideo = { inherit ApplicationServices CoreFoundation CoreGraphics IOSurface Metal OpenGL; };
CoreWLAN = { inherit Foundation IOKit; };
CryptoKit = { inherit CoreFoundation CoreGraphics Foundation IOKit LocalAuthentication Security; };
CryptoTokenKit = { inherit CoreFoundation CoreGraphics Foundation IOKit Security; };
DVDPlayback = { inherit ApplicationServices CoreFoundation Security; };
DeveloperToolsSupport = { inherit Foundation; };
DeviceCheck = { inherit Foundation; };
DirectoryService = { inherit CoreFoundation; };
DiscRecording = { inherit CoreServices Foundation; };
DiscRecordingUI = { inherit Carbon Cocoa DiscRecording; };
DiskArbitration = { inherit CoreFoundation IOKit; };
DriverKit = {};
EventKit = { inherit CoreGraphics CoreLocation Foundation; };
ExceptionHandling = { inherit Foundation; };
ExecutionPolicy = { inherit Foundation; };
ExternalAccessory = { inherit Foundation; };
FWAUserLib = { inherit IOKit; };
FileProvider = { inherit CoreGraphics Foundation; };
FileProviderUI = { inherit AppKit FileProvider Foundation; };
FinderSync = { inherit AppKit Foundation; };
ForceFeedback = { inherit CoreFoundation IOKit; };
Foundation = { inherit ApplicationServices Combine CoreFoundation CoreGraphics CoreServices IOKit Security; };
GLKit = { inherit AppKit CloudKit CoreData CoreFoundation CoreGraphics CoreImage CoreLocation Foundation IOKit Metal ModelIO OpenGL QuartzCore simd; };
GLUT = { inherit OpenGL; };
GSS = { inherit CoreFoundation; };
GameController = { inherit AppKit Foundation IOKit; };
GameKit = { inherit AppKit Cocoa Contacts CoreGraphics Foundation GameController GameplayKit Metal MetalKit ModelIO SceneKit SpriteKit simd; };
GameplayKit = { inherit AppKit CloudKit CoreData CoreFoundation CoreGraphics CoreImage CoreLocation Foundation GLKit IOKit Metal ModelIO QuartzCore SceneKit SpriteKit simd; };
HIDDriverKit = { inherit IOKit USBDriverKit; };
Hypervisor = {};
ICADevices = { inherit CoreFoundation CoreGraphics CoreServices IOBluetooth; };
IMServicePlugIn = { inherit Foundation; };
IOBluetooth = { inherit CoreAudio CoreFoundation CoreServices Foundation IOKit; };
IOBluetoothUI = { inherit Cocoa IOBluetooth; };
IOKit = { inherit CoreFoundation; };
IOSurface = { inherit CoreFoundation Foundation IOKit; };
IOUSBHost = { inherit Foundation IOKit; };
IdentityLookup = { inherit Foundation; };
ImageCaptureCore = { inherit Cocoa CoreGraphics Foundation; };
ImageIO = { inherit CoreFoundation CoreGraphics; };
InputMethodKit = { inherit Carbon Cocoa Foundation; };
InstallerPlugins = {};
InstantMessage = {};
Intents = { inherit CoreFoundation CoreGraphics CoreLocation Foundation IOKit; };
JavaNativeFoundation = { inherit Foundation; };
JavaRuntimeSupport = { inherit ApplicationServices Cocoa Foundation QuartzCore; };
JavaScriptCore = { inherit CoreFoundation CoreGraphics Foundation; };
Kerberos = {};
Kernel = {};
KernelManagement = { inherit Foundation; };
LDAP = {};
LatentSemanticMapping = { inherit Carbon CoreFoundation; };
LinkPresentation = { inherit AppKit Foundation; };
LocalAuthentication = { inherit Foundation; };
MLCompute = { inherit CoreFoundation CoreGraphics Foundation IOKit Metal; };
MapKit = { inherit AppKit CloudKit CoreData CoreFoundation CoreGraphics CoreImage CoreLocation Foundation IOKit Metal QuartzCore; };
MediaAccessibility = { inherit CoreFoundation CoreGraphics CoreText QuartzCore; };
MediaLibrary = { inherit Foundation; };
MediaPlayer = { inherit AVFoundation CoreGraphics Foundation; };
MediaToolbox = { inherit AudioToolbox CoreFoundation CoreMedia; };
Message = {};
Metal = { inherit CoreFoundation CoreGraphics Foundation IOKit IOSurface; };
MetalKit = { inherit AppKit CloudKit CoreData CoreFoundation CoreGraphics CoreImage CoreLocation Foundation IOKit Metal ModelIO QuartzCore simd; };
MetalPerformanceShaders = { inherit CoreGraphics Foundation Metal simd; };
MetalPerformanceShadersGraph = { inherit Foundation MetalPerformanceShaders; };
MetricKit = { inherit CoreFoundation CoreGraphics Foundation IOKit; };
ModelIO = { inherit CoreFoundation CoreGraphics Foundation IOKit simd; };
MultipeerConnectivity = { inherit Cocoa Foundation; };
NaturalLanguage = { inherit CoreFoundation CoreGraphics Foundation IOKit; };
NearbyInteraction = { inherit CoreFoundation CoreGraphics Foundation IOKit simd; };
NetFS = { inherit CoreFoundation; };
Network = { inherit CoreFoundation Foundation Security; };
NetworkExtension = { inherit Foundation Network Security; };
NetworkingDriverKit = {};
NotificationCenter = { inherit AppKit Foundation; };
OSAKit = { inherit Carbon Cocoa; };
OSLog = { inherit CoreFoundation CoreGraphics Foundation IOKit; };
OpenAL = {};
OpenCL = { inherit OpenGL; };
OpenDirectory = { inherit CoreFoundation Foundation; };
OpenGL = {};
PCIDriverKit = { inherit IOKit; };
PCSC = {};
PDFKit = { inherit AppKit Cocoa; };
ParavirtualizedGraphics = { inherit AppKit CoreVideo Foundation IOSurface Metal; };
PassKit = { inherit AppKit Contacts CoreGraphics Foundation; };
PencilKit = { inherit AppKit CloudKit Cocoa CoreData CoreFoundation CoreGraphics CoreImage CoreLocation Foundation IOKit Metal QuartzCore; };
Photos = { inherit AVFoundation CoreAudio CoreFoundation CoreGraphics CoreImage CoreLocation CoreMIDI CoreMedia Foundation IOKit ImageIO Metal QuartzCore UniformTypeIdentifiers simd; };
PhotosUI = { inherit AppKit Foundation MapKit Photos; };
PreferencePanes = { inherit Cocoa; };
PushKit = { inherit Foundation; };
Python = { inherit Carbon; };
QTKit = {};
Quartz = { inherit AppKit ApplicationServices Cocoa Foundation ImageCaptureCore OpenGL PDFKit QuartzCore QuickLook; };
QuartzCore = { inherit CoreFoundation CoreGraphics CoreImage CoreVideo Foundation IOKit Metal OpenGL; };
QuickLook = { inherit ApplicationServices CoreFoundation; };
QuickLookThumbnailing = { inherit CoreGraphics Foundation UniformTypeIdentifiers; };
RealityKit = { inherit AVFoundation AppKit AudioToolbox CloudKit Combine CoreAudio CoreData CoreFoundation CoreGraphics CoreImage CoreLocation CoreMIDI CoreText Foundation IOKit Metal MultipeerConnectivity QuartzCore simd; };
ReplayKit = { inherit AVFoundation AppKit Foundation; };
Ruby = {};
SafariServices = { inherit AppKit CloudKit CoreData CoreFoundation CoreGraphics CoreImage CoreLocation Foundation IOKit Metal QuartzCore; };
SceneKit = { inherit AppKit CloudKit CoreData CoreFoundation CoreGraphics CoreImage CoreLocation Foundation GLKit IOKit Metal ModelIO QuartzCore simd; };
ScreenSaver = { inherit AppKit Foundation; };
ScreenTime = { inherit AppKit Foundation; };
ScriptingBridge = { inherit ApplicationServices CoreServices Foundation; };
Security = { inherit CoreFoundation; };
SecurityFoundation = { inherit Foundation Security; };
SecurityInterface = { inherit AppKit Cocoa Security SecurityFoundation; };
SensorKit = { inherit CoreFoundation CoreLocation Foundation; };
ServiceManagement = { inherit CoreFoundation Security; };
Social = { inherit AppKit Foundation; };
SoundAnalysis = { inherit AVFoundation CoreML CoreMedia Foundation; };
Speech = { inherit AVFoundation CoreAudio CoreFoundation CoreGraphics CoreImage CoreMIDI CoreMedia Foundation IOKit Metal QuartzCore UniformTypeIdentifiers simd; };
SpriteKit = { inherit AppKit CloudKit Cocoa CoreData CoreFoundation CoreGraphics CoreImage CoreLocation Foundation GLKit IOKit Metal ModelIO QuartzCore simd; };
StoreKit = { inherit AppKit CoreGraphics Foundation; };
SwiftUI = { inherit AppKit CloudKit Combine CoreData CoreFoundation CoreGraphics CoreImage CoreLocation DeveloperToolsSupport Foundation IOKit Metal QuartzCore UniformTypeIdentifiers; };
SyncServices = {};
System = {};
SystemConfiguration = { inherit CoreFoundation Security; };
SystemExtensions = { inherit Foundation; };
TWAIN = {};
Tcl = {};
Tk = {};
USBDriverKit = { inherit IOKit; };
UniformTypeIdentifiers = { inherit CoreFoundation CoreGraphics Foundation IOKit; };
UserNotifications = { inherit Foundation; };
UserNotificationsUI = { inherit AppKit; };
VideoDecodeAcceleration = {};
VideoSubscriberAccount = { inherit Foundation; };
VideoToolbox = { inherit CoreFoundation CoreGraphics CoreMedia CoreVideo; };
Virtualization = { inherit CoreFoundation CoreGraphics Foundation IOKit; };
Vision = { inherit CoreAudio CoreFoundation CoreGraphics CoreML CoreMedia CoreVideo Foundation IOKit ImageIO Metal simd; };
WebKit = { inherit AppKit CloudKit CoreData CoreFoundation CoreGraphics CoreImage CoreLocation Foundation IOKit JavaScriptCore Metal OpenGL QuartzCore; };
WidgetKit = { inherit Combine CoreFoundation CoreGraphics CoreVideo Foundation IOKit Intents Metal SwiftUI; };
iTunesLibrary = { inherit Foundation; };
vmnet = {};
}

View File

@ -1,88 +0,0 @@
{ stdenvNoCC, buildPackages, MacOSX-SDK }:
stdenvNoCC.mkDerivation {
pname = "libSystem";
version = MacOSX-SDK.version;
dontBuild = true;
dontUnpack = true;
nativeBuildInputs = [ buildPackages.darwin.rewrite-tbd ];
includeDirs = [
"CommonCrypto" "_types" "architecture" "arpa" "atm" "bank" "bsd" "bsm"
"corecrypto" "corpses" "default_pager" "device" "dispatch" "hfs" "i386"
"iokit" "kern" "libkern" "mach" "mach-o" "mach_debug" "machine" "malloc"
"miscfs" "net" "netinet" "netinet6" "netkey" "nfs" "os" "osfmk" "pexpert"
"platform" "protocols" "pthread" "rpc" "rpcsvc" "secure" "security"
"servers" "sys" "uuid" "vfs" "voucher" "xlocale"
] ++ [
"arm" "xpc" "arm64"
];
csu = [
"bundle1.o" "crt0.o" "crt1.10.5.o" "crt1.10.6.o" "crt1.o" "dylib1.10.5.o"
"dylib1.o" "gcrt1.o" "lazydylib1.o"
];
installPhase = ''
mkdir -p $out/{include,lib/swift}
for dir in $includeDirs; do
from=${MacOSX-SDK}/usr/include/$dir
if [ -e "$from" ]; then
cp -dr $from $out/include
else
echo "Header directory '$from' doesn't exist: skipping"
fi
done
cp -d \
${MacOSX-SDK}/usr/include/*.h \
${MacOSX-SDK}/usr/include/*.modulemap \
${MacOSX-SDK}/usr/include/*.apinotes \
$out/include
rm $out/include/tk*.h $out/include/tcl*.h
cp -dr \
${MacOSX-SDK}/usr/lib/libSystem.* \
${MacOSX-SDK}/usr/lib/system \
$out/lib
# Extra libraries
for name in c dbm dl info m mx poll proc pthread rpcsvc util gcc_s.1 resolv; do
cp -d \
${MacOSX-SDK}/usr/lib/lib$name.tbd \
${MacOSX-SDK}/usr/lib/lib$name.*.tbd \
$out/lib
done
for name in os Dispatch; do
cp -dr \
${MacOSX-SDK}/usr/lib/swift/$name.swiftmodule \
${MacOSX-SDK}/usr/lib/swift/libswift$name.tbd \
$out/lib/swift
done
for f in $csu; do
from=${MacOSX-SDK}/usr/lib/$f
if [ -e "$from" ]; then
cp -d $from $out/lib
else
echo "Csu file '$from' doesn't exist: skipping"
fi
done
chmod u+w -R $out/lib
find $out -name '*.tbd' -type f | while read tbd; do
rewrite-tbd \
-c /usr/lib/libsystem.dylib:$out/lib/libsystem.dylib \
-p /usr/lib/system/:$out/lib/system/ \
-p /usr/lib/swift/:$out/lib/swift/ \
-r ${builtins.storeDir} \
"$tbd"
done
'';
}

View File

@ -1,16 +0,0 @@
{ stdenvNoCC, buildPackages, MacOSX-SDK }:
stdenvNoCC.mkDerivation {
pname = "libcharset";
version = MacOSX-SDK.version;
dontUnpack = true;
dontBuild = true;
nativeBuildInputs = [ buildPackages.darwin.checkReexportsHook ];
installPhase = ''
mkdir -p $out/{include,lib}
cp ${MacOSX-SDK}/usr/lib/libcharset* $out/lib
'';
}

View File

@ -1,20 +0,0 @@
{ stdenvNoCC, buildPackages, MacOSX-SDK }:
let self = stdenvNoCC.mkDerivation {
pname = "libcompression";
version = MacOSX-SDK.version;
dontUnpack = true;
dontBuild = true;
installPhase = ''
mkdir -p $out/lib
cp ${MacOSX-SDK}/usr/lib/libcompression* $out/lib
'';
passthru = {
tbdRewrites = {
const."/usr/lib/libcompression.dylib" = "${self}/lib/libcompression.dylib";
};
};
}; in self

View File

@ -1,20 +0,0 @@
{ stdenvNoCC, buildPackages, MacOSX-SDK }:
let self = stdenvNoCC.mkDerivation {
pname = "libnetwork";
version = MacOSX-SDK.version;
dontUnpack = true;
dontBuild = true;
installPhase = ''
mkdir -p $out/lib
cp ${MacOSX-SDK}/usr/lib/libnetwork* $out/lib
'';
passthru = {
tbdRewrites = {
const."/usr/lib/libnetwork.dylib" = "${self}/lib/libnetwork.dylib";
};
};
}; in self

View File

@ -1,24 +0,0 @@
{ stdenvNoCC, MacOSX-SDK, libcharset }:
let self = stdenvNoCC.mkDerivation {
pname = "libobjc";
version = MacOSX-SDK.version;
dontUnpack = true;
dontBuild = true;
installPhase = ''
mkdir -p $out/{include,lib/swift}
cp -r ${MacOSX-SDK}/usr/include/objc $out/include
cp ${MacOSX-SDK}/usr/lib/libobjc* $out/lib
cp -r ${MacOSX-SDK}/usr/lib/swift/ObjectiveC.swiftmodule $out/lib/swift
cp ${MacOSX-SDK}/usr/lib/swift/libswiftObjectiveC.tbd $out/lib/swift
'';
passthru = {
tbdRewrites = {
const."/usr/lib/libobjc.A.dylib" = "${self}/lib/libobjc.A.dylib";
const."/usr/lib/swift/libswiftObjectiveC.dylib" = "${self}/lib/swift/libswiftObjectiveC.dylib";
};
};
}; in self

View File

@ -1,23 +0,0 @@
{ stdenvNoCC, MacOSX-SDK, checkReexportsHook }:
stdenvNoCC.mkDerivation {
pname = "libpm";
version = MacOSX-SDK.version;
dontUnpack = true;
dontBuild = true;
nativeBuildInputs = [ checkReexportsHook ];
installPhase = ''
mkdir -p $out/lib
cp ${MacOSX-SDK}/usr/lib/libpm* $out/lib
'';
passthru = {
tbdRewrites = {
const."/usr/lib/libpmenergy.dylib" = "${placeholder "out"}/lib/libpmenergy.dylib";
const."/usr/lib/libpmsample.dylib" = "${placeholder "out"}/lib/libpmsample.dylib";
};
};
}

View File

@ -1,24 +0,0 @@
{ stdenvNoCC, buildPackages, MacOSX-SDK }:
stdenvNoCC.mkDerivation {
pname = "libunwind";
version = MacOSX-SDK.version;
dontUnpack = true;
dontBuild = true;
nativeBuildInputs = [ buildPackages.darwin.checkReexportsHook ];
installPhase = ''
mkdir -p $out/include/mach-o
cp \
${MacOSX-SDK}/usr/include/libunwind.h \
${MacOSX-SDK}/usr/include/unwind.h \
$out/include
cp \
${MacOSX-SDK}/usr/include/mach-o/compact_unwind_encoding.h \
$out/include/mach-o
'';
}

View File

@ -1,32 +0,0 @@
{ frameworks, libobjc }: with frameworks;
# generated by hand to avoid exposing all private frameworks
# frameworks here are only the necessary ones used by public frameworks.
{
Apple80211 = {};
AVFCapture = {};
AVFCore = {};
AddressBookCore = { inherit ContactsPersistence; };
AudioToolboxCore = {};
ContactsPersistence = {};
GameCenterFoundation = {};
GameCenterUI = {};
GameCenterUICore = {};
MediaRemote = {};
PassKitCore = {};
SignpostMetrics = {};
SkyLight = {};
UIFoundation = {};
URLFormatting = {};
# Also expose CoreSymbolication; used by `root` package.
CoreSymbolication = {};
# Also expose DebugSymbols; used by `llvmPackages_8.lldb` package.
DebugSymbols = {};
# Also expose DisplayServices; used by `sketchybar` package.
DisplayServices = { inherit libobjc; };
# Also expose MultitouchSupport; used by `chuck` package.
MultitouchSupport = {};
}

View File

@ -1,27 +0,0 @@
{
stdenvNoCC,
fetchurl,
cpio,
pbzx,
version,
}:
let
releases = builtins.fromJSON (builtins.readFile ./apple-sdk-releases.json);
in
stdenvNoCC.mkDerivation (finalAttrs: {
pname = "CLTools_Executables";
inherit version;
src = fetchurl releases.${version}.${finalAttrs.pname};
nativeBuildInputs = [
cpio
pbzx
];
buildCommand = ''
pbzx $src | cpio -idm
mv Library/Developer/CommandLineTools $out
'';
})

View File

@ -1,28 +0,0 @@
{
lib,
stdenvNoCC,
fetchurl,
cpio,
pbzx,
version,
}:
let
releases = builtins.fromJSON (builtins.readFile ./apple-sdk-releases.json);
in
stdenvNoCC.mkDerivation (finalAttrs: {
pname = "CLTools_macOSNMOS_SDK";
inherit version;
src = fetchurl releases.${version}.${finalAttrs.pname};
nativeBuildInputs = [
cpio
pbzx
];
buildCommand = ''
pbzx $src | cpio -idm
mv Library/Developer/CommandLineTools/SDKs/MacOSX${lib.versions.majorMinor version}.sdk $out
'';
})

View File

@ -1,20 +0,0 @@
{
"12.3": {
"CLTools_Executables": {
"hash": "sha256-XlxHwCq+rtBF3Yyfdob3UEHN7YKzb7JF84lRmZbB/50=",
"url": "https://swcdn.apple.com/content/downloads/24/42/002-83793-A_74JRE8GVAT/rlnkct919wgc5c0pjq986z5bb9h62uvni2/CLTools_Executables.pkg"
},
"CLTools_macOSLMOS_SDK": {
"hash": "sha256-mY9YTlyTujV6R89WaNmkJrfOQatXnoSW8gKxnawQz5Q=",
"url": "https://swcdn.apple.com/content/downloads/24/42/002-83793-A_74JRE8GVAT/rlnkct919wgc5c0pjq986z5bb9h62uvni2/CLTools_macOSLMOS_SDK.pkg"
},
"CLTools_macOSNMOS_SDK": {
"hash": "sha256-Tr9VCeCP5udmh09U/zPQG2c4ky1LXscBwPfgpRy8uds=",
"url": "https://swcdn.apple.com/content/downloads/24/42/002-83793-A_74JRE8GVAT/rlnkct919wgc5c0pjq986z5bb9h62uvni2/CLTools_macOSNMOS_SDK.pkg"
},
"CLTools_macOS_SDK": {
"hash": "sha256-2xwYLfiYuEdck7/8NY3iqiPKvoG9HAjXt8Ewyp9c0Es=",
"url": "https://swcdn.apple.com/content/downloads/24/42/002-83793-A_74JRE8GVAT/rlnkct919wgc5c0pjq986z5bb9h62uvni2/CLTools_macOS_SDK.pkg"
}
}
}

View File

@ -1,49 +1,266 @@
# Compatibility stubs for packages that used the old SDK frameworks.
# TODO(@reckenrode) Make these stubs warn after framework usage has been cleaned up in nixpkgs.
{
lib,
callPackage,
newScope,
overrideCC,
overrideSDK,
pkgs,
stdenv,
stdenvNoCC,
}:
let
version = "12.3";
MacOSX-SDK = callPackage ./CLTools_macOSNMOS_SDK.nix { inherit version; };
callPackage = newScope (pkgs.darwin // packages);
packages = {
# Make sure we pass our special `callPackage` instead of using packages.callPackage which
# does not have necessary attributes in scope.
frameworks = callPackage ./frameworks { inherit callPackage; };
libs = callPackage ./libs { inherit callPackage; };
CLTools_Executables = callPackage ./CLTools_Executables.nix { inherit version; };
Libsystem = callPackage ./libSystem.nix { };
LibsystemCross = callPackage ./libSystem.nix { };
libunwind = callPackage ./libunwind.nix { };
libnetwork = callPackage ./libnetwork.nix { };
libpm = callPackage ./libpm.nix { };
# Avoid introducing a new objc4 if stdenv already has one, to prevent
# conflicting LLVM modules.
objc4 = stdenv.objc4 or (callPackage ./libobjc.nix { });
darwin-stubs = stdenvNoCC.mkDerivation {
pname = "darwin-stubs";
inherit (MacOSX-SDK) version;
preferLocalBuild = true;
allowSubstitutes = false;
buildCommand = ''
mkdir -p "$out"
ln -s ${MacOSX-SDK}/System "$out/System"
ln -s ${MacOSX-SDK}/usr "$out/usr"
'';
};
sdkRoot = pkgs.callPackage ../apple-sdk/sdkRoot.nix { sdkVersion = version; };
};
mkStub = callPackage ../apple-sdk/mk-stub.nix { } "12.3";
in
packages
lib.genAttrs [
"CLTools_Executables"
"Libsystem"
"LibsystemCross"
"darwin-stubs"
"libnetwork"
"libpm"
"libunwind"
"objc4"
"sdkRoot"
] mkStub
// {
frameworks = lib.genAttrs [
"AGL"
"AVFAudio"
"AVFCapture"
"AVFCore"
"AVFoundation"
"AVKit"
"Accelerate"
"Accessibility"
"Accounts"
"AdServices"
"AdSupport"
"AddressBook"
"AddressBookCore"
"AppKit"
"AppTrackingTransparency"
"AppleScriptKit"
"AppleScriptObjC"
"ApplicationServices"
"AudioToolbox"
"AudioToolboxCore"
"AudioUnit"
"AudioVideoBridging"
"AuthenticationServices"
"AutomaticAssessmentConfiguration"
"Automator"
"BackgroundTasks"
"BusinessChat"
"CFNetwork"
"CHIP"
"CalendarStore"
"CallKit"
"Carbon"
"ClassKit"
"CloudKit"
"Cocoa"
"Collaboration"
"ColorSync"
"Combine"
"Contacts"
"ContactsPersistence"
"ContactsUI"
"CoreAudio"
"CoreAudioKit"
"CoreAudioTypes"
"CoreBluetooth"
"CoreData"
"CoreDisplay"
"CoreFoundation"
"CoreGraphics"
"CoreHaptics"
"CoreImage"
"CoreLocation"
"CoreMIDI"
"CoreMIDIServer"
"CoreML"
"CoreMedia"
"CoreMediaIO"
"CoreMotion"
"CoreServices"
"CoreSpotlight"
"CoreSymbolication"
"CoreTelephony"
"CoreText"
"CoreVideo"
"CoreWLAN"
"CreateML"
"CryptoKit"
"CryptoTokenKit"
"DVDPlayback"
"DataDetection"
"DebugSymbols"
"DeveloperToolsSupport"
"DeviceActivity"
"DeviceCheck"
"DirectoryService"
"DiscRecording"
"DiscRecordingUI"
"DiskArbitration"
"DisplayServices"
"DriverKit"
"EventKit"
"ExceptionHandling"
"ExecutionPolicy"
"ExposureNotification"
"ExternalAccessory"
"FWAUserLib"
"FileProvider"
"FileProviderUI"
"FinderSync"
"ForceFeedback"
"Foundation"
"GLKit"
"GLUT"
"GSS"
"GameCenterFoundation"
"GameCenterUI"
"GameCenterUICore"
"GameController"
"GameKit"
"GameplayKit"
"GroupActivities"
"Hypervisor"
"ICADevices"
"IMServicePlugIn"
"IOBluetooth"
"IOBluetoothUI"
"IOKit"
"IOSurface"
"IOUSBHost"
"IdentityLookup"
"ImageCaptureCore"
"ImageIO"
"InputMethodKit"
"InstallerPlugins"
"InstantMessage"
"Intents"
"IntentsUI"
"JavaNativeFoundation"
"JavaRuntimeSupport"
"JavaScriptCore"
"JavaVM"
"Kerberos"
"Kernel"
"KernelManagement"
"LDAP"
"LatentSemanticMapping"
"LinkPresentation"
"LocalAuthentication"
"LocalAuthenticationEmbeddedUI"
"MLCompute"
"MailKit"
"ManagedSettings"
"MapKit"
"MediaAccessibility"
"MediaLibrary"
"MediaPlayer"
"MediaToolbox"
"Message"
"Metal"
"MetalKit"
"MetalPerformanceShaders"
"MetalPerformanceShadersGraph"
"MetricKit"
"ModelIO"
"MultipeerConnectivity"
"MultitouchSupport"
"MusicKit"
"NaturalLanguage"
"NearbyInteraction"
"NetFS"
"Network"
"NetworkExtension"
"NotificationCenter"
"OSAKit"
"OSLog"
"OpenAL"
"OpenCL"
"OpenDirectory"
"OpenGL"
"PCSC"
"PDFKit"
"PHASE"
"ParavirtualizedGraphics"
"PassKit"
"PassKitCore"
"PencilKit"
"Photos"
"PhotosUI"
"PreferencePanes"
"PushKit"
"QTKit"
"Quartz"
"QuartzCore"
"QuickLook"
"QuickLookThumbnailing"
"QuickLookUI"
"QuickTime"
"RealityFoundation"
"RealityKit"
"ReplayKit"
"Ruby"
"SafariServices"
"SceneKit"
"ScreenCaptureKit"
"ScreenSaver"
"ScreenTime"
"ScriptingBridge"
"Security"
"SecurityFoundation"
"SecurityInterface"
"SensorKit"
"ServiceManagement"
"ShazamKit"
"SignpostMetrics"
"SkyLight"
"Social"
"SoundAnalysis"
"Speech"
"SpriteKit"
"StoreKit"
"SwiftUI"
"SyncServices"
"System"
"SystemConfiguration"
"SystemExtensions"
"TWAIN"
"TabularData"
"Tcl"
"Tk"
"UIFoundation"
"URLFormatting"
"UniformTypeIdentifiers"
"UserNotifications"
"UserNotificationsUI"
"VideoDecodeAcceleration"
"VideoSubscriberAccount"
"VideoToolbox"
"Virtualization"
"Vision"
"WebKit"
"WidgetKit"
"iTunesLibrary"
"vmnet"
] mkStub;
libs = lib.genAttrs [
"Xplugin"
"utmp"
"libDER"
"xpc"
"sandbox"
"simd"
"utmp"
"xpc"
] mkStub;
version = "12.3";
}

View File

@ -1,146 +0,0 @@
{
lib,
stdenvNoCC,
buildPackages,
# macOS things
callPackage,
darwin-stubs,
}:
let
inherit (darwin-stubs) version;
fixup-frameworks = callPackage ./fixups.nix { };
private-frameworks = callPackage ./private.nix { };
public-frameworks = callPackage ./public.nix { };
mkDepsRewrites =
deps:
let
mergeRewrites = x: y: {
prefix = lib.mergeAttrs (x.prefix or { }) (y.prefix or { });
const = lib.mergeAttrs (x.const or { }) (y.const or { });
};
rewriteArgs =
{
prefix ? { },
const ? { },
}:
lib.concatLists (
(lib.mapAttrsToList (from: to: [
"-p"
"${from}:${to}"
]) prefix)
++ (lib.mapAttrsToList (from: to: [
"-c"
"${from}:${to}"
]) const)
);
rewrites =
depList:
lib.fold mergeRewrites { } (
map (dep: dep.tbdRewrites) (lib.filter (dep: dep ? tbdRewrites) depList)
);
in
lib.escapeShellArgs (rewriteArgs (rewrites (lib.attrValues deps)));
mkFramework =
{
name,
deps,
private ? false,
}:
let
standardFrameworkPath =
name: private:
"/System/Library/${lib.optionalString private "Private"}Frameworks/${name}.framework";
self = stdenvNoCC.mkDerivation {
pname = "apple-${lib.optionalString private "private-"}framework-${name}";
inherit (darwin-stubs) version;
# because we copy files from the system
preferLocalBuild = true;
dontUnpack = true;
dontBuild = true;
disallowedRequisites = [ darwin-stubs ];
nativeBuildInputs = [ buildPackages.darwin.rewrite-tbd ];
installPhase = ''
mkdir -p $out/Library/Frameworks
cp -r ${darwin-stubs}${standardFrameworkPath name private} $out/Library/Frameworks
if [[ -d ${darwin-stubs}/usr/lib/swift/${name}.swiftmodule ]]; then
mkdir -p $out/lib/swift
cp -r -t $out/lib/swift \
${darwin-stubs}/usr/lib/swift/${name}.swiftmodule \
${darwin-stubs}/usr/lib/swift/libswift${name}.tbd
fi
# Fix and check tbd re-export references
chmod u+w -R $out
find $out -name '*.tbd' -type f | while IFS=$'\n' read tbd; do
echo "Fixing re-exports in $tbd"
rewrite-tbd \
-p ${standardFrameworkPath name private}/:$out/Library/Frameworks/${name}.framework/ \
-p /usr/lib/swift/:$out/lib/swift/ \
${mkDepsRewrites deps} \
-r ${builtins.storeDir} \
"$tbd"
done
'';
propagatedBuildInputs = lib.attrValues deps;
passthru.tbdRewrites.prefix."${standardFrameworkPath name private}/" = "${self}/Library/Frameworks/${name}.framework/";
meta = with lib; {
description = "Apple SDK framework ${name}";
maintainers = [ ];
platforms = platforms.darwin;
};
};
in
self;
# Helper functions for creating framework derivations.
framework =
name: deps:
mkFramework {
inherit name deps;
private = false;
};
# Helper functions for creating private framework derivations.
privateFramework =
name: deps:
mkFramework {
inherit name deps;
private = true;
};
# Merge addToFrameworks into public-frameworks and remove elements of removeFromFrameworks.
deps =
let
inherit (fixup-frameworks) addToFrameworks removeFromFrameworks;
fixupDeps =
name: deps:
lib.pipe deps [
# Add dependencies from addToFrameworks.
(deps: lib.recursiveUpdate deps (addToFrameworks.${name} or { }))
# Keep dependencies not in removeFromFrameworks.
(lib.filterAttrs (depName: _: !(removeFromFrameworks.${name}.${depName} or false)))
];
in
lib.mapAttrs fixupDeps public-frameworks;
# Create derivations and add private frameworks.
bareFrameworks =
(lib.mapAttrs framework deps) // (lib.mapAttrs privateFramework private-frameworks);
in
bareFrameworks // fixup-frameworks.overrideFrameworks bareFrameworks

View File

@ -1,163 +0,0 @@
{
lib,
# macOS things
frameworks,
libnetwork,
libs,
darwin-stubs,
objc4,
}:
{
# Used to add dependencies which are not picked up by gen-frameworks.py.
# Some of these are simply private frameworks the generator does not see.
# Trial and error, building things and adding dependencies when they fail.
addToFrameworks =
let
inherit (libs) libDER;
libobjc = objc4;
in
with frameworks;
{
# Below this comment are entries migrated from before the generator was
# added. If, for a given framework, you are able to reverify the extra
# deps are really necessary on top of the generator deps, move it above
# this comment (and maybe document your findings).
AVFoundation = {
inherit ApplicationServices AVFCapture AVFCore;
};
Accelerate = {
inherit CoreWLAN IOBluetooth;
};
AddressBook = {
inherit AddressBookCore ContactsPersistence libobjc;
};
AppKit = {
inherit AudioToolbox AudioUnit UIFoundation;
};
AudioToolbox = {
inherit AudioToolboxCore;
};
AudioUnit = {
inherit Carbon CoreAudio;
};
Carbon = {
inherit IOKit QuartzCore libobjc;
};
CoreAudio = {
inherit IOKit;
};
CoreData = {
inherit CloudKit;
};
CoreFoundation = {
inherit libobjc;
};
CoreGraphics = {
inherit SystemConfiguration;
};
CoreMIDIServer = {
inherit CoreMIDI;
};
CoreMedia = {
inherit ApplicationServices AudioToolbox AudioUnit;
};
CoreServices = {
inherit CoreAudio NetFS ServiceManagement;
};
CoreWLAN = {
inherit SecurityFoundation;
};
DiscRecording = {
inherit IOKit libobjc;
};
Foundation = {
inherit SystemConfiguration libobjc;
};
GameKit = {
inherit
GameCenterFoundation
GameCenterUI
GameCenterUICore
ReplayKit
;
};
ICADevices = {
inherit Carbon libobjc;
};
IOBluetooth = {
inherit CoreBluetooth;
};
JavaScriptCore = {
inherit libobjc;
};
Kernel = {
inherit IOKit;
};
LinkPresentation = {
inherit URLFormatting;
};
MediaToolbox = {
inherit AudioUnit;
};
MetricKit = {
inherit SignpostMetrics;
};
Network = {
inherit libnetwork;
};
PCSC = {
inherit CoreData;
};
PassKit = {
inherit PassKitCore;
};
QTKit = {
inherit
CoreMedia
CoreMediaIO
MediaToolbox
VideoToolbox
;
};
Quartz = {
inherit QTKit;
};
QuartzCore = {
inherit
ApplicationServices
CoreImage
CoreVideo
Metal
OpenCL
libobjc
;
};
Security = {
inherit IOKit libDER;
};
TWAIN = {
inherit Carbon;
};
VideoDecodeAcceleration = {
inherit CoreVideo;
};
WebKit = {
inherit ApplicationServices Carbon libobjc;
};
};
# Used to remove dependencies which are picked up by gen-frameworks.py -- used mainly to break
# cyclic dependencies.
removeFromFrameworks = { };
# Overrides for framework derivations.
overrideFrameworks = super: {
# This framework doesn't exist in newer SDKs (somewhere around 10.13), but
# there are references to it in nixpkgs.
QuickTime = throw "QuickTime framework not available";
# Seems to be appropriate given https://developer.apple.com/forums/thread/666686
JavaVM = super.JavaNativeFoundation;
};
}

View File

@ -1,35 +0,0 @@
{ objc4, frameworks }:
# generated by hand to avoid exposing all private frameworks
# frameworks here are only the necessary ones used by public frameworks.
{
AVFCapture = { };
AVFCore = { };
AddressBookCore = {
inherit (frameworks) ContactsPersistence;
};
AudioToolboxCore = { };
ContactsPersistence = { };
UIFoundation = { };
GameCenterFoundation = { };
GameCenterUI = { };
GameCenterUICore = { };
URLFormatting = { };
SignpostMetrics = { };
PassKitCore = { };
SkyLight = { };
# Also expose CoreSymbolication; used by `root` package.
CoreSymbolication = { };
# Also expose DebugSymbols; used by `llvmPackages_8.lldb` package.
DebugSymbols = { };
# Also expose DisplayServices; used by `sketchybar` package.
DisplayServices = {
libobjc = objc4;
};
# Also expose MultitouchSupport; used by `chuck` package.
MultitouchSupport = { };
}

View File

@ -1,209 +0,0 @@
# This file is generated by gen-frameworks.nix.
# Do not edit, put overrides in apple_sdk.nix instead.
{ libs, frameworks }: with libs; with frameworks;
{
AGL = { inherit Carbon OpenGL; };
AVFAudio = { inherit AudioToolbox CoreAudioTypes CoreMIDI CoreMedia Foundation; };
AVFoundation = { inherit AVFAudio CoreAudio CoreFoundation CoreGraphics CoreImage CoreMIDI CoreMedia CoreVideo Foundation IOKit ImageIO MediaToolbox Metal QuartzCore UniformTypeIdentifiers simd; };
AVKit = { inherit AVFoundation AppKit Cocoa Foundation; };
Accelerate = { inherit CoreFoundation CoreGraphics CoreVideo Foundation IOKit Metal; };
Accessibility = { inherit CoreFoundation CoreGraphics Foundation IOKit; };
Accounts = { inherit Foundation; };
AdServices = { inherit Foundation; };
AdSupport = { inherit Foundation; };
AddressBook = { inherit Carbon Cocoa CoreFoundation Foundation; };
AppKit = { inherit Accessibility ApplicationServices CoreData CoreFoundation CoreGraphics CoreImage Foundation IOKit Metal OpenGL QuartzCore; };
AppTrackingTransparency = { inherit Foundation; };
AppleScriptKit = {};
AppleScriptObjC = { inherit Foundation; };
ApplicationServices = { inherit ColorSync CoreFoundation CoreGraphics CoreServices CoreText ImageIO; };
AudioToolbox = { inherit Carbon CoreAudio CoreAudioTypes CoreFoundation CoreMIDI Foundation; };
AudioUnit = { inherit AudioToolbox; };
AudioVideoBridging = { inherit Foundation IOKit; };
AuthenticationServices = { inherit AppKit Foundation; };
AutomaticAssessmentConfiguration = { inherit Foundation; };
Automator = { inherit AppKit Cocoa Foundation OSAKit; };
BackgroundTasks = { inherit Foundation; };
BusinessChat = { inherit Cocoa Foundation; };
CFNetwork = { inherit CoreFoundation; };
CHIP = { inherit Foundation Security; };
CalendarStore = {};
CallKit = { inherit CoreFoundation CoreGraphics Foundation IOKit; };
Carbon = { inherit ApplicationServices CoreServices Foundation Security; };
ClassKit = { inherit CoreGraphics Foundation; };
CloudKit = { inherit CoreFoundation CoreGraphics CoreLocation Foundation IOKit; };
Cocoa = { inherit AppKit CoreData Foundation; };
Collaboration = { inherit AppKit CoreServices Foundation; };
ColorSync = { inherit CoreFoundation; };
Combine = {};
Contacts = { inherit CoreFoundation CoreGraphics Foundation IOKit; };
ContactsUI = { inherit AppKit; };
CoreAudio = { inherit CoreAudioTypes CoreFoundation; };
CoreAudioKit = { inherit AppKit AudioUnit Cocoa Foundation; };
CoreAudioTypes = { inherit CoreFoundation; };
CoreBluetooth = { inherit Foundation; };
CoreData = { inherit Combine CoreFoundation CoreGraphics Foundation IOKit; };
CoreDisplay = {};
CoreFoundation = {};
CoreGraphics = { inherit CoreFoundation IOKit; };
CoreHaptics = { inherit Foundation; };
CoreImage = { inherit ApplicationServices CoreFoundation CoreGraphics CoreVideo Foundation IOKit IOSurface ImageIO Metal OpenGL; };
CoreLocation = { inherit CoreFoundation CoreGraphics Foundation IOKit; };
CoreMIDI = { inherit CoreFoundation CoreGraphics Foundation IOKit; };
CoreMIDIServer = {};
CoreML = { inherit CoreFoundation CoreGraphics CoreVideo Foundation IOKit ImageIO Metal; };
CoreMedia = { inherit CoreAudio CoreAudioTypes CoreFoundation CoreGraphics CoreVideo Foundation IOKit Metal; };
CoreMediaIO = { inherit CoreAudio CoreFoundation CoreGraphics CoreMedia Foundation IOKit Metal; };
CoreMotion = { inherit Foundation; };
CoreServices = { inherit CFNetwork CoreFoundation DiskArbitration Security; };
CoreSpotlight = { inherit Foundation UniformTypeIdentifiers; };
CoreTelephony = {};
CoreText = { inherit CoreFoundation CoreGraphics; };
CoreVideo = { inherit ApplicationServices CoreFoundation CoreGraphics IOSurface Metal OpenGL; };
CoreWLAN = { inherit Foundation IOKit; };
CreateML = { inherit AVFoundation Combine CoreAudio CoreFoundation CoreGraphics CoreImage CoreML CoreMedia CoreServices CoreVideo Foundation IOKit ImageIO Metal MetalPerformanceShaders NaturalLanguage TabularData VideoToolbox Vision simd; };
CryptoKit = { inherit CoreFoundation CoreGraphics Foundation IOKit LocalAuthentication Security; };
CryptoTokenKit = { inherit CoreFoundation CoreGraphics Foundation IOKit Security; };
DVDPlayback = { inherit ApplicationServices CoreFoundation Security; };
DataDetection = { inherit CoreFoundation CoreGraphics Foundation IOKit; };
DeveloperToolsSupport = {};
DeviceActivity = { inherit Foundation ManagedSettings; };
DeviceCheck = { inherit Foundation; };
DirectoryService = { inherit CoreFoundation; };
DiscRecording = { inherit CoreServices Foundation; };
DiscRecordingUI = { inherit Carbon Cocoa DiscRecording; };
DiskArbitration = { inherit CoreFoundation IOKit; };
DriverKit = {};
EventKit = { inherit CoreGraphics CoreLocation Foundation; };
ExceptionHandling = { inherit Foundation; };
ExecutionPolicy = { inherit Foundation; };
ExposureNotification = { inherit Foundation; };
ExternalAccessory = { inherit Foundation; };
FWAUserLib = { inherit IOKit; };
FileProvider = { inherit CoreFoundation CoreGraphics Foundation IOKit; };
FileProviderUI = { inherit AppKit FileProvider Foundation; };
FinderSync = { inherit AppKit Foundation; };
ForceFeedback = { inherit CoreFoundation IOKit; };
Foundation = { inherit Combine CoreFoundation CoreGraphics CoreServices IOKit Security; };
GLKit = { inherit AppKit CoreData CoreFoundation CoreGraphics CoreImage Foundation IOKit Metal ModelIO OpenGL QuartzCore simd; };
GLUT = { inherit OpenGL; };
GSS = { inherit CoreFoundation; };
GameController = { inherit AppKit Foundation IOKit; };
GameKit = { inherit AppKit Cocoa Contacts CoreGraphics Foundation GameController GameplayKit Metal MetalKit ModelIO SceneKit SpriteKit simd; };
GameplayKit = { inherit AppKit CoreData CoreFoundation CoreGraphics CoreImage Foundation GLKit IOKit Metal ModelIO QuartzCore SceneKit SpriteKit simd; };
GroupActivities = { inherit AVFoundation Combine CoreGraphics CryptoKit Foundation Network UniformTypeIdentifiers; };
Hypervisor = {};
ICADevices = { inherit CoreFoundation CoreGraphics CoreServices IOBluetooth; };
IMServicePlugIn = { inherit Foundation; };
IOBluetooth = { inherit CoreAudio CoreFoundation CoreServices Foundation IOKit; };
IOBluetoothUI = { inherit Cocoa IOBluetooth; };
IOKit = { inherit CoreFoundation; };
IOSurface = { inherit CoreFoundation Foundation IOKit; };
IOUSBHost = { inherit Foundation IOKit; };
IdentityLookup = { inherit Foundation; };
ImageCaptureCore = { inherit Cocoa CoreGraphics Foundation; };
ImageIO = { inherit CoreFoundation CoreGraphics; };
InputMethodKit = { inherit Carbon Cocoa Foundation; };
InstallerPlugins = {};
InstantMessage = {};
Intents = { inherit CoreFoundation CoreGraphics CoreLocation Foundation IOKit UserNotifications; };
IntentsUI = { inherit AppKit; };
JavaNativeFoundation = { inherit Foundation; };
JavaRuntimeSupport = { inherit ApplicationServices Cocoa Foundation QuartzCore; };
JavaScriptCore = { inherit CoreFoundation CoreGraphics Foundation; };
Kerberos = {};
Kernel = {};
KernelManagement = { inherit Foundation; };
LDAP = {};
LatentSemanticMapping = { inherit Carbon CoreFoundation; };
LinkPresentation = { inherit AppKit Foundation; };
LocalAuthentication = { inherit Foundation; };
LocalAuthenticationEmbeddedUI = { inherit AppKit Foundation LocalAuthentication; };
MLCompute = { inherit CoreFoundation CoreGraphics Foundation IOKit Metal; };
MailKit = { inherit AppKit Foundation; };
ManagedSettings = { inherit Combine Foundation; };
MapKit = { inherit AppKit CoreData CoreFoundation CoreGraphics CoreImage CoreLocation Foundation IOKit Metal QuartzCore; };
MediaAccessibility = { inherit CoreFoundation CoreGraphics CoreText; };
MediaLibrary = { inherit Foundation; };
MediaPlayer = { inherit AVFoundation CoreGraphics Foundation; };
MediaToolbox = { inherit AudioToolbox CoreFoundation CoreMedia; };
Message = {};
Metal = { inherit CoreFoundation CoreGraphics Foundation IOKit IOSurface; };
MetalKit = { inherit AppKit CoreData CoreFoundation CoreGraphics CoreImage Foundation IOKit Metal ModelIO QuartzCore simd; };
MetalPerformanceShaders = { inherit CoreGraphics Foundation Metal simd; };
MetalPerformanceShadersGraph = { inherit Foundation MetalPerformanceShaders; };
MetricKit = { inherit CoreFoundation CoreGraphics Foundation IOKit; };
ModelIO = { inherit CoreFoundation CoreGraphics Foundation IOKit simd; };
MultipeerConnectivity = { inherit Cocoa Foundation; };
MusicKit = { inherit Combine CoreGraphics Foundation; };
NaturalLanguage = { inherit CoreFoundation CoreGraphics Foundation IOKit; };
NearbyInteraction = { inherit CoreFoundation CoreGraphics Foundation IOKit simd; };
NetFS = { inherit CoreFoundation; };
Network = { inherit CoreFoundation Foundation Security; };
NetworkExtension = { inherit Foundation Network Security; };
NotificationCenter = { inherit AppKit Foundation; };
OSAKit = { inherit Carbon Cocoa; };
OSLog = { inherit CoreFoundation CoreGraphics Foundation IOKit; };
OpenAL = {};
OpenCL = { inherit OpenGL; };
OpenDirectory = { inherit CoreFoundation Foundation; };
OpenGL = {};
PCSC = {};
PDFKit = { inherit AppKit Cocoa; };
PHASE = { inherit AVFAudio AVFoundation CoreAudioTypes Foundation ModelIO simd; };
ParavirtualizedGraphics = { inherit AppKit CoreVideo Foundation IOSurface Metal; };
PassKit = { inherit AppKit Contacts CoreData CoreFoundation CoreGraphics CoreImage Foundation IOKit Metal QuartzCore; };
PencilKit = { inherit AppKit Cocoa CoreData CoreFoundation CoreGraphics CoreImage Foundation IOKit Metal QuartzCore; };
Photos = { inherit AVFoundation CoreAudio CoreFoundation CoreGraphics CoreImage CoreLocation CoreMIDI CoreMedia Foundation IOKit ImageIO Metal QuartzCore UniformTypeIdentifiers simd; };
PhotosUI = { inherit AppKit Foundation MapKit Photos; };
PreferencePanes = { inherit Cocoa; };
PushKit = { inherit Foundation; };
QTKit = {};
Quartz = { inherit AppKit ApplicationServices Cocoa Foundation ImageCaptureCore OpenGL PDFKit QuartzCore QuickLookUI; };
QuartzCore = { inherit CoreFoundation CoreGraphics CoreImage CoreVideo Foundation IOKit Metal OpenGL; };
QuickLook = { inherit ApplicationServices CoreFoundation; };
QuickLookThumbnailing = { inherit CoreGraphics Foundation UniformTypeIdentifiers; };
QuickLookUI = { inherit AppKit CoreData CoreFoundation CoreGraphics CoreImage Foundation IOKit Metal PDFKit QuartzCore QuickLook UniformTypeIdentifiers; };
RealityFoundation = { inherit AVFAudio AVFoundation AppKit AudioToolbox Combine CoreAudio CoreFoundation CoreGraphics CoreMIDI CoreMedia CoreMotion CoreText CoreVideo Foundation IOKit Metal QuartzCore simd; };
RealityKit = { inherit AppKit Combine CoreData CoreFoundation CoreGraphics CoreImage Foundation IOKit Metal MultipeerConnectivity QuartzCore RealityFoundation simd; };
ReplayKit = { inherit AVFoundation AppKit Foundation; };
Ruby = {};
SafariServices = { inherit AppKit CoreData CoreFoundation CoreGraphics CoreImage Foundation IOKit Metal QuartzCore; };
SceneKit = { inherit AppKit CoreData CoreFoundation CoreGraphics CoreImage Foundation GLKit IOKit Metal ModelIO QuartzCore simd; };
ScreenCaptureKit = { inherit AppKit CoreGraphics CoreMedia Foundation; };
ScreenSaver = { inherit AppKit Foundation; };
ScreenTime = { inherit AppKit Foundation; };
ScriptingBridge = { inherit ApplicationServices CoreServices Foundation; };
Security = { inherit CoreFoundation; };
SecurityFoundation = { inherit Foundation Security; };
SecurityInterface = { inherit AppKit Cocoa Security SecurityFoundation; };
SensorKit = { inherit CoreFoundation CoreLocation Foundation; };
ServiceManagement = { inherit CoreFoundation Security; };
ShazamKit = { inherit AVFAudio CoreAudio CoreFoundation CoreGraphics CoreMIDI CoreMedia Foundation IOKit Metal MusicKit; };
Social = { inherit AppKit Foundation; };
SoundAnalysis = { inherit AVFoundation CoreAudio CoreFoundation CoreGraphics CoreImage CoreMIDI CoreML CoreMedia Foundation IOKit Metal QuartzCore UniformTypeIdentifiers simd; };
Speech = { inherit AVFoundation CoreAudio CoreFoundation CoreGraphics CoreImage CoreMIDI CoreMedia Foundation IOKit Metal QuartzCore UniformTypeIdentifiers simd; };
SpriteKit = { inherit AppKit Cocoa CoreData CoreFoundation CoreGraphics CoreImage Foundation GLKit IOKit Metal ModelIO QuartzCore simd; };
StoreKit = { inherit AppKit CoreData CoreFoundation CoreGraphics CoreImage CryptoKit Foundation IOKit Metal QuartzCore Security; };
SwiftUI = { inherit Accessibility AppKit Combine CoreData CoreFoundation CoreGraphics CoreImage DeveloperToolsSupport Foundation IOKit Metal QuartzCore UniformTypeIdentifiers; };
SyncServices = {};
System = {};
SystemConfiguration = { inherit CoreFoundation Security; };
SystemExtensions = { inherit Foundation; };
TWAIN = {};
TabularData = { inherit Combine Foundation; };
Tcl = {};
Tk = {};
UniformTypeIdentifiers = { inherit CoreFoundation CoreGraphics Foundation IOKit; };
UserNotifications = { inherit Foundation; };
UserNotificationsUI = { inherit AppKit; };
VideoDecodeAcceleration = {};
VideoSubscriberAccount = { inherit Foundation; };
VideoToolbox = { inherit CoreFoundation CoreGraphics CoreMedia CoreVideo; };
Virtualization = { inherit AppKit Cocoa CoreData CoreFoundation CoreGraphics CoreImage Foundation IOKit Metal QuartzCore; };
Vision = { inherit CoreAudio CoreFoundation CoreGraphics CoreML CoreMedia CoreVideo Foundation IOKit ImageIO Metal simd; };
WebKit = { inherit AppKit CoreData CoreFoundation CoreGraphics CoreImage Foundation IOKit JavaScriptCore Metal QuartzCore; };
WidgetKit = { inherit Combine CoreFoundation CoreGraphics Foundation IOKit Intents SwiftUI UniformTypeIdentifiers; };
iTunesLibrary = { inherit Foundation; };
vmnet = {};
}

View File

@ -1,96 +0,0 @@
{
stdenvNoCC,
buildPackages,
darwin-stubs,
}:
stdenvNoCC.mkDerivation {
pname = "libSystem";
inherit (darwin-stubs) version;
nativeBuildInputs = [ buildPackages.darwin.rewrite-tbd ];
csu = [
"bundle1.o"
"crt0.o"
"crt1.10.5.o"
"crt1.10.6.o"
"crt1.o"
"dylib1.10.5.o"
"dylib1.o"
"gcrt1.o"
"lazydylib1.o"
];
buildCommand =
''
mkdir -p $out/{include,lib/swift}
''
# Copy each directory in ${darwin-stubs}/usr/include into $out/include
+ ''
for dir in $(ls -d ${darwin-stubs}/usr/include/*/); do
cp -dr $dir $out/include
done
''
# Copy each header and modulemap file in ${darwin-stubs}/usr/include into $out/include
+ ''
cp -d \
${darwin-stubs}/usr/include/*.h \
${darwin-stubs}/usr/include/*.modulemap \
$out/include
''
# Remove curses.h, ncurses.h, ncurses_dll.h, and unctrl.h which conflict with ncurses.
# Then, remove the module map for ncurses.
# NOTE: The sed expression expects the module map to use consistent indentation across
# releases. If this changes, the sed expression will need to be updated.
#
# For example, right now we assume that there is one leading space before the
# "explicit" keyword and that the closing brace is on its own line (also with one
# leading space).
+ ''
rm $out/include/{curses,ncurses,ncurses_dll,unctrl}.h
sed -i -e '/^ explicit module ncurses {/,/^ }$/d' $out/include/module.modulemap
''
+ ''
rm $out/include/tk*.h $out/include/tcl*.h
cp -dr \
${darwin-stubs}/usr/lib/libSystem.* \
${darwin-stubs}/usr/lib/system \
$out/lib
# Extra libraries
for name in c dbm dl info m mx poll proc pthread rpcsvc util gcc_s.1 resolv; do
cp -d \
${darwin-stubs}/usr/lib/lib$name.tbd \
${darwin-stubs}/usr/lib/lib$name.*.tbd \
$out/lib
done
for name in os Dispatch; do
cp -dr \
${darwin-stubs}/usr/lib/swift/$name.swiftmodule \
${darwin-stubs}/usr/lib/swift/libswift$name.tbd \
$out/lib/swift
done
for f in $csu; do
from=${darwin-stubs}/usr/lib/$f
if [ -e "$from" ]; then
cp -d $from $out/lib
else
echo "Csu file '$from' doesn't exist: skipping"
fi
done
chmod u+w -R $out/lib
find $out -name '*.tbd' -type f | while read tbd; do
rewrite-tbd \
-c /usr/lib/libsystem.dylib:$out/lib/libsystem.dylib \
-p /usr/lib/system/:$out/lib/system/ \
-p /usr/lib/swift/:$out/lib/swift/ \
-r ${builtins.storeDir} \
"$tbd"
done
'';
}

View File

@ -1,16 +0,0 @@
{ stdenvNoCC, darwin-stubs }:
let
self = stdenvNoCC.mkDerivation {
pname = "libnetwork";
inherit (darwin-stubs) version;
buildCommand = ''
mkdir -p $out/lib
cp ${darwin-stubs}/usr/lib/libnetwork* $out/lib
'';
passthru.tbdRewrites.const."/usr/lib/libnetwork.dylib" = "${self}/lib/libnetwork.dylib";
};
in
self

View File

@ -1,22 +0,0 @@
{ stdenvNoCC, darwin-stubs }:
let
self = stdenvNoCC.mkDerivation {
pname = "libobjc";
inherit (darwin-stubs) version;
buildCommand = ''
mkdir -p $out/{include,lib/swift}
cp -r ${darwin-stubs}/usr/include/objc $out/include
cp ${darwin-stubs}/usr/lib/libobjc* $out/lib
cp -r ${darwin-stubs}/usr/lib/swift/ObjectiveC.swiftmodule $out/lib/swift
cp ${darwin-stubs}/usr/lib/swift/libswiftObjectiveC.tbd $out/lib/swift
'';
passthru.tbdRewrites = {
const."/usr/lib/libobjc.A.dylib" = "${self}/lib/libobjc.A.dylib";
const."/usr/lib/swift/libswiftObjectiveC.dylib" = "${self}/lib/swift/libswiftObjectiveC.dylib";
};
};
in
self

View File

@ -1,25 +0,0 @@
{
stdenvNoCC,
buildPackages,
darwin-stubs,
}:
stdenvNoCC.mkDerivation {
pname = "libpm";
inherit (darwin-stubs) version;
dontUnpack = true;
dontBuild = true;
nativeBuildInputs = [ buildPackages.darwin.checkReexportsHook ];
installPhase = ''
mkdir -p $out/lib
cp ${darwin-stubs}/usr/lib/libpm* $out/lib
'';
passthru.tbdRewrites = {
const."/usr/lib/libpmenergy.dylib" = "${placeholder "out"}/lib/libpmenergy.dylib";
const."/usr/lib/libpmsample.dylib" = "${placeholder "out"}/lib/libpmsample.dylib";
};
}

View File

@ -1,30 +0,0 @@
{
frameworks,
darwin-stubs,
stdenvNoCC,
}:
stdenvNoCC.mkDerivation {
pname = "apple-lib-Xplugin";
inherit (darwin-stubs) version;
dontUnpack = true;
dontBuild = true;
propagatedBuildInputs = with frameworks; [
OpenGL
ApplicationServices
Carbon
IOKit
CoreGraphics
CoreServices
CoreText
];
installPhase = ''
mkdir -p $out/include $out/lib
cp "${darwin-stubs}/include/Xplugin.h" $out/include/Xplugin.h
cp ${darwin-stubs}/usr/lib/libXplugin.1.tbd $out/lib
ln -s libXplugin.1.tbd $out/lib/libXplugin.tbd
'';
}

View File

@ -1,10 +0,0 @@
{ callPackage }:
{
libDER = callPackage ./libDER.nix { };
sandbox = callPackage ./sandbox.nix { };
simd = callPackage ./simd.nix { };
utmp = callPackage ./utmp.nix { };
xpc = callPackage ./xpc.nix { };
Xplugin = callPackage ./Xplugin.nix { };
}

View File

@ -1,11 +0,0 @@
{ darwin-stubs, stdenvNoCC }:
stdenvNoCC.mkDerivation {
pname = "apple-lib-libDER";
inherit (darwin-stubs) version;
buildCommand = ''
mkdir -p $out/include
cp -r ${darwin-stubs}/usr/include/libDER $out/include
'';
}

View File

@ -1,13 +0,0 @@
{ darwin-stubs, stdenvNoCC }:
stdenvNoCC.mkDerivation {
pname = "apple-lib-sandbox";
inherit (darwin-stubs) version;
buildCommand = ''
mkdir -p $out/include $out/lib
cp "${darwin-stubs}/usr/include/sandbox.h" $out/include/sandbox.h
cp "${darwin-stubs}/usr/lib/libsandbox.1.tbd" $out/lib
ln -s libsandbox.1.tbd $out/lib/libsandbox.tbd
'';
}

View File

@ -1,11 +0,0 @@
{ darwin-stubs, stdenvNoCC }:
stdenvNoCC.mkDerivation {
pname = "apple-lib-simd";
inherit (darwin-stubs) version;
buildCommand = ''
mkdir -p $out/include
cp -r ${darwin-stubs}/usr/include/simd $out/include
'';
}

View File

@ -1,12 +0,0 @@
{ darwin-stubs, stdenvNoCC }:
stdenvNoCC.mkDerivation {
pname = "apple-lib-utmp";
inherit (darwin-stubs) version;
buildCommand = ''
mkdir -p $out/include
cp "${darwin-stubs}/include/utmp.h" $out/include
cp "${darwin-stubs}/include/utmpx.h" $out/include
'';
}

View File

@ -1,12 +0,0 @@
{ darwin-stubs, stdenvNoCC }:
stdenvNoCC.mkDerivation {
pname = "apple-lib-xpc";
inherit (darwin-stubs) version;
buildCommand = ''
mkdir -p $out/include
cp -r "${darwin-stubs}/usr/include/xpc" $out/include/xpc
cp "${darwin-stubs}/usr/include/launch.h" $out/include/launch.h
'';
}

View File

@ -1,28 +0,0 @@
{
stdenvNoCC,
buildPackages,
darwin-stubs,
}:
stdenvNoCC.mkDerivation {
pname = "libunwind";
inherit (darwin-stubs) version;
dontUnpack = true;
dontBuild = true;
nativeBuildInputs = [ buildPackages.darwin.checkReexportsHook ];
installPhase = ''
mkdir -p $out/include/mach-o
cp \
${darwin-stubs}/usr/include/libunwind.h \
${darwin-stubs}/usr/include/unwind.h \
$out/include
cp \
${darwin-stubs}/usr/include/mach-o/compact_unwind_encoding.h \
$out/include/mach-o
'';
}

View File

@ -1,9 +0,0 @@
linkSystemCoreFoundationFramework() {
NIX_CFLAGS_COMPILE="-F@out@/Library/Frameworks${NIX_CFLAGS_COMPILE:+ }${NIX_CFLAGS_COMPILE-}"
# gross! many symbols (such as _OBJC_CLASS_$_NSArray) are defined in system CF, but not
# in the opensource release
# if the package needs private headers, we assume they also want to link with system CF
NIX_LDFLAGS+=" @out@/Library/Frameworks/CoreFoundation.framework/CoreFoundation.tbd"
}
preConfigureHooks+=(linkSystemCoreFoundationFramework)

View File

@ -1,360 +1,272 @@
{ stdenv, stdenvNoCC, fetchurl, cpio, pbzx, pkgs, lib, darwin-stubs, print-reexports }:
# Compatibility stubs for packages that used the old SDK frameworks.
# TODO(@reckenrode) Make these stubs warn after framework usage has been cleaned up in nixpkgs.
{ lib, callPackage }:
let
# sadly needs to be exported because security_tool needs it
sdk = stdenv.mkDerivation rec {
pname = "MacOS_SDK";
version = "10.12";
mkStub = callPackage ./mk-stub.nix { } "10.12";
# This URL comes from https://swscan.apple.com/content/catalogs/others/index-10.12.merged-1.sucatalog, which we found by:
# 1. Google: site:swscan.apple.com and look for a name that seems appropriate for your version
# 2. In the resulting file, search for a file called DevSDK ending in .pkg
# 3. ???
# 4. Profit
src = fetchurl {
url = "http://swcdn.apple.com/content/downloads/33/36/041-90419-A_7JJ4H9ZHO2/xs88ob5wjz6riz7g6764twblnvksusg4ps/DevSDK_OSX1012.pkg";
sha256 = "13xq34sb7383b37hwy076gnhf96prpk1b4087p87xnwswxbrisih";
};
nativeBuildInputs = [ cpio pbzx ];
outputs = [ "out" "dev" "man" ];
unpackPhase = ''
pbzx $src | cpio -idm
'';
sourceRoot = ".";
installPhase = ''
mkdir -p $out
cp -R System/Library $out
cp -R usr/* $out
pushd $out/lib
cp ${darwin-stubs}/usr/lib/libcups*.tbd .
ln -s libcups.2.tbd libcups.tbd
ln -s libcupscgi.1.tbd libcupscgi.tbd
ln -s libcupsimage.2.tbd libcupsimage.tbd
ln -s libcupsmime.1.tbd libcupsmime.tbd
ln -s libcupsppdc.1.tbd libcupsppdc.tbd
popd
'';
meta = with lib; {
description = "Apple SDK ${version}";
maintainers = with maintainers; [ copumpkin ];
platforms = platforms.darwin;
};
};
mkFrameworkSubs = name: deps:
let
deps' = deps // { "${name}" = placeholder "out"; };
substArgs = lib.concatMap (x: [ "--subst-var-by" x deps'."${x}" ]) (lib.attrNames deps');
in lib.escapeShellArgs substArgs;
framework = name: deps: stdenv.mkDerivation {
name = "apple-framework-${name}";
dontUnpack = true;
# because we copy files from the system
preferLocalBuild = true;
disallowedRequisites = [ sdk ];
nativeBuildInputs = [ print-reexports ];
extraTBDFiles = [];
installPhase = ''
linkFramework() {
local path="$1"
local nested_path="$1"
if [ "$path" == "JavaNativeFoundation.framework" ]; then
local nested_path="JavaVM.framework/Versions/A/Frameworks/JavaNativeFoundation.framework"
fi
if [ "$path" == "JavaRuntimeSupport.framework" ]; then
local nested_path="JavaVM.framework/Versions/A/Frameworks/JavaRuntimeSupport.framework"
fi
local name="$(basename "$path" .framework)"
local current="$(readlink "/System/Library/Frameworks/$nested_path/Versions/Current")"
if [ -z "$current" ]; then
current=A
fi
local dest="$out/Library/Frameworks/$path"
mkdir -p "$dest/Versions/$current"
pushd "$dest/Versions/$current" >/dev/null
if [ -d "${sdk.out}/Library/Frameworks/$nested_path/Versions/$current/Headers" ]; then
cp -R "${sdk.out}/Library/Frameworks/$nested_path/Versions/$current/Headers" .
elif [ -d "${sdk.out}/Library/Frameworks/$name.framework/Versions/$current/Headers" ]; then
current="$(readlink "/System/Library/Frameworks/$name.framework/Versions/Current")"
cp -R "${sdk.out}/Library/Frameworks/$name.framework/Versions/$current/Headers" .
fi
local tbd_source=${darwin-stubs}/System/Library/Frameworks/$nested_path/Versions/$current
if [ "${name}" != "Kernel" ]; then
# The Kernel.framework has headers but no actual library component.
cp -v $tbd_source/*.tbd .
fi
if [ -d "$tbd_source/Libraries" ]; then
mkdir Libraries
cp -v $tbd_source/Libraries/*.tbd Libraries/
fi
ln -s -L "/System/Library/Frameworks/$nested_path/Versions/$current/Resources"
if [ -f "/System/Library/Frameworks/$nested_path/module.map" ]; then
ln -s "/System/Library/Frameworks/$nested_path/module.map"
fi
pushd "${sdk.out}/Library/Frameworks/$nested_path/Versions/$current" >/dev/null
local children=$(echo Frameworks/*.framework)
popd >/dev/null
for child in $children; do
childpath="$path/Versions/$current/$child"
linkFramework "$childpath"
done
pushd ../.. >/dev/null
ln -s "$current" Versions/Current
ln -s Versions/Current/* .
popd >/dev/null
popd >/dev/null
}
linkFramework "${name}.framework"
# linkFramework is recursive, the rest of the processing is not.
local tbd_source=${darwin-stubs}/System/Library/Frameworks/${name}.framework
for tbd in $extraTBDFiles; do
local tbd_dest_dir=$out/Library/Frameworks/${name}.framework/$(dirname "$tbd")
mkdir -p "$tbd_dest_dir"
cp -v "$tbd_source/$tbd" "$tbd_dest_dir"
done
# Fix and check tbd re-export references
find $out -name '*.tbd' | while read tbd; do
echo "Fixing re-exports in $tbd"
substituteInPlace "$tbd" ${mkFrameworkSubs name deps}
echo "Checking re-exports in $tbd"
print-reexports "$tbd" | while read target; do
local expected="''${target%.dylib}.tbd"
if ! [ -e "$expected" ]; then
echo -e "Re-export missing:\n\t$target\n\t(expected $expected)"
echo -e "While processing\n\t$tbd"
exit 1
else
echo "Re-exported target $target ok"
fi
done
done
'';
propagatedBuildInputs = builtins.attrValues deps;
meta = with lib; {
description = "Apple SDK framework ${name}";
maintainers = with maintainers; [ copumpkin ];
platforms = platforms.darwin;
};
};
tbdOnlyFramework = name: { private ? true }: stdenv.mkDerivation {
name = "apple-framework-${name}";
dontUnpack = true;
installPhase = ''
mkdir -p $out/Library/Frameworks/
cp -r ${darwin-stubs}/System/Library/${lib.optionalString private "Private"}Frameworks/${name}.framework \
$out/Library/Frameworks
cd $out/Library/Frameworks/${name}.framework
versions=(./Versions/*)
if [ "''${#versions[@]}" != 1 ]; then
echo "Unable to determine current version of framework ${name}"
exit 1
fi
current=$(basename ''${versions[0]})
chmod u+w -R .
ln -s "$current" Versions/Current
ln -s Versions/Current/* .
# NOTE there's no re-export checking here, this is probably wrong
'';
};
in rec {
libs = {
xpc = stdenv.mkDerivation {
name = "apple-lib-xpc";
dontUnpack = true;
installPhase = ''
mkdir -p $out/include
pushd $out/include >/dev/null
cp -r "${lib.getDev sdk}/include/xpc" $out/include/xpc
cp "${lib.getDev sdk}/include/launch.h" $out/include/launch.h
popd >/dev/null
'';
};
Xplugin = stdenv.mkDerivation {
name = "apple-lib-Xplugin";
dontUnpack = true;
# Not enough
__propagatedImpureHostDeps = [ "/usr/lib/libXplugin.1.dylib" ];
propagatedBuildInputs = with frameworks; [
OpenGL ApplicationServices Carbon IOKit CoreGraphics CoreServices CoreText
];
installPhase = ''
mkdir -p $out/include $out/lib
ln -s "${lib.getDev sdk}/include/Xplugin.h" $out/include/Xplugin.h
cp ${darwin-stubs}/usr/lib/libXplugin.1.tbd $out/lib
ln -s libXplugin.1.tbd $out/lib/libXplugin.tbd
'';
};
utmp = stdenv.mkDerivation {
name = "apple-lib-utmp";
dontUnpack = true;
installPhase = ''
mkdir -p $out/include
pushd $out/include >/dev/null
ln -s "${lib.getDev sdk}/include/utmp.h"
ln -s "${lib.getDev sdk}/include/utmpx.h"
popd >/dev/null
'';
};
sandbox = stdenv.mkDerivation {
name = "apple-lib-sandbox";
dontUnpack = true;
installPhase = ''
mkdir -p $out/include $out/lib
ln -s "${lib.getDev sdk}/include/sandbox.h" $out/include/sandbox.h
cp "${darwin-stubs}/usr/lib/libsandbox.1.tbd" $out/lib
ln -s libsandbox.1.tbd $out/lib/libsandbox.tbd
'';
};
simd = stdenvNoCC.mkDerivation {
name = "apple-lib-simd";
preferLocalBuild = true;
allowSubstitutes = false;
buildCommand = "echo 'simd library not available in the 10.12 SDK'; exit 1";
};
};
overrides = super: {
AppKit = lib.overrideDerivation super.AppKit (drv: {
__propagatedImpureHostDeps = drv.__propagatedImpureHostDeps or [] ++ [
"/System/Library/PrivateFrameworks/"
];
});
Carbon = lib.overrideDerivation super.Carbon (drv: {
extraTBDFiles = [ "Versions/A/Frameworks/HTMLRendering.framework/Versions/A/HTMLRendering.tbd" ];
});
CoreFoundation = lib.overrideDerivation super.CoreFoundation (drv: {
setupHook = ./cf-setup-hook.sh;
});
CoreMedia = lib.overrideDerivation super.CoreMedia (drv: {
__propagatedImpureHostDeps = drv.__propagatedImpureHostDeps or [] ++ [
"/System/Library/Frameworks/CoreImage.framework"
];
});
CoreMIDI = lib.overrideDerivation super.CoreMIDI (drv: {
__propagatedImpureHostDeps = drv.__propagatedImpureHostDeps or [] ++ [
"/System/Library/PrivateFrameworks/"
];
setupHook = ./private-frameworks-setup-hook.sh;
});
IMServicePlugIn = lib.overrideDerivation super.IMServicePlugIn (drv: {
extraTBDFiles = [ "Versions/A/Frameworks/IMServicePlugInSupport.framework/Versions/A/IMServicePlugInSupport.tbd" ];
});
Security = lib.overrideDerivation super.Security (drv: {
setupHook = ./security-setup-hook.sh;
});
QuartzCore = lib.overrideDerivation super.QuartzCore (drv: {
installPhase = drv.installPhase + ''
f="$out/Library/Frameworks/QuartzCore.framework/Headers/CoreImage.h"
substituteInPlace "$f" \
--replace "QuartzCore/../Frameworks/CoreImage.framework/Headers" "CoreImage"
'';
});
MetalKit = lib.overrideDerivation super.MetalKit (drv: {
installPhase = drv.installPhase + ''
mkdir -p $out/include/simd
cp ${lib.getDev sdk}/include/simd/*.h $out/include/simd/
'';
});
System = lib.overrideDerivation super.System (drv: {
installPhase = ''
mkdir -p $out/Library/Frameworks/System.framework/Versions/B
ln -s $out/Library/Frameworks/System.framework/Versions/{B,Current}
ln -s ${pkgs.darwin.Libsystem}/lib/libSystem.B.tbd $out/Library/Frameworks/System.framework/Versions/B/System.tbd
ln -s $out/Library/Frameworks/System.framework/{Versions/Current/,}System.tbd
'';
});
WebKit = lib.overrideDerivation super.WebKit (drv: {
extraTBDFiles = [
"Versions/A/Frameworks/WebCore.framework/Versions/A/WebCore.tbd"
"Versions/A/Frameworks/WebKitLegacy.framework/Versions/A/WebKitLegacy.tbd"
];
});
} // lib.genAttrs [
frameworks = lib.genAttrs [
"AGL"
"AVFoundation"
"AVKit"
"Accelerate"
"Accounts"
"AddressBook"
"AppKit"
"AppKitScripting"
"AppleScriptKit"
"AppleScriptObjC"
"ApplicationServices"
"AudioToolbox"
"AudioUnit"
"AudioVideoBridging"
"Automator"
"CFNetwork"
"CalendarStore"
"Carbon"
"Cocoa"
"Collaboration"
"ContactsPersistence"
"CoreAudio"
"CoreAudioKit"
"CoreBluetooth"
"CoreData"
"CoreFoundation"
"CoreGraphics"
"CoreImage"
"CoreLocation"
"CoreMIDI"
"CoreMIDIServer"
"CoreMedia"
"CoreMediaIO"
"CoreServices"
"CoreSymbolication"
"CoreText"
"CoreVideo"
"CoreWLAN"
"DVDPlayback"
"DebugSymbols"
"DirectoryService"
"DiscRecording"
"DiscRecordingUI"
"DiskArbitration"
"DisplayServices"
"EventKit"
"ExceptionHandling"
"FWAUserLib"
"ForceFeedback"
"Foundation"
"GLKit"
"GLUT"
"GSS"
"GameCenter"
"GameController"
"GameKit"
"GameplayKit"
"Hypervisor"
"ICADevices"
"IMServicePlugIn"
"IOBluetooth"
"IOBluetoothUI"
"IOKit"
"IOSurface"
"ImageCaptureCore"
"ImageIO"
"InputMethodKit"
"InstallerPlugins"
"InstantMessage"
"JavaFrameEmbedding"
"JavaNativeFoundation"
"JavaRuntimeSupport"
"JavaScriptCore"
"JavaVM"
"Kerberos"
"Kernel"
"LDAP"
"LatentSemanticMapping"
"LocalAuthentication"
"MapKit"
"MediaAccessibility"
"MediaPlayer"
"MediaToolbox"
"Metal"
"MetalKit"
"ModelIO"
"MultitouchSupport"
"NetFS"
"OSAKit"
"OpenAL"
"OpenCL"
"OpenDirectory"
"OpenGL"
"PCSC"
"PreferencePanes"
"PubSub"
"QTKit"
"Quartz"
"QuartzCore"
"QuickLook"
"QuickTime"
"SceneKit"
"ScreenSaver"
"Scripting"
"ScriptingBridge"
"Security"
"SecurityFoundation"
"SecurityInterface"
"ServiceManagement"
"SkyLight"
"Social"
"SpriteKit"
"StoreKit"
"SyncServices"
"System"
"SystemConfiguration"
"TWAIN"
"Tcl"
"UIFoundation"
]
(x: tbdOnlyFramework x {});
"VideoDecodeAcceleration"
"VideoToolbox"
"WebKit"
"vmnet"
] mkStub;
bareFrameworks = lib.mapAttrs framework (import ./frameworks.nix {
inherit frameworks libs;
inherit (pkgs.darwin) libobjc;
});
bareFrameworks = lib.genAttrs [
"AGL"
"AVFoundation"
"AVKit"
"Accelerate"
"Accounts"
"AddressBook"
"AppKit"
"AppKitScripting"
"AppleScriptKit"
"AppleScriptObjC"
"ApplicationServices"
"AudioToolbox"
"AudioUnit"
"AudioVideoBridging"
"Automator"
"CFNetwork"
"CalendarStore"
"Carbon"
"Cocoa"
"Collaboration"
"CoreAudio"
"CoreAudioKit"
"CoreBluetooth"
"CoreData"
"CoreFoundation"
"CoreGraphics"
"CoreImage"
"CoreLocation"
"CoreMIDI"
"CoreMIDIServer"
"CoreMedia"
"CoreMediaIO"
"CoreServices"
"CoreText"
"CoreVideo"
"CoreWLAN"
"DVDPlayback"
"DirectoryService"
"DiscRecording"
"DiscRecordingUI"
"DiskArbitration"
"EventKit"
"ExceptionHandling"
"FWAUserLib"
"ForceFeedback"
"Foundation"
"GLKit"
"GLUT"
"GSS"
"GameCenter"
"GameController"
"GameKit"
"GameplayKit"
"Hypervisor"
"ICADevices"
"IMServicePlugIn"
"IOBluetooth"
"IOBluetoothUI"
"IOKit"
"IOSurface"
"ImageCaptureCore"
"ImageIO"
"InputMethodKit"
"InstallerPlugins"
"InstantMessage"
"JavaFrameEmbedding"
"JavaNativeFoundation"
"JavaRuntimeSupport"
"JavaScriptCore"
"JavaVM"
"Kerberos"
"Kernel"
"LDAP"
"LatentSemanticMapping"
"LocalAuthentication"
"MapKit"
"MediaAccessibility"
"MediaPlayer"
"MediaToolbox"
"Metal"
"MetalKit"
"ModelIO"
"NetFS"
"OSAKit"
"OpenAL"
"OpenCL"
"OpenDirectory"
"OpenGL"
"PCSC"
"PreferencePanes"
"PubSub"
"QTKit"
"Quartz"
"QuartzCore"
"QuickLook"
"QuickTime"
"SceneKit"
"ScreenSaver"
"Scripting"
"ScriptingBridge"
"Security"
"SecurityFoundation"
"SecurityInterface"
"ServiceManagement"
"Social"
"SpriteKit"
"StoreKit"
"SyncServices"
"System"
"SystemConfiguration"
"TWAIN"
"Tcl"
"VideoDecodeAcceleration"
"VideoToolbox"
"WebKit"
"vmnet"
] mkStub;
in
{
inherit bareFrameworks frameworks;
frameworks = bareFrameworks // overrides bareFrameworks;
libs = lib.genAttrs [
"Xplugin"
"sandbox"
"simd"
"utmp"
"xpc"
] mkStub;
inherit darwin-stubs;
objc4 = pkgs.darwin.libobjc;
sdkRoot = pkgs.callPackage ./sdkRoot.nix { sdkVersion = "10.12.4"; };
inherit (pkgs.darwin) Libsystem;
inherit sdk;
version = "10.12";
}
// lib.genAttrs [
"darwin-stubs"
"Libsystem"
"objc4"
"sdk"
"sdkRoot"
] mkStub

View File

@ -1,130 +0,0 @@
# Current as of 10.12
# Epic weird knot-tying happening here.
# TODO: clean up the process for generating this and include it
{ frameworks, libs, libobjc, }:
with frameworks; with libs; {
AGL = { inherit Carbon OpenGL; };
AVFoundation = { inherit ApplicationServices CoreGraphics CoreMedia MediaToolbox; };
AVKit = {};
Accounts = {};
AddressBook = { inherit libobjc Carbon ContactsPersistence; };
AppKit = { inherit ApplicationServices AudioToolbox AudioUnit Foundation QuartzCore UIFoundation; };
AppKitScripting = {};
AppleScriptKit = {};
AppleScriptObjC = {};
AudioToolbox = { inherit CoreAudio CoreMIDI; };
AudioUnit = { inherit AudioToolbox Carbon CoreAudio; };
AudioVideoBridging = { inherit Foundation; };
Automator = {};
CFNetwork = {};
CalendarStore = {};
Cocoa = { inherit AppKit CoreData; };
Collaboration = {};
# Impure version of CoreFoundation, this should not be used unless another
# framework includes headers that are not available in the pure version.
CoreFoundation = {};
CoreAudio = { inherit IOKit; };
CoreAudioKit = { inherit AudioUnit; };
CoreData = {};
CoreGraphics = { inherit Accelerate IOKit IOSurface SystemConfiguration; };
CoreImage = {};
CoreLocation = {};
CoreMIDI = {};
CoreMIDIServer = { inherit CoreMIDI; };
CoreMedia = { inherit ApplicationServices AudioToolbox AudioUnit CoreAudio CoreGraphics CoreVideo; };
CoreMediaIO = { inherit CoreMedia; };
CoreText = { inherit CoreGraphics; };
CoreVideo = { inherit ApplicationServices CoreGraphics IOSurface OpenGL; };
CoreWLAN = { inherit SecurityFoundation; };
DVDPlayback = {};
DirectoryService = {};
DiscRecording = { inherit libobjc CoreServices IOKit; };
DiscRecordingUI = {};
DiskArbitration = { inherit IOKit; };
EventKit = {};
ExceptionHandling = {};
FWAUserLib = {};
ForceFeedback = { inherit IOKit; };
Foundation = { inherit libobjc CoreFoundation Security ApplicationServices SystemConfiguration; };
GLKit = {};
GLUT = { inherit OpenGL; };
GSS = {};
GameCenter = {};
GameController = {};
GameKit = { inherit Cocoa Foundation GameCenter GameController GameplayKit Metal MetalKit ModelIO SceneKit SpriteKit; };
GameplayKit = {};
Hypervisor = {};
ICADevices = { inherit libobjc Carbon IOBluetooth; };
IMServicePlugIn = {};
IOBluetoothUI = { inherit IOBluetooth; };
IOKit = {};
IOSurface = { inherit IOKit xpc; };
ImageCaptureCore = {};
ImageIO = { inherit CoreGraphics; };
InputMethodKit = { inherit Carbon; };
InstallerPlugins = {};
InstantMessage = {};
JavaFrameEmbedding = {};
JavaNativeFoundation = {};
JavaRuntimeSupport = {};
JavaScriptCore = { inherit libobjc; };
Kerberos = {};
Kernel = { inherit IOKit; };
LDAP = {};
LatentSemanticMapping = { inherit Carbon; };
LocalAuthentication = {};
MapKit = {};
MediaAccessibility = { inherit CoreGraphics CoreText QuartzCore; };
MediaPlayer = {};
MediaToolbox = { inherit AudioToolbox AudioUnit CoreMedia; };
Metal = {};
MetalKit = { inherit ModelIO Metal; };
ModelIO = {};
NetFS = {};
OSAKit = { inherit Carbon; };
OpenAL = {};
OpenCL = { inherit IOSurface OpenGL; };
OpenGL = {};
PCSC = { inherit CoreData; };
PreferencePanes = {};
PubSub = {};
QTKit = { inherit CoreMediaIO CoreMedia MediaToolbox QuickTime VideoToolbox; };
QuickLook = { inherit ApplicationServices; };
SceneKit = {};
ScreenSaver = {};
Scripting = {};
ScriptingBridge = {};
Security = { inherit IOKit; };
SecurityFoundation = {};
SecurityInterface = { inherit Security SecurityFoundation; };
ServiceManagement = { inherit Security; };
Social = {};
SpriteKit = {};
StoreKit = {};
SyncServices = {};
System = {};
SystemConfiguration = { inherit Security; };
TWAIN = { inherit Carbon; };
Tcl = {};
VideoDecodeAcceleration = { inherit CoreVideo; };
VideoToolbox = { inherit CoreMedia CoreVideo; };
WebKit = { inherit libobjc ApplicationServices Carbon JavaScriptCore OpenGL; };
# Umbrellas
Accelerate = { inherit CoreWLAN IOBluetooth; };
ApplicationServices = { inherit CoreGraphics CoreServices CoreText ImageIO; };
Carbon = { inherit libobjc ApplicationServices CoreServices Foundation IOKit Security QuartzCore; };
CoreBluetooth = {};
# TODO: figure out which part of the umbrella depends on CoreFoundation and move it there.
CoreServices = { inherit CFNetwork CoreFoundation CoreAudio CoreData DiskArbitration Security NetFS OpenDirectory ServiceManagement; };
IOBluetooth = { inherit CoreBluetooth IOKit; };
JavaVM = {};
OpenDirectory = {};
Quartz = { inherit QuartzCore QuickLook QTKit; };
QuartzCore = { inherit libobjc ApplicationServices CoreVideo OpenCL CoreImage Metal; };
QuickTime = { inherit ApplicationServices AudioUnit Carbon CoreAudio CoreServices OpenGL QuartzCore; };
vmnet = {};
}

View File

@ -1,256 +0,0 @@
rec {
CFNetwork = [
"/System/Library/Frameworks/CFNetwork.framework"
"/usr/lib/libsqlite3.dylib"
"/usr/lib/libxml2.2.dylib"
];
ForceFeedback = [
"/System/Library/Frameworks/ForceFeedback.framework"
];
AGL = [
"/System/Library/Frameworks/AGL.framework"
];
IOKit = [
"/System/Library/Frameworks/IOKit.framework"
];
JavaScriptCore = [
"/System/Library/Frameworks/JavaScriptCore.framework"
];
QuickLook = [
"/System/Library/Frameworks/QuickLook.framework"
];
Quartz = [
"/System/Library/Frameworks/Quartz.framework"
"/System/Library/PrivateFrameworks/AppleSystemInfo.framework/Versions/A/AppleSystemInfo"
"/System/Library/PrivateFrameworks/CorePDF.framework/Versions/A/CorePDF"
"/usr/lib/libspindump.dylib"
];
ImageCaptureCore = [
"/System/Library/Frameworks/ImageCaptureCore.framework"
];
VideoToolbox = [
"/System/Library/Frameworks/VideoToolbox.framework"
"/System/Library/PrivateFrameworks/AppleVA.framework/Versions/A/AppleVA"
];
QuickTime = [
"/System/Library/Frameworks/QuickTime.framework"
];
CoreMedia = [
"/System/Library/Frameworks/CoreMedia.framework"
];
CoreMediaIO = [
"/System/Library/Frameworks/CoreMediaIO.framework"
"/System/Library/PrivateFrameworks/AppSandbox.framework/Versions/A/AppSandbox"
"/System/Library/PrivateFrameworks/AppContainer.framework/Versions/A/AppContainer"
"/System/Library/PrivateFrameworks/SecCodeWrapper.framework/Versions/A/SecCodeWrapper"
"/System/Library/PrivateFrameworks/XPCService.framework/Versions/A/XPCService"
"/usr/lib/libsandbox.1.dylib"
"/usr/lib/libMatch.1.dylib"
];
MediaToolbox = [
"/System/Library/Frameworks/MediaToolbox.framework"
"/System/Library/PrivateFrameworks/CoreAUC.framework/Versions/A/CoreAUC"
"/System/Library/PrivateFrameworks/NetworkStatistics.framework/Versions/A/NetworkStatistics"
];
QTKit = [
"/System/Library/Frameworks/QTKit.framework"
"/System/Library/PrivateFrameworks/CoreMediaAuthoring.framework/Versions/A/CoreMediaAuthoring"
];
OSAKit = [
"/System/Library/Frameworks/OSAKit.framework"
"/usr/lib/libexslt.0.dylib"
];
WebKit = [
"/System/Library/Frameworks/WebKit.framework"
];
DiskArbitration = [
"/System/Library/Frameworks/DiskArbitration.framework"
];
Security = [
"/System/Library/Frameworks/Security.framework"
"/usr/lib/libbsm.0.dylib"
"/usr/lib/libbz2.1.0.dylib"
"/usr/lib/libpam.2.dylib"
"/usr/lib/libxar.1.dylib"
"/usr/lib/libxml2.2.dylib"
"/usr/lib/libsqlite3.dylib"
];
GSS = [
"/System/Library/Frameworks/GSS.framework"
];
Kerberos = [
"/System/Library/Frameworks/Kerberos.framework"
];
CoreServices = [
"/System/Library/Frameworks/CoreServices.framework"
"/System/Library/PrivateFrameworks/DataDetectorsCore.framework/Versions/A/DataDetectorsCore"
"/System/Library/PrivateFrameworks/TCC.framework/Versions/A/TCC"
"/System/Library/PrivateFrameworks/LanguageModeling.framework/Versions/A/LanguageModeling"
"/usr/lib/libmecabra.dylib"
"/usr/lib/libcmph.dylib"
"/usr/lib/libiconv.2.dylib"
"/usr/lib/libxslt.1.dylib"
] ++ Foundation;
IOSurface = [
"/System/Library/Frameworks/IOSurface.framework"
];
CoreGraphics = [
"/System/Library/Frameworks/CoreGraphics.framework"
"/System/Library/PrivateFrameworks/MultitouchSupport.framework/Versions/A/MultitouchSupport"
"/usr/lib/libbsm.0.dylib"
"/usr/lib/libz.1.dylib"
];
CoreText = [
"/System/Library/Frameworks/CoreText.framework"
];
ImageIO = [
"/System/Library/Frameworks/ImageIO.framework"
];
ApplicationServices = [
"/System/Library/Frameworks/ApplicationServices.framework"
"/usr/lib/libcups.2.dylib"
"/usr/lib/libresolv.9.dylib"
] ++ AudioToolbox;
OpenGL = [
"/System/Library/Frameworks/OpenGL.framework"
];
CoreVideo = [
"/System/Library/Frameworks/CoreVideo.framework"
];
QuartzCore = [
"/System/Library/Frameworks/QuartzCore.framework"
"/System/Library/PrivateFrameworks/CrashReporterSupport.framework/Versions/A/CrashReporterSupport"
];
PCSC = [
"/System/Library/Frameworks/PCSC.framework"
];
AppKit = [
"/System/Library/Frameworks/AppKit.framework"
"/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Apple80211"
"/System/Library/PrivateFrameworks/AppleJPEG.framework/Versions/A/AppleJPEG"
"/System/Library/PrivateFrameworks/AppleVPA.framework/Versions/A/AppleVPA"
"/System/Library/PrivateFrameworks/Backup.framework/Versions/A/Backup"
"/System/Library/PrivateFrameworks/ChunkingLibrary.framework/Versions/A/ChunkingLibrary"
"/System/Library/PrivateFrameworks/CommonAuth.framework/Versions/A/CommonAuth"
"/System/Library/PrivateFrameworks/CoreSymbolication.framework/Versions/A/CoreSymbolication"
"/System/Library/PrivateFrameworks/CoreUI.framework/Versions/A/CoreUI"
"/System/Library/PrivateFrameworks/CoreWiFi.framework/Versions/A/CoreWiFi"
"/System/Library/PrivateFrameworks/CrashReporterSupport.framework/Versions/A/CrashReporterSupport"
"/System/Library/PrivateFrameworks/DataDetectorsCore.framework/Versions/A/DataDetectorsCore"
"/System/Library/PrivateFrameworks/DebugSymbols.framework/Versions/A/DebugSymbols"
"/System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv"
"/System/Library/PrivateFrameworks/FaceCore.framework/Versions/A/FaceCore"
"/System/Library/PrivateFrameworks/GenerationalStorage.framework/Versions/A/GenerationalStorage"
"/System/Library/PrivateFrameworks/Heimdal.framework/Heimdal"
"/System/Library/PrivateFrameworks/Heimdal.framework/Versions/Current"
"/System/Library/PrivateFrameworks/Heimdal.framework/Versions/A/Heimdal"
"/System/Library/PrivateFrameworks/IconServices.framework/Versions/A/IconServices"
"/System/Library/PrivateFrameworks/LanguageModeling.framework/Versions/A/LanguageModeling"
"/System/Library/PrivateFrameworks/MultitouchSupport.framework/Versions/A/MultitouchSupport"
"/System/Library/PrivateFrameworks/NetAuth.framework/Versions/A/NetAuth"
"/System/Library/PrivateFrameworks/PerformanceAnalysis.framework/Versions/A/PerformanceAnalysis"
"/System/Library/PrivateFrameworks/RemoteViewServices.framework/Versions/A/RemoteViewServices"
"/System/Library/PrivateFrameworks/Sharing.framework/Versions/A/Sharing"
"/System/Library/PrivateFrameworks/SpeechRecognitionCore.framework/Versions/A/SpeechRecognitionCore"
"/System/Library/PrivateFrameworks/Symbolication.framework/Versions/A/Symbolication"
"/System/Library/PrivateFrameworks/TCC.framework/Versions/A/TCC"
"/System/Library/PrivateFrameworks/UIFoundation.framework/Versions/A/UIFoundation"
"/System/Library/PrivateFrameworks/login.framework/Versions/A/Frameworks/loginsupport.framework/Versions/A/loginsupport"
"/usr/lib/libCRFSuite.dylib"
"/usr/lib/libOpenScriptingUtil.dylib"
"/usr/lib/libarchive.2.dylib"
"/usr/lib/libbsm.0.dylib"
"/usr/lib/libbz2.1.0.dylib"
"/usr/lib/libc++.1.dylib"
"/usr/lib/libc++abi.dylib"
"/usr/lib/libcmph.dylib"
"/usr/lib/libcups.2.dylib"
"/usr/lib/libextension.dylib"
"/usr/lib/libheimdal-asn1.dylib"
"/usr/lib/libiconv.2.dylib"
"/usr/lib/libicucore.A.dylib"
"/usr/lib/liblangid.dylib"
"/usr/lib/liblzma.5.dylib"
"/usr/lib/libmecabra.dylib"
"/usr/lib/libpam.2.dylib"
"/usr/lib/libresolv.9.dylib"
"/usr/lib/libsqlite3.dylib"
"/usr/lib/libxar.1.dylib"
"/usr/lib/libxml2.2.dylib"
"/usr/lib/libxslt.1.dylib"
"/usr/lib/libz.1.dylib"
];
Foundation = [
"/System/Library/Frameworks/Foundation.framework"
"/usr/lib/libextension.dylib"
"/usr/lib/libarchive.2.dylib"
"/usr/lib/liblzma.5.dylib"
"/usr/lib/liblangid.dylib"
"/usr/lib/libCRFSuite.dylib"
];
CoreData = [
"/System/Library/Frameworks/CoreData.framework"
];
Cocoa = [
"/System/Library/Frameworks/Cocoa.framework"
"/System/Library/PrivateFrameworks/UIFoundation.framework/Versions/A/UIFoundation"
"/System/Library/PrivateFrameworks/UIFoundation.framework/Versions/A"
];
Carbon = [
"/System/Library/Frameworks/Carbon.framework"
"/System/Library/PrivateFrameworks/CoreUI.framework/Versions/A/CoreUI"
"/System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv"
"/System/Library/PrivateFrameworks/IconServices.framework/Versions/A/IconServices"
"/System/Library/PrivateFrameworks/ChunkingLibrary.framework/Versions/A/ChunkingLibrary"
"/System/Library/PrivateFrameworks/Sharing.framework/Versions/A/Sharing"
"/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Apple80211"
"/System/Library/PrivateFrameworks/GenerationalStorage.framework/Versions/A/GenerationalStorage"
];
CoreAudio = [
"/System/Library/Frameworks/CoreAudio.framework"
];
AudioUnit = [
"/System/Library/Frameworks/AudioUnit.framework"
];
CoreMIDI = [
"/System/Library/Frameworks/CoreMIDI.framework"
];
AudioToolbox = [
"/System/Library/Frameworks/AudioToolbox.framework"
];
SystemConfiguration = [
"/System/Library/Frameworks/SystemConfiguration.framework"
];
NetFS = [
"/System/Library/Frameworks/NetFS.framework"
"/System/Library/PrivateFrameworks/NetAuth.framework/Versions/A/NetAuth"
"/System/Library/PrivateFrameworks/login.framework/Versions/A/Frameworks/loginsupport.framework/Versions/A/loginsupport"
];
Accelerate = [
"/System/Library/Frameworks/Accelerate.framework"
];
OpenDirectory = [
"/System/Library/Frameworks/OpenDirectory.framework"
];
ServiceManagement = [
"/System/Library/Frameworks/ServiceManagement.framework"
];
OpenCL = [
"/System/Library/Frameworks/OpenCL.framework"
];
CoreWLAN = [
"/System/Library/Frameworks/CoreWLAN.framework"
];
IOBluetooth = [
"/System/Library/Frameworks/IOBluetooth.framework"
] ++ AudioUnit ++ CoreBluetooth;
CoreBluetooth = [
"/System/Library/Frameworks/CoreBluetooth.framework"
];
SecurityFoundation = [
"/System/Library/Frameworks/SecurityFoundation.framework"
];
Kernel = [
"/System/Library/Frameworks/Kernel.framework"
];
}

View File

@ -0,0 +1,14 @@
{ stdenvNoCC }:
version: pname:
stdenvNoCC.mkDerivation {
inherit pname version;
buildCommand = ''
mkdir -p "$out"
echo "Individual frameworks have been deprecated. See the stdenv documentation for how to use `apple-sdk`" \
> "$out/README"
'';
passthru.isDarwinCompatStub = true;
}

View File

@ -1,8 +0,0 @@
addPrivateFrameworks() {
flag="-F/System/Library/PrivateFrameworks"
if [[ "${NIX_CFLAGS_COMPILE-}" != *$flag* ]]; then
NIX_CFLAGS_COMPILE+=" $flag"
fi
}
addEnvHooks "$hostOffset" addPrivateFrameworks

View File

@ -1,68 +0,0 @@
{
lib,
runCommand,
writeText,
sdkVersion,
}:
let
sdkName = "MacOSX${sdkVersion}";
toolchainName = "com.apple.dt.toolchain.XcodeDefault";
productBuildVer = null;
inherit (lib.generators) toPlist toJSON;
SDKSettings = {
CanonicalName = "macosx${sdkVersion}";
DisplayName = "macOS ${sdkVersion}";
Toolchains = [ toolchainName ];
Version = sdkVersion;
MaximumDeploymentTarget = "${sdkVersion}.99";
isBaseSDK = "YES";
};
SystemVersion =
lib.optionalAttrs (productBuildVer != null) { ProductBuildVersion = productBuildVer; }
// {
ProductName = "macOS";
ProductVersion = sdkVersion;
};
in
runCommand "sdkroot-${sdkVersion}" { } ''
sdk="$out/${sdkName}.sdk"
install -D ${writeText "SDKSettings.plist" (toPlist { } SDKSettings)} "$sdk/SDKSettings.plist"
install -D ${writeText "SDKSettings.json" (toJSON { } SDKSettings)} "$sdk/SDKSettings.json"
install -D ${
writeText "SystemVersion.plist" (toPlist { } SystemVersion)
} "$sdk/System/Library/CoreServices/SystemVersion.plist"
ln -s "$sdk" "$sdk/usr"
install -D '${../../../build-support/setup-hooks/role.bash}' "$out/nix-support/setup-hook"
cat >> "$out/nix-support/setup-hook" <<-hook
#
# See comments in cc-wrapper's setup hook. This works exactly the same way.
#
[[ -z \''${strictDeps-} ]] || (( "\$hostOffset" < 0 )) || return 0
sdkRootHook() {
# See ../../../build-support/setup-hooks/role.bash
local role_post
getHostRoleEnvHook
# Only set the SDK root if one has not been set via this hook or some other means.
if [[ ! \$NIX_CFLAGS_COMPILE =~ isysroot ]]; then
export NIX_CFLAGS_COMPILE\''${role_post}+=' -isysroot $out/${sdkName}.sdk'
fi
}
# See ../../../build-support/setup-hooks/role.bash
getTargetRole
addEnvHooks "\$targetOffset" sdkRootHook
# No local scope in sourced file
unset -v role_post
hook
''

View File

@ -1,10 +0,0 @@
noDeprecatedDeclarations() {
# Security.framework has about 2000 deprecated constants, all of which the user will be
# warned about at compilation time
flag="-Wno-deprecated-declarations"
if [[ "${NIX_CFLAGS_COMPILE-}" != *$flag* ]]; then
NIX_CFLAGS_COMPILE+=" $flag"
fi
}
addEnvHooks "$hostOffset" noDeprecatedDeclarations

View File

@ -1,16 +1,27 @@
{
lib,
stdenvNoCC,
appleDerivation',
gnused,
python3,
apple-sdk,
buildPackages,
mkAppleDerivation,
unifdef,
}:
appleDerivation' stdenvNoCC {
nativeBuildInputs = [ unifdef ];
let
inherit (buildPackages) gnused python3;
xnu = apple-sdk.sourceRelease "xnu";
in
mkAppleDerivation (finalAttrs: {
releaseName = "AvailabilityVersions";
patches = [ ./0001-Support-setting-an-upper-bound-on-versions.patch ];
patches = [
# Add support for setting an upper bound, which is needed by the `gen-headers` script.
# It avoids having pre-process the DSL to remove unwanted versions.
./patches/0001-Support-setting-an-upper-bound-on-versions.patch
];
noCC = true;
nativeBuildInputs = [ unifdef ];
buildPhase = ''
runHook preBuild
@ -18,7 +29,6 @@ appleDerivation' stdenvNoCC {
declare -a unifdef_sources=(
os_availability.modulemap
os_availability_private.modulemap
AvailabilityPrivate.modulemap
)
unifdef -x2 -UBUILD_FOR_DRIVERKIT -m $(for x in "''${unifdef_sources[@]}"; do echo templates/$x; done)
@ -33,10 +43,20 @@ appleDerivation' stdenvNoCC {
cp -r availability.dsl templates "$out/share/availability/"
substitute availability "$out/libexec/availability" \
--replace-fail '/usr/bin/env python3' '${lib.getBin python3}/bin/python3' \
--replace-fail '/usr/bin/env python3' '${lib.getExe python3}' \
--replace-fail 'f"{os.path.abspath(os.path.dirname(sys.argv[0]))}/' "\"$out/share/availability/"
chmod a+x "$out/libexec/availability"
substitute ${xnu}/bsd/sys/make_symbol_aliasing.sh "$out/libexec/make_symbol_aliasing.sh" \
${
if lib.versionOlder (lib.getVersion xnu) "6153.11.26" then
''--replace-fail "\''${SDKROOT}/usr/local/libexec/availability.pl" "$out/libexec/availability" \''
else
''--replace-fail "\''${SDKROOT}/\''${DRIVERKITROOT}/usr/local/libexec/availability.pl" "$out/libexec/availability" \''
}
--replace-fail '--macosx' '--macosx --threshold $SDKROOT'
chmod a+x "$out/libexec/make_symbol_aliasing.sh"
cat <<SCRIPT > "$out/bin/gen-headers"
#!/usr/bin/env bash
set -eu
@ -61,13 +81,7 @@ appleDerivation' stdenvNoCC {
--preprocess "$out/share/availability/templates/\$header_src" "\$dest/include/\$header"
done
# `__ENVIRONMENT_OS_VERSION_MIN_REQUIRED__` is only defined by clang 17+, so define it for older versions.
${lib.getExe gnused} -E '/#ifndef __MAC_OS_X_VERSION_MIN_REQUIRED/{
i#ifndef __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__
i#define __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__ __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
i#endif
}' \\
-i "\$dest/include/AvailabilityInternal.h"
"$out/libexec/make_symbol_aliasing.sh" \$threshold "\$dest/include/sys/_symbol_aliasing.h"
# Remove macros from newer SDKs because they can confuse some programs about the SDK version.
declare -a versionParts=(\''${threshold//./ })
@ -95,5 +109,9 @@ appleDerivation' stdenvNoCC {
runHook postInstall
'';
meta.mainProgram = "gen-headers";
}
meta = {
description = "Generates Darwin Availability headers";
mainProgram = "gen-headers";
platforms = lib.platforms.unix;
};
})

View File

@ -1,20 +0,0 @@
{ lib, appleDerivation', stdenvNoCC }:
appleDerivation' stdenvNoCC {
dontBuild = true;
installPhase = ''
mkdir -p $out/include
cp MacTypes.h $out/include
cp ConditionalMacros.h $out/include
substituteInPlace $out/include/MacTypes.h \
--replace "CarbonCore/" ""
'';
meta = with lib; {
maintainers = with maintainers; [ copumpkin ];
platforms = platforms.darwin;
license = licenses.apple-psl20;
};
}

View File

@ -1,42 +0,0 @@
{ lib, appleDerivation', stdenvNoCC }:
appleDerivation' stdenvNoCC {
installPhase = ''
mkdir -p $out/include/CommonCrypto
cp include/* $out/include/CommonCrypto
'';
appleHeaders = ''
CommonCrypto/CommonBaseXX.h
CommonCrypto/CommonBigNum.h
CommonCrypto/CommonCMACSPI.h
CommonCrypto/CommonCRC.h
CommonCrypto/CommonCrypto.h
CommonCrypto/CommonCryptoError.h
CommonCrypto/CommonCryptoPriv.h
CommonCrypto/CommonCryptor.h
CommonCrypto/CommonCryptorSPI.h
CommonCrypto/CommonDH.h
CommonCrypto/CommonDigest.h
CommonCrypto/CommonDigestSPI.h
CommonCrypto/CommonECCryptor.h
CommonCrypto/CommonHMAC.h
CommonCrypto/CommonHMacSPI.h
CommonCrypto/CommonKeyDerivation.h
CommonCrypto/CommonKeyDerivationSPI.h
CommonCrypto/CommonNumerics.h
CommonCrypto/CommonRSACryptor.h
CommonCrypto/CommonRandom.h
CommonCrypto/CommonRandomSPI.h
CommonCrypto/CommonSymmetricKeywrap.h
CommonCrypto/aes.h
CommonCrypto/lionCompat.h
CommonCrypto/module.modulemap
'';
meta = with lib; {
maintainers = with maintainers; [ copumpkin ];
platforms = platforms.darwin;
license = licenses.apple-psl20;
};
}

View File

@ -1,29 +0,0 @@
{ lib, appleDerivation', stdenv }:
appleDerivation' stdenv {
prePatch = ''
substituteInPlace Makefile \
--replace /usr/lib /lib \
--replace /usr/local/lib /lib \
--replace /usr/bin "" \
--replace /bin/ "" \
--replace "CC = " "#" \
--replace "SDK_DIR = " "SDK_DIR = . #" \
# Mac OS didn't support rpaths back before 10.5, but we don't care about it.
substituteInPlace Makefile \
--replace -mmacosx-version-min=10.4 -mmacosx-version-min=10.6 \
--replace -mmacosx-version-min=10.5 -mmacosx-version-min=10.6
'';
installFlags = [ "DSTROOT=$(out)" ];
enableParallelInstalling = false; # cp: cannot create regular file '$out/lib/crt1.10.6.o'
meta = with lib; {
description = "Apple's common startup stubs for darwin";
maintainers = with maintainers; [ copumpkin ];
platforms = platforms.darwin;
license = licenses.apple-psl20;
};
}

View File

@ -0,0 +1,31 @@
{
lib,
makeSetupHook,
mkAppleDerivation,
stdenv,
}:
mkAppleDerivation {
releaseName = "Csu";
makeFlags = [
"CC=${stdenv.cc.targetPrefix}clang"
"CHMOD=chmod"
"MKDIR=mkdir"
"USRLIBDIR=/lib"
"LOCLIBDIR=/lib"
];
installFlags = [ "DSTROOT=$(out)" ];
setupHooks = [
../../../../build-support/setup-hooks/role.bash
# ccWrapper_addCVars doesnt add Csu to `NIX_LDFLAGS` because it contains objects and no dylibs.
./setup-hooks/add-Csu-lib-path.sh
];
meta = {
description = "Common startup stubs for Darwin";
badPlatforms = [ lib.systems.inspect.patterns.isAarch ];
};
}

Some files were not shown because too many files have changed in this diff Show More