Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce 10.13 xnu #273016

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
48 changes: 45 additions & 3 deletions pkgs/os-specific/darwin/apple-source-releases/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,23 @@ let
macosPackages_11_0_1 = import ./macos-11.0.1.nix { inherit applePackage'; };
developerToolsPackages_11_3_1 = import ./developer-tools-11.3.1.nix { inherit applePackage'; };

applePackage' = namePath: version: sdkName: sha256:
applePackage'' =
extra: namePath: version: sdkName: sha256:
let
pname = builtins.head (lib.splitString "/" namePath);
appleDerivation' = stdenv: appleDerivation'' stdenv pname version sdkName sha256;
appleDerivation = appleDerivation' stdenv;
callPackage = self.newScope { inherit appleDerivation' appleDerivation; python3 = pkgs.buildPackages.python3Minimal; };
in callPackage (./. + "/${namePath}");
callPackage = self.newScope (
{
inherit appleDerivation' appleDerivation;
python3 = pkgs.buildPackages.python3Minimal;
}
// extra
);
in
callPackage (./. + "/${namePath}");

applePackage' = applePackage'' { };

applePackage = namePath: sdkName: sha256: let
pname = builtins.head (lib.splitString "/" namePath);
Expand Down Expand Up @@ -321,4 +331,36 @@ developerToolsPackages_11_3_1 // macosPackages_11_0_1 // {
# TODO(matthewbauer):
# To be removed, once I figure out how to build a newer Security version.
Security = applePackage "Security/boot.nix" "osx-10.9.5" "sha256-7qr0IamjCXCobIJ6V9KtvbMBkJDfRCy4C5eqpHJlQLI=" {};

# To enable splitting up the SDK bump into reviewable chunks before
# switching to it wholesale.
"10.13.6" =
let
applePackageMapping =
namePath:
applePackage''
# Have packages depend on each other
# rather than previous versions.
self."10.13.6"
{
xnu = "xnu/10.13.6.nix";
}."${namePath}" or namePath;
in
{
inherit (import ./macos-10.13.6.nix { applePackage' = applePackageMapping; })
architecture
copyfile
Csu
dyld
libclosure
Libinfo
libmalloc
Libnotify
libresolv
mDNSResponder
objc4
removefile
xnu
;
};
}
48 changes: 48 additions & 0 deletions pkgs/os-specific/darwin/apple-source-releases/macos-10.13.6.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Generated using: ./generate-sdk-packages.sh macos 10.13.6

{ applePackage' }:

{
CommonCrypto = applePackage' "CommonCrypto" "60118.50.1" "macos-10.13.6" "1sjqa60zhchh0y5rbn9a2cbs07rw3hyvk3xqf44h48c4xpididdf" {};
Csu = applePackage' "Csu" "85" "macos-10.13.6" "1ipas2j3250lykbppnlbpp4a2dayh413x06m51qy2m840fqvz9l7" {};
ICU = applePackage' "ICU" "59180.0.1" "macos-10.13.6" "0c51440nfbp4fawvyzzikk7qjjcx2yvjrjghg6dqb4sy6bnb000s" {};
Libc = applePackage' "Libc" "1244.50.9" "macos-10.13.6" "1y4r1bgs54y5ni31nwpx2n38sv1rx1g3izmjpzy6rbg21vb0jsbq" {};
Libinfo = applePackage' "Libinfo" "517.30.1" "macos-10.13.6" "1jk9rp3sm3ij9avbkryaq9cv355dg9sf9q9wbl5l5jhgyf4azn6v" {};
Libnotify = applePackage' "Libnotify" "172" "macos-10.13.6" "0xpqqa88nfnsccpd2imfwqa75cbga4m3l1z68sbxa5a3b5qrs2ap" {};
Librpcsvc = applePackage' "Librpcsvc" "26" "macos-10.13.6" "0wf6srbw28664wa0dckldbhrl9ydg70fms06rj6i7mvlrz1ccxk0" {};
Libsystem = applePackage' "Libsystem" "1252.50.4" "macos-10.13.6" "0nd5smcbakqpx1288qhsn0lglgs4klw3sp4q25gvvp1zf423k4c2" {};
PowerManagement = applePackage' "PowerManagement" "703.71.1" "macos-10.13.6" "1naf1wfc8cakaifi9c5gf7g5wzdhppwcygybr2isr4jrp3chzzgx" {};
Security = applePackage' "Security" "58286.70.7" "macos-10.13.6" "1xmh33z9glrcak15dqf5bnmnlyklfy069kc42dms02hxhx7c6jx0" {};
adv_cmds = applePackage' "adv_cmds" "172" "macos-10.13.6" "1kxxwa5ix5fkncxl631skg42x2q3j9fpp8j68q5m5fwmm159dxax" {};
architecture = applePackage' "architecture" "268" "macos-10.13.6" "0ln1byjjmsbvs6vbz6rszx1bj7mdxky7bj0i950hqf563qrrwhki" {};
basic_cmds = applePackage' "basic_cmds" "55" "macos-10.13.6" "1913pzk376zfap2fwmrb233rkn4h4l2c65nd7s8ixvrz1r7cz0q5" {};
bootstrap_cmds = applePackage' "bootstrap_cmds" "98" "macos-10.13.6" "18jwla9i4c94zdxddwzfrg7xmjh4kjc6q5gg0jbx0sjk7qx1mzsp" {};
configd = applePackage' "configd" "963.50.8" "macos-10.13.6" "18bfmylqpff3f2davs1g5a9ciawigysrx9pjvrzcrc4b751aqimn" {};
copyfile = applePackage' "copyfile" "146.50.5" "macos-10.13.6" "04hf4k04c1xzglnq2xjn091r57wy1xcqghb31b8hch58vdi704n2" {};
diskdev_cmds = applePackage' "diskdev_cmds" "593" "macos-10.13.6" "0x635rfqnk2z3ncd79spskpk2xikwn1rc2qw28yf1169krqs2zsm" {};
dtrace = applePackage' "dtrace" "262.50.12" "macos-10.13.6" "0f51hb5m2rx1nxk2wimdkg5d1z946r3g6r5kwv96sclhk1k9dd0q" {};
dyld = applePackage' "dyld" "551.4" "macos-10.13.6" "1ckfar82r2p6zk2836h8jrpv4i82fm8dcqq9n9kjaqda4rfnv8k4" {};
eap8021x = applePackage' "eap8021x" "264.50.5" "macos-10.13.6" "1129zmk4a9pzmi2bcfi43ngv34znnb4xiwxv8xdm6r7ixhd7h9v5" {};
file_cmds = applePackage' "file_cmds" "272" "macos-10.13.6" "1h5kk4awv4sflqjkc2vzv8sj7pnzw6c7csh0jag54d4anciz4560" {};
hfs = applePackage' "hfs" "407.50.6" "macos-10.13.6" "16q21q1s29b1gwqbzv807bgx2m514d934w9qwvc6dhg893kqj35f" {};
libauto = applePackage' "libauto" "187" "macos-10.13.6" "1k7wb5283mll2gqf2a7frf66hykhnazwlxy3sncpd2nqyb77jjrz" {};
libclosure = applePackage' "libclosure" "67" "macos-10.13.6" "1l7s19lnr05b2pmn5scrafp759d20dr8h050a1hihwbwz6hg0yk9" {};
libdispatch = applePackage' "libdispatch" "913.60.2" "macos-10.13.6" "0hdg6jmx7rwqgnhby8d6hn5xvrfi0r1dk7mysp62x1m1xcfqd25z" {};
libiconv = applePackage' "libiconv" "51.50.1" "macos-10.13.6" "0mp2ixkvda7d10q740rqxfghag36s60yiid93zgblg8nwjbjaa70" {};
libmalloc = applePackage' "libmalloc" "140.50.6" "macos-10.13.6" "125gqbkhrghkm41hj3pjdxksgj4yxmlpg407g6hnphzgin5ixzhk" {};
libplatform = applePackage' "libplatform" "161.50.1" "macos-10.13.6" "0pwaib4l0kngq36r43zkmw3rcvsvyj88phfgvqn0krxlq4f722lx" {};
libpthread = applePackage' "libpthread" "301.50.1" "macos-10.13.6" "04swggjnysp6wbhfkzdwh3cafklzpmmp5r5mc8gnicbnqqh5n2hl" {};
libresolv = applePackage' "libresolv" "65" "macos-10.13.6" "1grdd9ywzjl78mgv53l3ymsw194j8mvmx9azfj7m93dzpm9r73jj" {};
libunwind = applePackage' "libunwind" "35.3" "macos-10.13.6" "1qdad3x35mn907fhxqqmbr4w1q4fvzzdwvnnvlgad67zsffjqb88" {};
libutil = applePackage' "libutil" "51.20.1" "macos-10.13.6" "0r8zfpqmw5bllysz0s27w22sf2wrvskffbx332zrkmsklangycrs" {};
mDNSResponder = applePackage' "mDNSResponder" "878.70.2" "macos-10.13.6" "0glgv8735pjmihzyssqq5313zsh9b9higb0dsnd6mwkfq7zvbdky" {};
network_cmds = applePackage' "network_cmds" "543.50.4" "macos-10.13.6" "1zxiy7syy06qzlr4zzii5hmni4hna9337hricp2dqhiy04z4nvsq" {};
objc4 = applePackage' "objc4" "723" "macos-10.13.6" "18chzg9ykmby6qrn6w4h2sjys6n8rf7v69lwinqzhhjy7cvylyww" {};
ppp = applePackage' "ppp" "847" "macos-10.13.6" "1hr7p7h3kqfckm6laxifcvp52hwcs95kycavqbq2pikk4rq27vv3" {};
removefile = applePackage' "removefile" "45" "macos-10.13.6" "1lwb50kciq9j20cr1pdsspyg6cpnai95jmsnndn7cph6p7dn94sj" {};
shell_cmds = applePackage' "shell_cmds" "203" "macos-10.13.6" "00c001sq5npqmnac0x2z3v8fi8h5l3i2i8rjdpz1mb5k863i5x1k" {};
system_cmds = applePackage' "system_cmds" "790.50.6" "macos-10.13.6" "0fc9hahfgsqa63s8ppbikx44qv3dsrr5lvz2pxk65mjrym208zmg" {};
text_cmds = applePackage' "text_cmds" "99" "macos-10.13.6" "070gff2mq5nr848556kgvarp38rmhqxryxbymbgc6lkjnr9rn9r9" {};
top = applePackage' "top" "111.20.1" "macos-10.13.6" "0qgr8ggf40pyq8bwrgf8p3fd5hf96p3nqfqj7zmilny46wkkhlay" {};
xnu = applePackage' "xnu" "4570.71.2" "macos-10.13.6" "052sbbd3j0ngns9c2cg7jh8xwjrg1khlbj1vgn8ija767r6ciqmr" {};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
From 0fdd7beac9dd2f47e5c8b4aa555f97c532c6e6ed Mon Sep 17 00:00:00 2001
From: toonn <toonn@toonn.io>
Date: Mon, 23 Aug 2021 13:55:48 +0200
Subject: [PATCH 2/2] Implement missing availability platform

---
EXTERNAL_HEADERS/AvailabilityInternal.h | 1 +
1 file changed, 1 insertion(+)

diff --git a/EXTERNAL_HEADERS/AvailabilityInternal.h b/EXTERNAL_HEADERS/AvailabilityInternal.h
index 8663cae..3c27779 100644
--- a/EXTERNAL_HEADERS/AvailabilityInternal.h
+++ b/EXTERNAL_HEADERS/AvailabilityInternal.h
@@ -23459,6 +23459,7 @@
#define __API_AVAILABLE_PLATFORM_ios(x) ios,introduced=x
#define __API_AVAILABLE_PLATFORM_watchos(x) watchos,introduced=x
#define __API_AVAILABLE_PLATFORM_tvos(x) tvos,introduced=x
+#define __API_AVAILABLE_PLATFORM_bridgeos(x) bridgeos,introduced=x

#define __API_A(x) __attribute__((availability(__API_AVAILABLE_PLATFORM_##x)))
#define __API_AVAILABLE1(x) __API_A(x)
--
2.17.2 (Apple Git-113)

159 changes: 159 additions & 0 deletions pkgs/os-specific/darwin/apple-source-releases/xnu/10.13.6.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
{ appleDerivation', lib, stdenv, stdenvNoCC, buildPackages
, bootstrap_cmds, bison, flex
, gnum4, unifdef, perl, python3
, headersOnly ? true
}:

appleDerivation' (if headersOnly then stdenvNoCC else stdenv) (
let arch = if stdenv.isx86_64 then "x86_64" else "arm64";
in
{
depsBuildBuild = [ buildPackages.stdenv.cc ];

nativeBuildInputs = [ bootstrap_cmds bison flex gnum4 unifdef perl python3 ];

patches = lib.optionals stdenv.isx86_64 [
./python3.patch
./0001-Implement-missing-availability-platform.patch
];

postPatch = ''
substituteInPlace Makefile \
--replace-fail "/bin/" "" \
--replace-fail "MAKEJOBS := " '# MAKEJOBS := '

substituteInPlace makedefs/MakeInc.cmd \
--replace-fail "/usr/bin/" "" \
--replace-fail "/bin/" ""

substituteInPlace makedefs/MakeInc.def \
--replace-fail "-c -S -m" "-c -m"

substituteInPlace makedefs/MakeInc.top \
--replace-fail "MEMORY_SIZE := " 'MEMORY_SIZE := 1073741824 # '

substituteInPlace libsyscall/xcodescripts/mach_install_mig.sh \
toonn marked this conversation as resolved.
Show resolved Hide resolved
--replace-fail "/usr/include" "/include" \
--replace-fail 'MIG=`' "# " \
--replace-fail 'MIGCC=`' "# " \
--replace-fail '$SRC/$mig' '-I$DSTROOT/include $SRC/$mig' \
--replace-fail '$SRC/servers/netname.defs' \
'-I$DSTROOT/include $SRC/servers/netname.defs' \
--replace-fail '$BUILT_PRODUCTS_DIR/mig_hdr' '$BUILT_PRODUCTS_DIR'

patchShebangs .
'' + lib.optionalString stdenv.isAarch64 ''
# iig is closed-sourced, we don't have it
# create an empty file to the header instead
# this line becomes: echo "" > $@; echo --header ...
substituteInPlace iokit/DriverKit/Makefile \
--replace-fail '--def $<' '> $@; echo'
'';

PLATFORM = "MacOSX";
SDKVERSION = "10.13.6";
CC = "${stdenv.cc.targetPrefix or ""}cc";
CXX = "${stdenv.cc.targetPrefix or ""}c++";
MIG = "mig";
MIGCOM = "migcom";
STRIP = "${stdenv.cc.bintools.targetPrefix or ""}strip";
RANLIB = "${stdenv.cc.bintools.targetPrefix or ""}ranlib";
NM = "${stdenv.cc.bintools.targetPrefix or ""}nm";
UNIFDEF = "unifdef";
DSYMUTIL = "dsymutil";
HOST_OS_VERSION = "10.13.6";
HOST_CC = "${buildPackages.stdenv.cc.targetPrefix or ""}cc";
HOST_FLEX = "flex";
HOST_BISON = "bison";
HOST_GM4 = "m4";
MIGCC = "cc";
ARCHS = arch;
ARCH_CONFIGS = arch;

env.NIX_CFLAGS_COMPILE = "-Wno-error";

preBuild = let
macosVersions = "10.0 10.1 10.2 10.3 10.4 10.5 10.6 10.7 10.8 10.9 10.10 10.10.2 10.10.3 10.11 10.11.2 10.11.3 10.11.4 10.12 10.12.1 10.12.2 10.12.4 10.13 10.13.1 10.13.2 10.13.4";
iosVersions = "2.0 2.1 2.2 3.0 3.1 3.2 4.0 4.1 4.2 4.3 5.0 5.1 6.0 6.1 7.0 7.1 8.0 8.1 8.2 8.3 8.4 9.0 9.1 9.2 9.3 10.0 10.1 10.2 10.3 11.0 11.1 11.2 11.3 11.4";
in ''
# This is a bit of a hack...
mkdir -p sdk/usr/local/libexec

cat > sdk/usr/local/libexec/availability.pl <<EOF
#!$SHELL
if [ "\$1" == "--macosx" ]; then
echo ${macosVersions}
elif [ "\$1" == "--ios" ]; then
echo ${iosVersions}
fi
EOF
chmod +x sdk/usr/local/libexec/availability.pl

export SDKROOT_RESOLVED=$PWD/sdk
export HOST_SDKROOT_RESOLVED=$PWD/sdk

export BUILT_PRODUCTS_DIR=.
export DSTROOT=$out
'';

buildFlags = lib.optional headersOnly "exporthdrs";
installTargets = lib.optional headersOnly "installhdrs";

postInstall = lib.optionalString headersOnly ''
mv $out/usr/include $out

(cd BUILD/obj/EXPORT_HDRS && find -type f -exec install -D \{} $out/include/\{} \;)

# TODO: figure out why I need to do this
cp libsyscall/wrappers/*.h $out/include
install -D libsyscall/os/tsd.h $out/include/os/tsd.h
cp EXTERNAL_HEADERS/AssertMacros.h $out/include
cp EXTERNAL_HEADERS/Availability*.h $out/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/
cp -r EXTERNAL_HEADERS/corecrypto $out/include

# Build the mach headers we crave
export SRCROOT=$PWD/libsyscall
export DERIVED_SOURCES_DIR=$out/include
export SDKROOT=$out
export OBJROOT=$PWD
export BUILT_PRODUCTS_DIR=$out
libsyscall/xcodescripts/mach_install_mig.sh

# Get rid of the System prefix
mv $out/System/* $out/
rmdir $out/System

# TODO: do I need this?
mv $out/internal_hdr/include/mach/*.h $out/include/mach

# Get rid of some junk lying around
rm -r $out/internal_hdr $out/usr $out/local

# Add some symlinks
ln -s $out/Library/Frameworks/System.framework/Versions/B \
$out/Library/Frameworks/System.framework/Versions/Current
ln -s $out/Library/Frameworks/System.framework/Versions/Current/PrivateHeaders \
$out/Library/Frameworks/System.framework/Headers

# IOKit (and possibly the others) is incomplete,
# so let's not make it visible from here...
mkdir $out/Library/PrivateFrameworks
mv $out/Library/Frameworks/IOKit.framework $out/Library/PrivateFrameworks
'';

appleHeaders = builtins.readFile ./headers-10.13.6.txt;

meta = {
maintainers = with lib.maintainers; [ toonn ];
};
} // lib.optionalAttrs headersOnly {
HOST_CODESIGN = "echo";
HOST_CODESIGN_ALLOCATE = "echo";
LIPO = "echo";
LIBTOOL = "echo";
CTFCONVERT = "echo";
CTFMERGE = "echo";
CTFINSERT = "echo";
NMEDIT = "echo";
IIG = "echo";
})
Loading