uboot: (firmwareOdroidC2/C4) don't invoke patch tool, use patches = [] instead

https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L948
this can do it nicely.

Signed-off-by: Anton Arapov <anton@deadbeef.mx>
This commit is contained in:
Anton Arapov 2021-04-03 12:58:10 +02:00 committed by Alan Daniels
commit 56de2bcd43
30691 changed files with 3076956 additions and 0 deletions

View file

@ -0,0 +1,18 @@
diff -u -r1.35.2.1 nbtool_config.h.in
--- a/nbtool_config.h.in 22 Apr 2015 07:18:58 -0000 1.35.2.1
+++ b/nbtool_config.h.in 31 May 2018 01:46:53 -0000
@@ -680,5 +680,14 @@
/* Define if you have u_int8_t, but not uint8_t. */
#undef uint8_t
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include "compat_defs.h"
+
+#ifdef __cplusplus
+}
+#endif
+
#endif /* !__NETBSD_NBTOOL_CONFIG_H__ */

View file

@ -0,0 +1,22 @@
commit f2d0ff85e05b49e9d11735ce4810b242c1dbf5af
Author: John Ericson <John.Ericson@Obsidian.Systems>
Date: Wed Sep 1 15:38:56 2021 +0000
Make should not hit configure
diff --git a/Makefile b/Makefile
index b5adb8a5f2e9..1a914ef16739 100644
--- a/Makefile
+++ b/Makefile
@@ -76,11 +76,6 @@ _CURDIR:= ${.CURDIR}
SRCS:= ${SRCS:M*.c}
-config.cache: include/.stamp configure nbtool_config.h.in defs.mk.in
- rm -f ${.TARGET}
- CC=${HOST_CC:Q} CFLAGS=${HOST_CFLAGS:Q} LDFLAGS=${HOST_LDFLAGS:Q} \
- ${HOST_SH} ${.CURDIR}/configure --cache-file=config.cache
-
defs.mk: config.cache
@touch ${.TARGET}

View file

@ -0,0 +1,101 @@
commit 5acf3bdea5140e90135d15d6479f29fbf624f75e
Author: John Ericson <John.Ericson@Obsidian.Systems>
Date: Wed Sep 1 15:38:56 2021 +0000
Don't force building and installing for the build platform
Also remove `compat/` subdir from install directories.
diff --git a/Makefile b/Makefile
index 4bcf227f0e75..9ed1d6eea6ff 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
# $NetBSD: Makefile,v 1.87 2019/05/08 02:25:50 thorpej Exp $
-HOSTLIB= nbcompat
+LIB= nbcompat
-.include <bsd.hostinit.mk>
+.include <bsd.own.mk>
@@ -94,63 +94,37 @@ include/.stamp:
# Install rules
-HOST_LIBDIR= ${TOOLDIR}/lib
-HOST_INCSDIR= ${TOOLDIR}/include
-HOST_SHAREDIR= ${TOOLDIR}/share
-
-install: .PHONY install.lib includes install.defs.mk
-
-# Install lib${HOSTLIB}.a in ${TOOLDIR}/lib
-install.lib: .PHONY ${HOST_LIBDIR}/lib${HOSTLIB}.a
-${HOST_LIBDIR}/lib${HOSTLIB}.a: lib${HOSTLIB}.a
- ${_MKTARGET_INSTALL}
- ${HOST_INSTALL_DIR} ${HOST_LIBDIR}
- ${HOST_INSTALL_FILE} -m ${LIBMODE} ${.ALLSRC} ${.TARGET}
+install: .PHONY includes install.defs.mk
.for _f in ${INCFILES}
-HOST_INCINSTFILES+= ${HOST_INCSDIR}/compat/${_f}
-${HOST_INCSDIR}/compat/${_f}: ${_f}
+INCINSTFILES+= ${INCSDIR}/${_f}
+${INCSDIR}/${_f}: ${_f}
${_MKTARGET_INSTALL}
- ${HOST_INSTALL_FILE} ${.ALLSRC} ${.TARGET}
+ ${INSTALL_FILE} ${.ALLSRC} ${.TARGET}
.endfor
.for _d in ${INCSUBDIRS}
-HOST_INCINSTDIRS+= ${HOST_INCSDIR}/compat/${_d}
-${HOST_INCSDIR}/compat/${_d}:
+INCINSTDIRS+= ${INCSDIR}/${_d}
+${INCSDIR}/${_d}:
${_MKTARGET_INSTALL}
- ${HOST_INSTALL_DIR} ${.TARGET}
+ ${INSTALL_DIR} ${.TARGET}
.endfor
-# Install include files in ${TOOLDIR}/include/compat
-includes: .PHONY ${HOST_INCINSTDIRS} .WAIT ${HOST_INCINSTFILES}
+# Install include files in ${INCSDIR}
+includes: .PHONY ${INCINSTDIRS} .WAIT ${INCINSTFILES}
@(cd include && find . -name '*.h' -print | while read f ; do \
- ${HOST_INSTALL_FILE} $$f ${HOST_INCSDIR}/compat/$$f ; \
+ ${INSTALL_FILE} $$f ${INCSDIR}/$$f ; \
done)
-# Install defs.mk in ${TOOLDIR}/share/compat
-install.defs.mk: .PHONY ${HOST_SHAREDIR}/compat/defs.mk
-${HOST_SHAREDIR}/compat/defs.mk: defs.mk
+# Install defs.mk in ${DATADIR}
+install.defs.mk: .PHONY ${DATADIR}/defs.mk
+${DATADIR}/defs.mk: defs.mk
${_MKTARGET_INSTALL}
- ${HOST_INSTALL_DIR} ${HOST_SHAREDIR}
- ${HOST_INSTALL_DIR} ${HOST_SHAREDIR}/compat
- ${HOST_INSTALL_FILE} ${.ALLSRC} ${.TARGET}
-
-# bsd.hostlib.mk wants HOST_CPPFLAGS, not CPPFLAGS
-
-HOST_CPPFLAGS:= ${CPPFLAGS}
-CPPFLAGS:= # empty
-
-.include <bsd.hostlib.mk>
-
-# Use uninstalled copy of host-mkdep
-HOST_MKDEP_OBJ!= cd ${.CURDIR}/../host-mkdep && ${PRINTOBJDIR}
-HOST_MKDEP= ${HOST_MKDEP_OBJ}/host-mkdep
-MKDEP= ${HOST_MKDEP}
+ ${INSTALL_DIR} ${DATADIR}
+ ${INSTALL_FILE} ${.ALLSRC} ${.TARGET}
-# Use uninstalled copy of the install program
-INSTALL_OBJ!= cd ${NETBSDSRCDIR}/tools/binstall && ${PRINTOBJDIR}
-INSTALL= ${INSTALL_OBJ}/xinstall
+.include <bsd.lib.mk>
# Run "${TOOLDIR}/bin/nbmake-${MACHINE} regen" by hand after editing
# configure.ac. See more detailed instructions in configure.ac.

View file

@ -0,0 +1,5 @@
# See pkgs/build-support/setup-hooks/role.bash
getHostRole
export NIX_LDFLAGS${role_post}+=" -lnbcompat"
export NIX_CFLAGS_COMPILE${role_post}+=" -DHAVE_NBTOOL_CONFIG_H"

View file

@ -0,0 +1,999 @@
{ stdenv, lib, stdenvNoCC
, pkgsBuildBuild, pkgsBuildHost, pkgsBuildTarget, pkgsHostHost, pkgsTargetTarget
, buildPackages, splicePackages, newScope
, bsdSetupHook, makeSetupHook, fetchcvs, groff, mandoc, byacc, flex
, zlib
, writeText, symlinkJoin
}:
let
inherit (buildPackages.buildPackages) rsync;
fetchNetBSD = path: version: sha256: fetchcvs {
cvsRoot = ":pserver:anoncvs@anoncvs.NetBSD.org:/cvsroot";
module = "src/${path}";
inherit sha256;
tag = "netbsd-${lib.replaceStrings ["."] ["-"] version}-RELEASE";
};
netbsdSetupHook = makeSetupHook {
name = "netbsd-setup-hook";
} ./setup-hook.sh;
otherSplices = {
selfBuildBuild = pkgsBuildBuild.netbsd;
selfBuildHost = pkgsBuildHost.netbsd;
selfBuildTarget = pkgsBuildTarget.netbsd;
selfHostHost = pkgsHostHost.netbsd;
selfTargetTarget = pkgsTargetTarget.netbsd or {}; # might be missing
};
defaultMakeFlags = [
"MKSOFTFLOAT=${if stdenv.hostPlatform.gcc.float or (stdenv.hostPlatform.parsed.abi.float or "hard") == "soft"
then "yes"
else "no"}"
];
in lib.makeScopeWithSplicing
splicePackages
newScope
otherSplices
(_: {})
(_: {})
(self: let
inherit (self) mkDerivation;
in {
# Why do we have splicing and yet do `nativeBuildInputs = with self; ...`?
#
# We use `lib.makeScopeWithSplicing` because this should be used for all
# nested package sets which support cross, so the inner `callPackage` works
# correctly. But for the inline packages we don't bother to use
# `callPackage`.
#
# We still could have tried to `with` a big spliced packages set, but
# splicing is jank and causes a number of bootstrapping infinite recursions
# if one is not careful. Pulling deps out of the right package set directly
# side-steps splicing entirely and avoids those footguns.
#
# For non-bootstrap-critical packages, we might as well use `callPackage` for
# consistency with everything else, and maybe put in separate files too.
compatIfNeeded = lib.optional (!stdenvNoCC.hostPlatform.isNetBSD) self.compat;
mkDerivation = lib.makeOverridable (attrs: let
stdenv' = if attrs.noCC or false then stdenvNoCC else stdenv;
in stdenv'.mkDerivation ({
name = "${attrs.pname or (baseNameOf attrs.path)}-netbsd-${attrs.version}";
src = fetchNetBSD attrs.path attrs.version attrs.sha256;
extraPaths = [ ];
nativeBuildInputs = with buildPackages.netbsd; [
bsdSetupHook netbsdSetupHook
makeMinimal
install tsort lorder buildPackages.mandoc groff statHook rsync
];
buildInputs = with self; compatIfNeeded;
HOST_SH = stdenv'.shell;
MACHINE_ARCH = {
i486 = "i386";
i586 = "i386";
i686 = "i386";
}.${stdenv'.hostPlatform.parsed.cpu.name}
or stdenv'.hostPlatform.parsed.cpu.name;
MACHINE = {
x86_64 = "amd64";
aarch64 = "evbarm64";
i486 = "i386";
i586 = "i386";
i686 = "i386";
}.${stdenv'.hostPlatform.parsed.cpu.name}
or stdenv'.hostPlatform.parsed.cpu.name;
BSD_PATH = attrs.path;
makeFlags = defaultMakeFlags;
strictDeps = true;
meta = with lib; {
maintainers = with maintainers; [ matthewbauer qyliss ];
platforms = platforms.unix;
license = licenses.bsd2;
};
} // lib.optionalAttrs stdenv'.hasCC {
# TODO should CC wrapper set this?
CPP = "${stdenv'.cc.targetPrefix}cpp";
} // lib.optionalAttrs stdenv'.isDarwin {
MKRELRO = "no";
} // lib.optionalAttrs (stdenv'.cc.isClang or false) {
HAVE_LLVM = lib.versions.major (lib.getVersion stdenv'.cc.cc);
} // lib.optionalAttrs (stdenv'.cc.isGNU or false) {
HAVE_GCC = lib.versions.major (lib.getVersion stdenv'.cc.cc);
} // lib.optionalAttrs (stdenv'.isx86_32) {
USE_SSP = "no";
} // lib.optionalAttrs (attrs.headersOnly or false) {
installPhase = "includesPhase";
dontBuild = true;
} // attrs // {
postPatch = lib.optionalString (!stdenv'.hostPlatform.isNetBSD) ''
# Files that use NetBSD-specific macros need to have nbtool_config.h
# included ahead of them on non-NetBSD platforms.
set +e
grep -Zlr "^__RCSID
^__BEGIN_DECLS" | xargs -0r grep -FLZ nbtool_config.h |
xargs -0tr sed -i '0,/^#/s//#include <nbtool_config.h>\n\0/'
set -e
'' + attrs.postPatch or "";
}));
##
## START BOOTSTRAPPING
##
makeMinimal = mkDerivation {
path = "tools/make";
sha256 = "0fh0nrnk18m613m5blrliq2aydciv51qhc0ihsj4k63incwbk90n";
version = "9.2";
buildInputs = with self; [];
nativeBuildInputs = with buildPackages.netbsd; [ bsdSetupHook netbsdSetupHook rsync ];
skipIncludesPhase = true;
postPatch = ''
patchShebangs configure
${self.make.postPatch}
'';
buildPhase = ''
runHook preBuild
sh ./buildmake.sh
runHook postBuild
'';
installPhase = ''
runHook preInstall
install -D nbmake $out/bin/nbmake
ln -s $out/bin/nbmake $out/bin/make
mkdir -p $out/share
cp -r $BSDSRCDIR/share/mk $out/share/mk
runHook postInstall
'';
extraPaths = with self; [ make.src ] ++ make.extraPaths;
};
compat = mkDerivation (let
version = "9.2";
commonDeps = [ zlib ];
in {
path = "tools/compat";
sha256 = "1vsxg7136nlhc72vpa664vs22874xh7ila95nkmsd8crn3z3cyn0";
inherit version;
setupHooks = [
../../../build-support/setup-hooks/role.bash
./compat-setup-hook.sh
];
preConfigure = ''
make include/.stamp configure nbtool_config.h.in defs.mk.in
'';
configurePlatforms = [ "build" "host" ];
configureFlags = [
"--cache-file=config.cache"
] ++ lib.optionals stdenv.hostPlatform.isMusl [
# We include this header in our musl package only for legacy
# compatibility, and compat works fine without it (and having it
# know about sys/cdefs.h breaks packages like glib when built
# statically).
"ac_cv_header_sys_cdefs_h=no"
];
nativeBuildInputs = with buildPackages.netbsd; commonDeps ++ [
bsdSetupHook netbsdSetupHook
makeMinimal
rsync
];
buildInputs = with self; commonDeps;
# temporarily use gnuinstall for bootstrapping
# bsdinstall will be built later
makeFlags = defaultMakeFlags ++ [
"INSTALL=${buildPackages.coreutils}/bin/install"
"DATADIR=$(out)/share"
# Can't sort object files yet
"LORDER=echo"
"TSORT=cat"
# Can't process man pages yet
"MKSHARE=no"
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
# GNU objcopy produces broken .a libs which won't link into dependers.
# Makefiles only invoke `$OBJCOPY -x/-X`, so cctools strip works here.
"OBJCOPY=${buildPackages.darwin.cctools}/bin/strip"
];
RENAME = "-D";
passthru.tests = { netbsd-install = self.install; };
patches = [
./compat-cxx-safe-header.patch
./compat-dont-configure-twice.patch
./compat-no-force-native.patch
];
preInstall = ''
makeFlagsArray+=('INSTALL_FILE=''${INSTALL} ''${COPY} ''${PRESERVE} ''${RENAME}')
makeFlagsArray+=('INSTALL_DIR=''${INSTALL} -d')
makeFlagsArray+=('INSTALL_SYMLINK=''${INSTALL} ''${SYMLINK} ''${RENAME}')
'';
postInstall = ''
# why aren't these installed by netbsd?
install -D compat_defs.h $out/include/compat_defs.h
install -D $BSDSRCDIR/include/cdbw.h $out/include/cdbw.h
install -D $BSDSRCDIR/sys/sys/cdbr.h $out/include/cdbr.h
install -D $BSDSRCDIR/sys/sys/featuretest.h \
$out/include/sys/featuretest.h
install -D $BSDSRCDIR/sys/sys/md5.h $out/include/md5.h
install -D $BSDSRCDIR/sys/sys/rmd160.h $out/include/rmd160.h
install -D $BSDSRCDIR/sys/sys/sha1.h $out/include/sha1.h
install -D $BSDSRCDIR/sys/sys/sha2.h $out/include/sha2.h
install -D $BSDSRCDIR/sys/sys/queue.h $out/include/sys/queue.h
install -D $BSDSRCDIR/include/vis.h $out/include/vis.h
install -D $BSDSRCDIR/include/db.h $out/include/db.h
install -D $BSDSRCDIR/include/netconfig.h $out/include/netconfig.h
install -D $BSDSRCDIR/include/utmpx.h $out/include/utmpx.h
install -D $BSDSRCDIR/include/tzfile.h $out/include/tzfile.h
install -D $BSDSRCDIR/sys/sys/tree.h $out/include/sys/tree.h
install -D $BSDSRCDIR/include/nl_types.h $out/include/nl_types.h
install -D $BSDSRCDIR/include/stringlist.h $out/include/stringlist.h
# Collapse includes slightly to fix dangling reference
install -D $BSDSRCDIR/common/include/rpc/types.h $out/include/rpc/types.h
sed -i '1s;^;#include "nbtool_config.h"\n;' $out/include/rpc/types.h
'' + lib.optionalString stdenv.isDarwin ''
mkdir -p $out/include/ssp
touch $out/include/ssp/ssp.h
'' + ''
mkdir -p $out/lib/pkgconfig
substitute ${./libbsd-overlay.pc} $out/lib/pkgconfig/libbsd-overlay.pc \
--subst-var-by out $out \
--subst-var-by version ${version}
'';
extraPaths = with self; [ include.src libc.src libutil.src
(fetchNetBSD "external/bsd/flex" "9.2" "0h98jpfj7vx5zh7vd7bk6b1hmzgkcb757a8j6d9zgygxxv13v43m")
(fetchNetBSD "sys/sys" "9.2" "0zawhw51klaigqqwkx0lzrx3mim2jywrc24cm7c66qsf1im9awgd")
(fetchNetBSD "common/include/rpc/types.h" "9.2" "0n2df12mlc3cbc48jxq35yzl1y7ghgpykvy7jnfh898rdhac7m9a")
] ++ libutil.extraPaths ++ _mainLibcExtraPaths;
});
# HACK: to ensure parent directories exist. This emulates GNU
# installs -D option. No alternative seems to exist in BSD install.
install = let binstall = writeText "binstall" ''
#!${stdenv.shell}
for last in $@; do true; done
mkdir -p $(dirname $last)
xinstall "$@"
''; in mkDerivation {
path = "usr.bin/xinstall";
version = "9.2";
sha256 = "1f6pbz3qv1qcrchdxif8p5lbmnwl8b9nq615hsd3cyl4avd5bfqj";
extraPaths = with self; [ mtree.src make.src ];
nativeBuildInputs = with buildPackages.netbsd; [
bsdSetupHook netbsdSetupHook
makeMinimal
mandoc groff rsync
];
skipIncludesPhase = true;
buildInputs = with self; compatIfNeeded ++ [ fts ];
installPhase = ''
runHook preInstall
install -D install.1 $out/share/man/man1/install.1
install -D xinstall $out/bin/xinstall
install -D -m 0550 ${binstall} $out/bin/binstall
ln -s $out/bin/binstall $out/bin/install
runHook postInstall
'';
setupHook = ./install-setup-hook.sh;
};
fts = mkDerivation {
pname = "fts";
path = "include/fts.h";
sha256 = "01d4fpxvz1pgzfk5xznz5dcm0x0gdzwcsfm1h3d0xc9kc6hj2q77";
version = "9.2";
nativeBuildInputs = with buildPackages.netbsd; [
bsdSetupHook netbsdSetupHook rsync
];
propagatedBuildInputs = with self; compatIfNeeded;
extraPaths = with self; [
(fetchNetBSD "lib/libc/gen/fts.c" "9.2" "1a8hmf26242nmv05ipn3ircxb0jqmmi66rh78kkyi9vjwkfl3qn7")
(fetchNetBSD "lib/libc/include/namespace.h" "9.2" "0kksr3pdwdc1cplqf5z12ih4cml6l11lqrz91f7hjjm64y7785kc")
(fetchNetBSD "lib/libc/gen/fts.3" "9.2" "1asxw0n3fhjdadwkkq3xplfgqgl3q32w1lyrvbakfa3gs0wz5zc1")
];
skipIncludesPhase = true;
buildPhase = ''
"$CC" -c -Iinclude -Ilib/libc/include lib/libc/gen/fts.c \
-o lib/libc/gen/fts.o
"$AR" -rsc libfts.a lib/libc/gen/fts.o
'';
installPhase = ''
runHook preInstall
install -D lib/libc/gen/fts.3 $out/share/man/man3/fts.3
install -D include/fts.h $out/include/fts.h
install -D lib/libc/include/namespace.h $out/include/namespace.h
install -D libfts.a $out/lib/libfts.a
runHook postInstall
'';
setupHooks = [
../../../build-support/setup-hooks/role.bash
./fts-setup-hook.sh
];
};
# Don't add this to nativeBuildInputs directly. Use statHook instead.
stat = mkDerivation {
path = "usr.bin/stat";
version = "9.2";
sha256 = "18nqwlndfc34qbbgqx5nffil37jfq9aw663ippasfxd2hlyc106x";
nativeBuildInputs = with buildPackages.netbsd; [
bsdSetupHook netbsdSetupHook
makeMinimal
install mandoc groff rsync
];
};
# stat isn't in POSIX, and NetBSD stat supports a completely
# different range of flags than GNU stat, so including it in PATH
# breaks stdenv. Work around that with a hook that will point
# NetBSD's build system and NetBSD stat without including it in
# PATH.
statHook = makeSetupHook {
name = "netbsd-stat-hook";
} (writeText "netbsd-stat-hook-impl" ''
makeFlagsArray+=(TOOL_STAT=${self.stat}/bin/stat)
'');
tsort = mkDerivation {
path = "usr.bin/tsort";
version = "9.2";
sha256 = "1dqvf9gin29nnq3c4byxc7lfd062pg7m84843zdy6n0z63hnnwiq";
nativeBuildInputs = with buildPackages.netbsd; [
bsdSetupHook netbsdSetupHook
makeMinimal
install mandoc groff rsync
];
};
lorder = mkDerivation {
path = "usr.bin/lorder";
version = "9.2";
sha256 = "0rjf9blihhm0n699vr2bg88m4yjhkbxh6fxliaay3wxkgnydjwn2";
nativeBuildInputs = with buildPackages.netbsd; [
bsdSetupHook netbsdSetupHook
makeMinimal
install mandoc groff rsync
];
};
##
## END BOOTSTRAPPING
##
##
## START COMMAND LINE TOOLS
##
make = mkDerivation {
path = "usr.bin/make";
sha256 = "0vi73yicbmbp522qzqvd979cx6zm5jakhy77xh73c1kygf8klccs";
version = "9.2";
postPatch = ''
substituteInPlace $BSDSRCDIR/share/mk/bsd.doc.mk \
--replace '-o ''${DOCOWN}' "" \
--replace '-g ''${DOCGRP}' ""
for mk in $BSDSRCDIR/share/mk/bsd.inc.mk $BSDSRCDIR/share/mk/bsd.kinc.mk; do
substituteInPlace $mk \
--replace '-o ''${BINOWN}' "" \
--replace '-g ''${BINGRP}' ""
done
substituteInPlace $BSDSRCDIR/share/mk/bsd.kmodule.mk \
--replace '-o ''${KMODULEOWN}' "" \
--replace '-g ''${KMODULEGRP}' ""
substituteInPlace $BSDSRCDIR/share/mk/bsd.lib.mk \
--replace '-o ''${LIBOWN}' "" \
--replace '-g ''${LIBGRP}' "" \
--replace '-o ''${DEBUGOWN}' "" \
--replace '-g ''${DEBUGGRP}' ""
substituteInPlace $BSDSRCDIR/share/mk/bsd.lua.mk \
--replace '-o ''${LIBOWN}' "" \
--replace '-g ''${LIBGRP}' ""
substituteInPlace $BSDSRCDIR/share/mk/bsd.man.mk \
--replace '-o ''${MANOWN}' "" \
--replace '-g ''${MANGRP}' ""
substituteInPlace $BSDSRCDIR/share/mk/bsd.nls.mk \
--replace '-o ''${NLSOWN}' "" \
--replace '-g ''${NLSGRP}' ""
substituteInPlace $BSDSRCDIR/share/mk/bsd.prog.mk \
--replace '-o ''${BINOWN}' "" \
--replace '-g ''${BINGRP}' "" \
--replace '-o ''${RUMPBINOWN}' "" \
--replace '-g ''${RUMPBINGRP}' "" \
--replace '-o ''${DEBUGOWN}' "" \
--replace '-g ''${DEBUGGRP}' ""
# make needs this to pick up our sys make files
export NIX_CFLAGS_COMPILE+=" -D_PATH_DEFSYSPATH=\"$out/share/mk\""
substituteInPlace $BSDSRCDIR/share/mk/bsd.lib.mk \
--replace '_INSTRANLIB=''${empty(PRESERVE):?-a "''${RANLIB} -t":}' '_INSTRANLIB='
substituteInPlace $BSDSRCDIR/share/mk/bsd.kinc.mk \
--replace /bin/rm rm
'' + lib.optionalString stdenv.isDarwin ''
substituteInPlace $BSDSRCDIR/share/mk/bsd.sys.mk \
--replace '-Wl,--fatal-warnings' "" \
--replace '-Wl,--warn-shared-textrel' ""
'';
postInstall = ''
make -C $BSDSRCDIR/share/mk FILESDIR=$out/share/mk install
'';
extraPaths = [
(fetchNetBSD "share/mk" "9.2" "0w9x77cfnm6zwy40slradzi0ip9gz80x6lk7pvnlxzsr2m5ra5sy")
];
};
mtree = mkDerivation {
path = "usr.sbin/mtree";
version = "9.2";
sha256 = "04p7w540vz9npvyb8g8hcf2xa05phn1y88hsyrcz3vwanvpc0yv9";
extraPaths = with self; [ mknod.src ];
};
mknod = mkDerivation {
path = "sbin/mknod";
version = "9.2";
sha256 = "1d9369shzwgixz3nph991i8q5vk7hr04py3n9avbfbhzy4gndqs2";
};
getent = mkDerivation {
path = "usr.bin/getent";
sha256 = "1qngywcmm0y7nl8h3n8brvkxq4jw63szbci3kc1q6a6ndhycbbvr";
version = "9.2";
patches = [ ./getent.patch ];
};
getconf = mkDerivation {
path = "usr.bin/getconf";
sha256 = "122vslz4j3h2mfs921nr2s6m078zcj697yrb75rwp2hnw3qz4s8q";
version = "9.2";
};
locale = mkDerivation {
path = "usr.bin/locale";
version = "9.2";
sha256 = "0kk6v9k2bygq0wf9gbinliqzqpzs9bgxn0ndyl2wcv3hh2bmsr9p";
patches = [ ./locale.patch ];
NIX_CFLAGS_COMPILE = "-DYESSTR=__YESSTR -DNOSTR=__NOSTR";
};
rpcgen = mkDerivation {
path = "usr.bin/rpcgen";
version = "9.2";
sha256 = "1kfgfx54jg98wbg0d95p0rvf4w0302v8fz724b0bdackdsrd4988";
};
genassym = mkDerivation {
path = "usr.bin/genassym";
version = "9.2";
sha256 = "1acl1dz5kvh9h5806vkz2ap95rdsz7phmynh5i3x5y7agbki030c";
};
gencat = mkDerivation {
path = "usr.bin/gencat";
version = "9.2";
sha256 = "0gd463x1hg36bhr7y0xryb5jyxk0z0g7xvy8rgk82nlbnlnsbbwb";
};
nbperf = mkDerivation {
path = "usr.bin/nbperf";
version = "9.2";
sha256 = "1nxc302vgmjhm3yqdivqyfzslrg0vjpbss44s74rcryrl19mma9r";
};
tic = mkDerivation {
path = "tools/tic";
version = "9.2";
sha256 = "092y7db7k4kh2jq8qc55126r5qqvlb8lq8mhmy5ipbi36hwb4zrz";
HOSTPROG = "tic";
buildInputs = with self; compatIfNeeded;
nativeBuildInputs = with buildPackages.netbsd; [
bsdSetupHook netbsdSetupHook
makeMinimal
install mandoc groff nbperf rsync
];
makeFlags = defaultMakeFlags ++ [ "TOOLDIR=$(out)" ];
extraPaths = with self; [
libterminfo.src
(fetchNetBSD "usr.bin/tic" "9.2" "1mwdfg7yx1g43ss378qsgl5rqhsxskqvsd2mqvrn38qw54i8v5i1")
(fetchNetBSD "tools/Makefile.host" "9.2" "15b4ab0n36lqj00j5lz2xs83g7l8isk3wx1wcapbrn66qmzz2sxy")
];
};
uudecode = mkDerivation {
path = "usr.bin/uudecode";
version = "9.2";
sha256 = "00a3zmh15pg4vx6hz0kaa5mi8d2b1sj4h512d7p6wbvxq6mznwcn";
NIX_CFLAGS_COMPILE = lib.optional stdenv.isLinux "-DNO_BASE64";
};
cksum = mkDerivation {
path = "usr.bin/cksum";
version = "9.2";
sha256 = "0msfhgyvh5c2jmc6qjnf12c378dhw32ffsl864qz4rdb2b98rfcq";
meta.platforms = lib.platforms.netbsd;
};
config = mkDerivation {
path = "usr.bin/config";
version = "9.2";
sha256 = "1yz3n4hncdkk6kp595fh2q5lg150vpqg8iw2dccydkyw4y3hgsjj";
NIX_CFLAGS_COMPILE = [ "-DMAKE_BOOTSTRAP" ];
nativeBuildInputs = with buildPackages.netbsd; [
bsdSetupHook netbsdSetupHook
makeMinimal install mandoc byacc flex rsync
];
buildInputs = with self; compatIfNeeded;
extraPaths = with self; [ cksum.src ];
};
##
## END COMMAND LINE TOOLS
##
##
## START HEADERS
##
include = mkDerivation {
path = "include";
version = "9.2";
sha256 = "0nxnmj4c8s3hb9n3fpcmd0zl3l1nmhivqgi9a35sis943qvpgl9h";
nativeBuildInputs = with buildPackages.netbsd; [
bsdSetupHook netbsdSetupHook
makeMinimal
install mandoc groff rsync nbperf rpcgen
];
# The makefiles define INCSDIR per subdirectory, so we have to set
# something else on the command line so those definitions aren't
# overridden.
postPatch = ''
find "$BSDSRCDIR" -name Makefile -exec \
sed -i -E \
-e 's_/usr/include_''${INCSDIR0}_' \
{} \;
'';
# multiple header dirs, see above
postConfigure = ''
makeFlags=''${makeFlags/INCSDIR/INCSDIR0}
'';
extraPaths = with self; [ common ];
headersOnly = true;
noCC = true;
meta.platforms = lib.platforms.netbsd;
makeFlags = defaultMakeFlags ++ [ "RPCGEN_CPP=${buildPackages.stdenv.cc.cc}/bin/cpp" ];
};
common = fetchNetBSD "common" "9.2" "1pfylz9r3ap5wnwwbwczbfjb1m5qdyspzbnmxmcdkpzz2zgj64b9";
sys-headers = mkDerivation {
pname = "sys-headers";
path = "sys";
version = "9.2";
sha256 = "03s18q8d9giipf05bx199fajc2qwikji0djz7hw63d2lya6bfnpj";
patches = [
# Fix this error when building bootia32.efi and bootx64.efi:
# error: PHDR segment not covered by LOAD segment
./no-dynamic-linker.patch
# multiple header dirs, see above
./sys-headers-incsdir.patch
];
# multiple header dirs, see above
inherit (self.include) postPatch;
CONFIG = "GENERIC";
propagatedBuildInputs = with self; [ include ];
nativeBuildInputs = with buildPackages.netbsd; [
bsdSetupHook netbsdSetupHook
makeMinimal install tsort lorder statHook rsync uudecode config genassym
];
postConfigure = ''
pushd arch/$MACHINE/conf
config $CONFIG
popd
''
# multiple header dirs, see above
+ self.include.postConfigure;
makeFlags = defaultMakeFlags ++ [ "FIRMWAREDIR=$(out)/libdata/firmware" ];
hardeningDisable = [ "pic" ];
MKKMOD = "no";
NIX_CFLAGS_COMPILE = [ "-Wa,--no-warn" ];
postBuild = ''
make -C arch/$MACHINE/compile/$CONFIG $makeFlags
'';
postInstall = ''
cp arch/$MACHINE/compile/$CONFIG/netbsd $out
'';
meta.platforms = lib.platforms.netbsd;
extraPaths = with self; [ common ];
installPhase = "includesPhase";
dontBuild = true;
noCC = true;
};
# The full kernel. We do the funny thing of overridding the headers to the
# full kernal and not vice versa to avoid infinite recursion -- the headers
# come earlier in the bootstrap.
sys = self.sys-headers.override {
pname = "sys";
installPhase = null;
noCC = false;
dontBuild = false;
};
headers = symlinkJoin {
name = "netbsd-headers-9.2";
paths = with self; [
include
sys-headers
libpthread-headers
];
meta.platforms = lib.platforms.netbsd;
};
##
## END HEADERS
##
##
## START LIBRARIES
##
libutil = mkDerivation {
path = "lib/libutil";
version = "9.2";
sha256 = "02gm5a5zhh8qp5r5q5r7x8x6x50ir1i0ncgsnfwh1vnrz6mxbq7z";
extraPaths = with self; [ common libc.src sys.src ];
nativeBuildInputs = with buildPackages.netbsd; [
bsdSetupHook netbsdSetupHook
makeMinimal
byacc install tsort lorder mandoc statHook rsync
];
buildInputs = with self; [ headers ];
SHLIBINSTALLDIR = "$(out)/lib";
};
libedit = mkDerivation {
path = "lib/libedit";
version = "9.2";
sha256 = "1wqhngraxwqk4jgrf5f18jy195yrp7c06n1gf31pbplq79mg1bcj";
buildInputs = with self; [ libterminfo libcurses ];
propagatedBuildInputs = with self; compatIfNeeded;
SHLIBINSTALLDIR = "$(out)/lib";
makeFlags = defaultMakeFlags ++ [ "LIBDO.terminfo=${self.libterminfo}/lib" ];
postPatch = ''
sed -i '1i #undef bool_t' el.h
substituteInPlace config.h \
--replace "#define HAVE_STRUCT_DIRENT_D_NAMLEN 1" ""
substituteInPlace readline/Makefile --replace /usr/include "$out/include"
'';
NIX_CFLAGS_COMPILE = [
"-D__noinline="
"-D__scanflike(a,b)="
"-D__va_list=va_list"
];
};
libterminfo = mkDerivation {
path = "lib/libterminfo";
version = "9.2";
sha256 = "0pq05k3dj0dfsczv07frnnji92mazmy2qqngqbx2zgqc1x251414";
nativeBuildInputs = with buildPackages.netbsd; [
bsdSetupHook netbsdSetupHook
makeMinimal install tsort lorder mandoc statHook nbperf tic rsync
];
buildInputs = with self; compatIfNeeded;
SHLIBINSTALLDIR = "$(out)/lib";
postPatch = ''
substituteInPlace term.c --replace /usr/share $out/share
substituteInPlace setupterm.c \
--replace '#include <curses.h>' 'void use_env(bool);'
'';
postBuild = ''
make -C $BSDSRCDIR/share/terminfo $makeFlags BINDIR=$out/share
'';
postInstall = ''
make -C $BSDSRCDIR/share/terminfo $makeFlags BINDIR=$out/share install
'';
extraPaths = with self; [
(fetchNetBSD "share/terminfo" "9.2" "1vh9rl4w8118a9qdpblfxmv1wkpm83rm9gb4rzz5bpm56i6d7kk7")
];
};
libcurses = mkDerivation {
path = "lib/libcurses";
version = "9.2";
sha256 = "0pd0dggl3w4bv5i5h0s1wrc8hr66n4hkv3zlklarwfdhc692fqal";
buildInputs = with self; [ libterminfo ];
NIX_CFLAGS_COMPILE = [
"-D__scanflike(a,b)="
"-D__va_list=va_list"
"-D__warn_references(a,b)="
] ++ lib.optional stdenv.isDarwin "-D__strong_alias(a,b)=";
propagatedBuildInputs = with self; compatIfNeeded;
MKDOC = "no"; # missing vfontedpr
makeFlags = defaultMakeFlags ++ [ "LIBDO.terminfo=${self.libterminfo}/lib" ];
postPatch = lib.optionalString (!stdenv.isDarwin) ''
substituteInPlace printw.c \
--replace "funopen(win, NULL, __winwrite, NULL, NULL)" NULL \
--replace "__strong_alias(vwprintw, vw_printw)" 'extern int vwprintw(WINDOW*, const char*, va_list) __attribute__ ((alias ("vw_printw")));'
substituteInPlace scanw.c \
--replace "__strong_alias(vwscanw, vw_scanw)" 'extern int vwscanw(WINDOW*, const char*, va_list) __attribute__ ((alias ("vw_scanw")));'
'';
};
column = mkDerivation {
path = "usr.bin/column";
version = "9.2";
sha256 = "0r6b0hjn5ls3j3sv6chibs44fs32yyk2cg8kh70kb4cwajs4ifyl";
};
libossaudio = mkDerivation {
path = "lib/libossaudio";
version = "9.2";
sha256 = "16l3bfy6dcwqnklvh3x0ps8ld1y504vf57v9rx8f9adzhb797jh0";
meta.platforms = lib.platforms.netbsd;
};
librpcsvc = mkDerivation {
path = "lib/librpcsvc";
version = "9.2";
sha256 = "1q34pfiyjbrgrdqm46jwrsqms49ly6z3b0xh1wg331zga900vq5n";
makeFlags = defaultMakeFlags ++ [ "INCSDIR=$(out)/include/rpcsvc" ];
meta.platforms = lib.platforms.netbsd;
nativeBuildInputs = with buildPackages.netbsd; [
bsdSetupHook netbsdSetupHook
makeMinimal
install tsort lorder rpcgen statHook
];
};
librt = mkDerivation {
path = "lib/librt";
version = "9.2";
sha256 = "07f8mpjcqh5kig5z5sp97fg55mc4dz6aa1x5g01nv2pvbmqczxc6";
meta.platforms = lib.platforms.netbsd;
extraPaths = with self; [ libc.src ] ++ libc.extraPaths;
postPatch = ''
sed -i 's,/usr\(/include/sys/syscall.h\),${self.headers}\1,g' \
$BSDSRCDIR/lib/{libc,librt}/sys/Makefile.inc
'';
};
libcrypt = mkDerivation {
path = "lib/libcrypt";
version = "9.2";
sha256 = "0siqan1wdqmmhchh2n8w6a8x1abbff8n4yb6jrqxap3hqn8ay54g";
SHLIBINSTALLDIR = "$(out)/lib";
meta.platforms = lib.platforms.netbsd;
};
libpthread-headers = mkDerivation {
pname = "libpthread-headers";
path = "lib/libpthread";
version = "9.2";
sha256 = "0mlmc31k509dwfmx5s2x010wxjc44mr6y0cbmk30cfipqh8c962h";
installPhase = "includesPhase";
dontBuild = true;
noCC = true;
meta.platforms = lib.platforms.netbsd;
};
libpthread = self.libpthread-headers.override {
pname = "libpthread";
installPhase = null;
noCC = false;
dontBuild = false;
buildInputs = with self; [ headers ];
SHLIBINSTALLDIR = "$(out)/lib";
extraPaths = with self; [ common libc.src librt.src sys.src ];
};
libresolv = mkDerivation {
path = "lib/libresolv";
version = "9.2";
sha256 = "1am74s74mf1ynwz3p4ncjkg63f78a1zjm983q166x4sgzps15626";
meta.platforms = lib.platforms.netbsd;
extraPaths = with self; [ libc.src ];
};
libm = mkDerivation {
path = "lib/libm";
version = "9.2";
sha256 = "1apwfr26shdmbqqnmg7hxf7bkfxw44ynqnnnghrww9bnhqdnsy92";
SHLIBINSTALLDIR = "$(out)/lib";
meta.platforms = lib.platforms.netbsd;
extraPaths = with self; [ sys.src ];
};
i18n_module = mkDerivation {
path = "lib/i18n_module";
version = "9.2";
sha256 = "0w6y5v3binm7gf2kn7y9jja8k18rhnyl55cvvfnfipjqdxvxd9jd";
meta.platforms = lib.platforms.netbsd;
extraPaths = with self; [ libc.src ];
};
csu = mkDerivation {
path = "lib/csu";
version = "9.2";
sha256 = "0al5jfazvhlzn9hvmnrbchx4d0gm282hq5gp4xs2zmj9ycmf6d03";
meta.platforms = lib.platforms.netbsd;
nativeBuildInputs = with buildPackages.netbsd; [
bsdSetupHook netbsdSetupHook
makeMinimal
install mandoc groff flex
byacc genassym gencat lorder tsort statHook rsync
];
buildInputs = with self; [ headers ];
extraPaths = with self; [ sys.src ld_elf_so.src ];
};
ld_elf_so = mkDerivation {
path = "libexec/ld.elf_so";
version = "9.2";
sha256 = "0ia9mqzdljly0vqfwflm5mzz55k7qsr4rw2bzhivky6k30vgirqa";
meta.platforms = lib.platforms.netbsd;
LIBC_PIC = "${self.libc}/lib/libc_pic.a";
# Hack to prevent a symlink being installed here for compatibility.
SHLINKINSTALLDIR = "/usr/libexec";
USE_FORT = "yes";
makeFlags = defaultMakeFlags ++ [ "BINDIR=$(out)/libexec" "CLIBOBJ=${self.libc}/lib" ];
extraPaths = with self; [ libc.src ] ++ libc.extraPaths;
};
_mainLibcExtraPaths = with self; [
common i18n_module.src sys.src
ld_elf_so.src libpthread.src libm.src libresolv.src
librpcsvc.src libutil.src librt.src libcrypt.src
];
libc = mkDerivation {
path = "lib/libc";
version = "9.2";
sha256 = "1y9c13igg0kai07sqvf9cm6yqmd8lhfd8hq3q7biilbgs1l99as3";
USE_FORT = "yes";
MKPROFILE = "no";
extraPaths = with self; _mainLibcExtraPaths ++ [
(fetchNetBSD "external/bsd/jemalloc" "9.2" "0cq704swa0h2yxv4gc79z2lwxibk9k7pxh3q5qfs7axx3jx3n8kb")
];
nativeBuildInputs = with buildPackages.netbsd; [
bsdSetupHook netbsdSetupHook
makeMinimal
install mandoc groff flex
byacc genassym gencat lorder tsort statHook rsync rpcgen
];
buildInputs = with self; [ headers csu ];
NIX_CFLAGS_COMPILE = "-B${self.csu}/lib";
meta.platforms = lib.platforms.netbsd;
SHLIBINSTALLDIR = "$(out)/lib";
MKPICINSTALL = "yes";
NLSDIR = "$(out)/share/nls";
makeFlags = defaultMakeFlags ++ [ "FILESDIR=$(out)/var/db"];
postInstall = ''
pushd ${self.headers}
find . -type d -exec mkdir -p $out/\{} \;
find . \( -type f -o -type l \) -exec cp -pr \{} $out/\{} \;
popd
pushd ${self.csu}
find . -type d -exec mkdir -p $out/\{} \;
find . \( -type f -o -type l \) -exec cp -pr \{} $out/\{} \;
popd
NIX_CFLAGS_COMPILE+=" -B$out/lib"
NIX_CFLAGS_COMPILE+=" -I$out/include"
NIX_LDFLAGS+=" -L$out/lib"
make -C $BSDSRCDIR/lib/libpthread $makeFlags
make -C $BSDSRCDIR/lib/libpthread $makeFlags install
make -C $BSDSRCDIR/lib/libm $makeFlags
make -C $BSDSRCDIR/lib/libm $makeFlags install
make -C $BSDSRCDIR/lib/libresolv $makeFlags
make -C $BSDSRCDIR/lib/libresolv $makeFlags install
make -C $BSDSRCDIR/lib/librpcsvc $makeFlags
make -C $BSDSRCDIR/lib/librpcsvc $makeFlags install
make -C $BSDSRCDIR/lib/i18n_module $makeFlags
make -C $BSDSRCDIR/lib/i18n_module $makeFlags install
make -C $BSDSRCDIR/lib/libutil $makeFlags
make -C $BSDSRCDIR/lib/libutil $makeFlags install
make -C $BSDSRCDIR/lib/librt $makeFlags
make -C $BSDSRCDIR/lib/librt $makeFlags install
make -C $BSDSRCDIR/lib/libcrypt $makeFlags
make -C $BSDSRCDIR/lib/libcrypt $makeFlags install
'';
inherit (self.librt) postPatch;
};
#
# END LIBRARIES
#
#
# START MISCELLANEOUS
#
dict = mkDerivation {
path = "share/dict";
noCC = true;
version = "9.2";
sha256 = "0svfc0byk59ri37pyjslv4c4rc7zw396r73mr593i78d39q5g3ad";
makeFlags = defaultMakeFlags ++ [ "BINDIR=$(out)/share" ];
};
misc = mkDerivation {
path = "share/misc";
noCC = true;
version = "9.2";
sha256 = "1j2cdssdx6nncv8ffj7f7ybl7m9hadjj8vm8611skqdvxnjg6nbc";
makeFlags = defaultMakeFlags ++ [ "BINDIR=$(out)/share" ];
};
man = mkDerivation {
path = "share/man";
noCC = true;
version = "9.2";
sha256 = "1l4lmj4kmg8dl86x94sr45w0xdnkz8dn4zjx0ipgr9bnq98663zl";
# man0 generates a man.pdf using ps2pdf, but doesn't install it later,
# so we can avoid the dependency on ghostscript
postPatch = ''
substituteInPlace man0/Makefile --replace "ps2pdf" "echo noop "
'';
makeFlags = defaultMakeFlags ++ [
"FILESDIR=$(out)/share"
"MKRUMP=no" # would require to have additional path sys/rump/share/man
];
};
#
# END MISCELLANEOUS
#
})

View file

@ -0,0 +1,4 @@
# See pkgs/build-support/setup-hooks/role.bash
getHostRole
export NIX_LDFLAGS${role_post}+=" -lfts"

View file

@ -0,0 +1,455 @@
Author: Matthew Bauer
Description: Remove unavailable getent databases
Version: 7.1.2
--- a/getent.c 2018-04-16 13:33:49.000000000 -0500
+++ b/getent.c 2018-04-16 13:29:30.000000000 -0500
@@ -42,7 +42,6 @@
#include <grp.h>
#include <limits.h>
#include <netdb.h>
-#include <netgroup.h>
#include <pwd.h>
#include <stdio.h>
#include <stdarg.h>
@@ -57,27 +56,16 @@
#include <arpa/nameser.h>
#include <net/if.h>
-#include <net/if_ether.h>
#include <netinet/in.h> /* for INET6_ADDRSTRLEN */
-#include <rpc/rpcent.h>
-
-#include <disktab.h>
-
static int usage(void) __attribute__((__noreturn__));
static int parsenum(const char *, unsigned long *);
-static int disktab(int, char *[]);
-static int gettytab(int, char *[]);
-static int ethers(int, char *[]);
static int group(int, char *[]);
static int hosts(int, char *[]);
-static int netgroup(int, char *[]);
static int networks(int, char *[]);
static int passwd(int, char *[]);
-static int printcap(int, char *[]);
static int protocols(int, char *[]);
-static int rpc(int, char *[]);
static int services(int, char *[]);
static int shells(int, char *[]);
@@ -92,17 +80,11 @@
const char *name;
int (*callback)(int, char *[]);
} databases[] = {
- { "disktab", disktab, },
- { "ethers", ethers, },
- { "gettytab", gettytab, },
{ "group", group, },
{ "hosts", hosts, },
- { "netgroup", netgroup, },
{ "networks", networks, },
{ "passwd", passwd, },
- { "printcap", printcap, },
{ "protocols", protocols, },
- { "rpc", rpc, },
{ "services", services, },
{ "shells", shells, },
@@ -195,49 +177,6 @@
(void)printf("\n");
}
-
- /*
- * ethers
- */
-
-static int
-ethers(int argc, char *argv[])
-{
- char hostname[MAXHOSTNAMELEN + 1], *hp;
- struct ether_addr ea, *eap;
- int i, rv;
-
- assert(argc > 1);
- assert(argv != NULL);
-
-#define ETHERSPRINT (void)printf("%-17s %s\n", ether_ntoa(eap), hp)
-
- rv = RV_OK;
- if (argc == 2) {
- warnx("Enumeration not supported on ethers");
- rv = RV_NOENUM;
- } else {
- for (i = 2; i < argc; i++) {
- if ((eap = ether_aton(argv[i])) == NULL) {
- eap = &ea;
- hp = argv[i];
- if (ether_hostton(hp, eap) != 0) {
- rv = RV_NOTFOUND;
- break;
- }
- } else {
- hp = hostname;
- if (ether_ntohost(hp, eap) != 0) {
- rv = RV_NOTFOUND;
- break;
- }
- }
- ETHERSPRINT;
- }
- }
- return rv;
-}
-
/*
* group
*/
@@ -298,7 +237,7 @@
hosts(int argc, char *argv[])
{
struct hostent *he;
- char addr[IN6ADDRSZ];
+ char addr[NS_IN6ADDRSZ];
int i, rv;
assert(argc > 1);
@@ -312,9 +251,9 @@
} else {
for (i = 2; i < argc; i++) {
if (inet_pton(AF_INET6, argv[i], (void *)addr) > 0)
- he = gethostbyaddr(addr, IN6ADDRSZ, AF_INET6);
+ he = gethostbyaddr(addr, NS_IN6ADDRSZ, AF_INET6);
else if (inet_pton(AF_INET, argv[i], (void *)addr) > 0)
- he = gethostbyaddr(addr, INADDRSZ, AF_INET);
+ he = gethostbyaddr(addr, NS_INADDRSZ, AF_INET);
else
he = gethostbyname(argv[i]);
if (he != NULL)
@@ -330,48 +269,6 @@
}
/*
- * netgroup
- */
-static int
-netgroup(int argc, char *argv[])
-{
- int rv, i;
- bool first;
- const char *host, *user, *domain;
-
- assert(argc > 1);
- assert(argv != NULL);
-
-#define NETGROUPPRINT(s) (((s) != NULL) ? (s) : "")
-
- rv = RV_OK;
- if (argc == 2) {
- warnx("Enumeration not supported on netgroup");
- rv = RV_NOENUM;
- } else {
- for (i = 2; i < argc; i++) {
- setnetgrent(argv[i]);
- first = true;
- while (getnetgrent(&host, &user, &domain) != 0) {
- if (first) {
- first = false;
- (void)fputs(argv[i], stdout);
- }
- (void)printf(" (%s,%s,%s)",
- NETGROUPPRINT(host),
- NETGROUPPRINT(user),
- NETGROUPPRINT(domain));
- }
- if (!first)
- (void)putchar('\n');
- endnetgrent();
- }
- }
-
- return rv;
-}
-
- /*
* networks
*/
@@ -464,227 +361,6 @@
return rv;
}
-static char *
-mygetent(const char * const * db_array, const char *name)
-{
- char *buf = NULL;
- int error;
-
- switch (error = cgetent(&buf, db_array, name)) {
- case -3:
- warnx("tc= loop in record `%s' in `%s'", name, db_array[0]);
- break;
- case -2:
- warn("system error fetching record `%s' in `%s'", name,
- db_array[0]);
- break;
- case -1:
- case 0:
- break;
- case 1:
- warnx("tc= reference not found in record for `%s' in `%s'",
- name, db_array[0]);
- break;
- default:
- warnx("unknown error %d in record `%s' in `%s'", error, name,
- db_array[0]);
- break;
- }
- return buf;
-}
-
-static char *
-mygetone(const char * const * db_array, int first)
-{
- char *buf = NULL;
- int error;
-
- switch (error = (first ? cgetfirst : cgetnext)(&buf, db_array)) {
- case -2:
- warnx("tc= loop in `%s'", db_array[0]);
- break;
- case -1:
- warn("system error fetching record in `%s'", db_array[0]);
- break;
- case 0:
- case 1:
- break;
- case 2:
- warnx("tc= reference not found in `%s'", db_array[0]);
- break;
- default:
- warnx("unknown error %d in `%s'", error, db_array[0]);
- break;
- }
- return buf;
-}
-
-static void
-capprint(const char *cap)
-{
- char *c = strchr(cap, ':');
- if (c)
- if (c == cap)
- (void)printf("true\n");
- else {
- int l = (int)(c - cap);
- (void)printf("%*.*s\n", l, l, cap);
- }
- else
- (void)printf("%s\n", cap);
-}
-
-static void
-prettyprint(char *b)
-{
-#define TERMWIDTH 65
- int did = 0;
- size_t len;
- char *s, c;
-
- for (;;) {
- len = strlen(b);
- if (len <= TERMWIDTH) {
-done:
- if (did)
- printf("\t:");
- printf("%s\n", b);
- return;
- }
- for (s = b + TERMWIDTH; s > b && *s != ':'; s--)
- continue;
- if (*s++ != ':')
- goto done;
- c = *s;
- *s = '\0';
- if (did)
- printf("\t:");
- did++;
- printf("%s\\\n", b);
- *s = c;
- b = s;
- }
-}
-
-static void
-handleone(const char * const *db_array, char *b, int recurse, int pretty,
- int level)
-{
- char *tc;
-
- if (level && pretty)
- printf("\n");
- if (pretty)
- prettyprint(b);
- else
- printf("%s\n", b);
- if (!recurse || cgetstr(b, "tc", &tc) <= 0)
- return;
-
- b = mygetent(db_array, tc);
- free(tc);
-
- if (b == NULL)
- return;
-
- handleone(db_array, b, recurse, pretty, ++level);
- free(b);
-}
-
-static int
-handlecap(const char *db, int argc, char *argv[])
-{
- static const char sfx[] = "=#:";
- const char *db_array[] = { db, NULL };
- char *b, *cap;
- int i, rv, c;
- size_t j;
- int expand = 1, recurse = 0, pretty = 0;
-
- assert(argc > 1);
- assert(argv != NULL);
-
- argc--;
- argv++;
- while ((c = getopt(argc, argv, "pnr")) != -1)
- switch (c) {
- case 'n':
- expand = 0;
- break;
- case 'r':
- expand = 0;
- recurse = 1;
- break;
- case 'p':
- pretty = 1;
- break;
- default:
- usage();
- break;
- }
-
- argc -= optind;
- argv += optind;
- csetexpandtc(expand);
- rv = RV_OK;
- if (argc == 0) {
- for (b = mygetone(db_array, 1); b; b = mygetone(db_array, 0)) {
- handleone(db_array, b, recurse, pretty, 0);
- free(b);
- }
- } else {
- if ((b = mygetent(db_array, argv[0])) == NULL)
- return RV_NOTFOUND;
- if (argc == 1)
- handleone(db_array, b, recurse, pretty, 0);
- else {
- for (i = 2; i < argc; i++) {
- for (j = 0; j < sizeof(sfx) - 1; j++) {
- cap = cgetcap(b, argv[i], sfx[j]);
- if (cap) {
- capprint(cap);
- break;
- }
- }
- if (j == sizeof(sfx) - 1)
- printf("false\n");
- }
- }
- free(b);
- }
- return rv;
-}
-
- /*
- * gettytab
- */
-
-static int
-gettytab(int argc, char *argv[])
-{
- return handlecap(_PATH_GETTYTAB, argc, argv);
-}
-
- /*
- * printcap
- */
-
-static int
-printcap(int argc, char *argv[])
-{
- return handlecap(_PATH_PRINTCAP, argc, argv);
-}
-
- /*
- * disktab
- */
-
-static int
-disktab(int argc, char *argv[])
-{
- return handlecap(_PATH_DISKTAB, argc, argv);
-}
-
/*
* protocols
*/
@@ -726,47 +402,6 @@
}
/*
- * rpc
- */
-
-static int
-rpc(int argc, char *argv[])
-{
- struct rpcent *re;
- unsigned long id;
- int i, rv;
-
- assert(argc > 1);
- assert(argv != NULL);
-
-#define RPCPRINT printfmtstrings(re->r_aliases, " ", " ", \
- "%-16s %6d", \
- re->r_name, re->r_number)
-
- setrpcent(1);
- rv = RV_OK;
- if (argc == 2) {
- while ((re = getrpcent()) != NULL)
- RPCPRINT;
- } else {
- for (i = 2; i < argc; i++) {
- if (parsenum(argv[i], &id))
- re = getrpcbynumber((int)id);
- else
- re = getrpcbyname(argv[i]);
- if (re != NULL)
- RPCPRINT;
- else {
- rv = RV_NOTFOUND;
- break;
- }
- }
- }
- endrpcent();
- return rv;
-}
-
- /*
* services
*/

View file

@ -0,0 +1,8 @@
addNetBSDInstallMakeFlags() {
export INSTALL_FILE="install -U -c"
export INSTALL_DIR="install -U -d"
export INSTALL_LINK="install -U -l h"
export INSTALL_SYMLINK="install -U -l s"
}
preConfigureHooks+=(addNetBSDInstallMakeFlags)

View file

@ -0,0 +1,11 @@
prefix=@out@
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: nbcompat
Description: NetBSD compatibility framework
Version: @version@
URL: https://www.netbsd.org/
Libs: -L${libdir} -lnbcompat
Cflags: -I${includedir} -DHAVE_NBTOOL_CONFIG_H -include nbtool_config.h

View file

@ -0,0 +1,85 @@
--- a/locale.c 2018-06-11 14:39:06.449762000 -0400
+++ b/locale.c 2018-06-11 14:42:28.461122899 -0400
@@ -56,14 +56,8 @@
#include <stringlist.h>
#include <unistd.h>
-#include "citrus_namespace.h"
-#include "citrus_region.h"
-#include "citrus_lookup.h"
-#include "setlocale_local.h"
-
/* Local prototypes */
void init_locales_list(void);
-void init_locales_list_alias(void);
void list_charmaps(void);
void list_locales(void);
const char *lookup_localecat(int);
@@ -221,6 +215,8 @@
};
#define NKWINFO (sizeof(kwinfo)/sizeof(kwinfo[0]))
+const char *_PathLocale = NULL;
+
int
main(int argc, char *argv[])
{
@@ -411,8 +407,7 @@
while ((dp = readdir(dirp)) != NULL) {
/* exclude "." and "..", _LOCALE_ALIAS_NAME */
if ((dp->d_name[0] != '.' || (dp->d_name[1] != '\0' &&
- (dp->d_name[1] != '.' || dp->d_name[2] != '\0'))) &&
- strcmp(_LOCALE_ALIAS_NAME, dp->d_name) != 0) {
+ (dp->d_name[1] != '.' || dp->d_name[2] != '\0')))) {
s = strdup(dp->d_name);
if (s == NULL)
err(1, "could not allocate memory");
@@ -431,48 +426,10 @@
if (sl_find(locales, "C") == NULL)
sl_add(locales, "C");
- init_locales_list_alias();
-
/* make output nicer, sort the list */
qsort(locales->sl_str, locales->sl_cur, sizeof(char *), scmp);
}
-void
-init_locales_list_alias(void)
-{
- char aliaspath[PATH_MAX];
- struct _lookup *hlookup;
- struct _region key, dat;
- size_t n;
- char *s, *t;
-
- _DIAGASSERT(locales != NULL);
- _DIAGASSERT(_PathLocale != NULL);
-
- (void)snprintf(aliaspath, sizeof(aliaspath),
- "%s/" _LOCALE_ALIAS_NAME, _PathLocale);
-
- if (_lookup_seq_open(&hlookup, aliaspath,
- _LOOKUP_CASE_SENSITIVE) == 0) {
- while (_lookup_seq_next(hlookup, &key, &dat) == 0) {
- n = _region_size((const struct _region *)&key);
- s = _region_head((const struct _region *)&key);
- for (t = s; n > 0 && *s!= '/'; --n, ++s);
- n = (size_t)(s - t);
- s = malloc(n + 1);
- if (s == NULL)
- err(1, "could not allocate memory");
- memcpy(s, t, n);
- s[n] = '\0';
- if (sl_find(locales, s) == NULL)
- sl_add(locales, s);
- else
- free(s);
- }
- _lookup_seq_close(hlookup);
- }
-}
-
/*
* Show current locale status, depending on environment variables
*/

View file

@ -0,0 +1,16 @@
===================================================================
RCS file: /ftp/cvs/cvsroot/src/sys/arch/i386/stand/efiboot/Makefile.efiboot,v
rcsdiff: /ftp/cvs/cvsroot/src/sys/arch/i386/stand/efiboot/Makefile.efiboot,v: warning: Unknown phrases like `commitid ...;' are present.
retrieving revision 1.16
retrieving revision 1.17
diff -u -p -r1.16 -r1.17
--- sys/arch/i386/stand/efiboot/Makefile.efiboot 2019/09/13 02:19:45 1.16
+++ sys/arch/i386/stand/efiboot/Makefile.efiboot 2020/04/04 15:30:46 1.17
@@ -41,6 +41,7 @@ BINMODE=444
.PATH: ${.CURDIR}/../../libsa
LDSCRIPT?= ${.CURDIR}/ldscript
+LDFLAGS+= --no-dynamic-linker --noinhibit-exec
LDFLAGS+= -nostdlib -T${LDSCRIPT} -Bsymbolic -shared -nocombreloc
CPPFLAGS+= -I$S -I${.CURDIR} -I${.CURDIR}/.. -I$S/lib/libsa
CPPFLAGS+= -I${.OBJDIR}

View file

@ -0,0 +1,15 @@
mergeNetBSDSourceDir() {
# merge together all extra paths
# there should be a better way to do this
chmod -R u+w $BSDSRCDIR
for path in $extraPaths; do
rsync -Er --chmod u+w $path/ $BSDSRCDIR/
done
}
addNetBSDMakeFlags() {
makeFlags="INCSDIR=${!outputDev}/include $makeFlags"
}
postUnpackHooks+=(mergeNetBSDSourceDir)
preConfigureHooks+=(addNetBSDMakeFlags)

View file

@ -0,0 +1,13 @@
diff --git a/Makefile b/Makefile
index 3f1e18dc659d..163362b82f94 100644
--- a/Makefile
+++ b/Makefile
@@ -2,6 +2,8 @@
.include <bsd.own.mk>
+INCSDIR= ${INCSDIR0}
+
SUBDIR= altq arch compat dev fs miscfs \
net net80211 netatalk netbt netcan netipsec netinet netinet6 \
netmpls netsmb \

View file

@ -0,0 +1,109 @@
# BSD makefiles should be able to detect this
# but without they end up using gcc on Darwin stdenv
addMakeFlags() {
export setOutputFlags=
export LIBCRT0=
export LIBCRTI=
export LIBCRTEND=
export LIBCRTBEGIN=
export LIBC=
export LIBUTIL=
export LIBSSL=
export LIBCRYPTO=
export LIBCRYPT=
export LIBCURSES=
export LIBTERMINFO=
export LIBM=
export LIBL=
export _GCC_CRTBEGIN=
export _GCC_CRTBEGINS=
export _GCC_CRTEND=
export _GCC_CRTENDS=
export _GCC_LIBGCCDIR=
export _GCC_CRTI=
export _GCC_CRTN=
export _GCC_CRTDIR=
# Definitions passed to share/mk/*.mk. Should be pretty simple -
# eventually maybe move it to a configure script.
export DESTDIR=
export USETOOLS=never
export NOCLANGERROR=yes
export NOGCCERROR=yes
export LEX=flex
export MKUNPRIVED=yes
export EXTERNAL_TOOLCHAIN=yes
makeFlags="MACHINE=$MACHINE $makeFlags"
makeFlags="MACHINE_ARCH=$MACHINE_ARCH $makeFlags"
makeFlags="AR=$AR $makeFlags"
makeFlags="CC=$CC $makeFlags"
makeFlags="CPP=$CPP $makeFlags"
makeFlags="CXX=$CXX $makeFlags"
makeFlags="LD=$LD $makeFlags"
makeFlags="STRIP=$STRIP $makeFlags"
makeFlags="BINDIR=${!outputBin}/bin $makeFlags"
makeFlags="LIBDIR=${!outputLib}/lib $makeFlags"
makeFlags="SHLIBDIR=${!outputLib}/lib $makeFlags"
makeFlags="MANDIR=${!outputMan}/share/man $makeFlags"
makeFlags="INFODIR=${!outputInfo}/share/info $makeFlags"
makeFlags="DOCDIR=${!outputDoc}/share/doc $makeFlags"
makeFlags="LOCALEDIR=${!outputLib}/share/locale $makeFlags"
# Parallel building. Needs the space.
makeFlags="-j $NIX_BUILD_CORES $makeFlags"
}
setBSDSourceDir() {
sourceRoot=$PWD/$sourceRoot
export BSDSRCDIR=$sourceRoot
export _SRC_TOP_=$BSDSRCDIR
cd $sourceRoot
if [ -d "$BSD_PATH" ]
then sourceRoot=$sourceRoot/$BSD_PATH
fi
}
includesPhase() {
if [ -z "${skipIncludesPhase:-}" ]; then
runHook preIncludes
local flagsArray=(
$makeFlags ${makeFlagsArray+"${makeFlagsArray[@]}"}
includes
)
echoCmd 'includes flags' "${flagsArray[@]}"
make ${makefile:+-f $makefile} "${flagsArray[@]}"
moveUsrDir
runHook postIncludes
fi
}
moveUsrDir() {
if [ -d $prefix ]; then
# Remove lingering /usr references
if [ -d $prefix/usr ]; then
# Didn't try using rsync yet because per
# https://unix.stackexchange.com/questions/127712/merging-folders-with-mv,
# it's not neessarily better.
pushd $prefix/usr
find . -type d -exec mkdir -p $out/\{} \;
find . \( -type f -o -type l \) -exec mv \{} $out/\{} \;
popd
fi
find $prefix -type d -empty -delete
fi
}
postUnpackHooks+=(setBSDSourceDir)
preConfigureHooks+=(addMakeFlags)
preInstallHooks+=(includesPhase)
fixupOutputHooks+=(moveUsrDir)

View file

@ -0,0 +1,19 @@
{ fetchFromGitHub, stdenv }:
# Reverse engineered CoreSymbolication to make dtrace buildable
stdenv.mkDerivation rec {
name = "CoreSymbolication";
src = fetchFromGitHub {
repo = name;
owner = "matthewbauer";
rev = "671fcb66c82eac1827f3f53dc4cc4e9b1b94da0a";
sha256 = "0qpw46gwgjxiwqqjxksb8yghp2q8dwad6hzaf4zl82xpvk9n5ahj";
};
installPhase = ''
mkdir -p $out/include
cp -r CoreSymbolication $out/include
'';
}

View file

@ -0,0 +1,36 @@
{ lib, stdenv, fetchurl }:
stdenv.mkDerivation rec {
pname = "DarwinTools";
version = "1";
src = fetchurl {
url = "https://opensource.apple.com/tarballs/DarwinTools/DarwinTools-${version}.tar.gz";
sha256 = "0hh4jl590jv3v830p77r3jcrnpndy7p2b8ajai3ldpnx2913jfhp";
};
patches = [
./sw_vers-CFPriv.patch
];
postPatch = ''
substituteInPlace Makefile \
--replace gcc cc
'';
configurePhase = ''
export SRCROOT=.
export SYMROOT=.
export DSTROOT=$out
'';
postInstall = ''
mv $out/usr/* $out
rmdir $out/usr
'';
meta = {
maintainers = [ lib.maintainers.matthewbauer ];
platforms = lib.platforms.darwin;
};
}

View file

@ -0,0 +1,19 @@
--- a/sw_vers.c 2021-04-19 13:06:50.131346864 +0900
+++ b/sw_vers.c 2021-04-19 13:07:32.481967474 +0900
@@ -28,7 +28,15 @@
*/
#include <CoreFoundation/CoreFoundation.h>
-#include <CoreFoundation/CFPriv.h>
+
+// Avoid dependency on CoreFoundation/CFPriv, which no longer appears to be
+// part of the upstream sdk.
+
+CFDictionaryRef _CFCopyServerVersionDictionary(void);
+CFDictionaryRef _CFCopySystemVersionDictionary(void);
+extern CFStringRef _kCFSystemVersionProductNameKey;
+extern CFStringRef _kCFSystemVersionProductVersionKey;
+extern CFStringRef _kCFSystemVersionBuildVersionKey;
void usage(char *progname) {
fprintf(stderr, "Usage: %s [-productName|-productVersion|-buildVersion]\n", progname);

View file

@ -0,0 +1,181 @@
{ 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
# 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/ \
${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
'';
};
};
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;
};
bareFrameworks = (
lib.mapAttrs framework (import ./frameworks.nix {
inherit frameworks libs;
inherit (pkgs.darwin) libobjc Libsystem;
inherit (pkgs.darwin.apple_sdk) libnetwork;
})
) // (
lib.mapAttrs privateFramework (import ./private-frameworks.nix {
inherit frameworks;
})
);
frameworks = bareFrameworks // overrides bareFrameworks;
}

View file

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

View file

@ -0,0 +1,58 @@
{ stdenvNoCC, fetchurl, newScope, pkgs
, xar, cpio, python3, pbzx }:
let
MacOSX-SDK = stdenvNoCC.mkDerivation rec {
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";
};
dontBuild = true;
darwinDontCodeSign = true;
nativeBuildInputs = [ cpio pbzx ];
outputs = [ "out" ];
unpackPhase = ''
pbzx $src | cpio -idm
'';
installPhase = ''
cd Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk
mkdir $out
cp -r System usr $out/
'';
passthru = {
inherit version;
};
};
callPackage = newScope (packages // pkgs.darwin // { inherit MacOSX-SDK; });
packages = {
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;
Libsystem = callPackage ./libSystem.nix {};
LibsystemCross = pkgs.darwin.Libsystem;
libcharset = callPackage ./libcharset.nix {};
libunwind = callPackage ./libunwind.nix {};
libnetwork = callPackage ./libnetwork.nix {};
objc4 = callPackage ./libobjc.nix {};
# questionable aliases
configd = pkgs.darwin.apple_sdk.frameworks.SystemConfiguration;
IOKit = pkgs.darwin.apple_sdk.frameworks.IOKit;
};
in packages

View file

@ -0,0 +1,195 @@
{ frameworks, libs, libobjc, Libsystem, libnetwork }: with frameworks; with libs;
{
AGL = { inherit Carbon OpenGL; };
AVFoundation = { inherit ApplicationServices AVFCapture AVFCore CoreGraphics simd UniformTypeIdentifiers; };
AVKit = {};
Accelerate = { inherit CoreWLAN IOBluetooth; };
Accessibility = {};
Accounts = {};
AdSupport = {};
AddressBook = { inherit AddressBookCore Carbon ContactsPersistence libobjc; };
AppKit = { inherit ApplicationServices AudioToolbox AudioUnit Foundation QuartzCore UIFoundation; };
AppTrackingTransparency = {};
AppleScriptKit = {};
AppleScriptObjC = {};
ApplicationServices = { inherit ColorSync CoreGraphics CoreServices CoreText ImageIO; };
AudioToolbox = { inherit AudioToolboxCore CoreAudio CoreMIDI; };
AudioUnit = { inherit AudioToolbox Carbon CoreAudio; };
AudioVideoBridging = { inherit Foundation; };
AuthenticationServices = {};
AutomaticAssessmentConfiguration = {};
Automator = {};
BackgroundTasks = {};
BusinessChat = {};
CFNetwork = {};
CalendarStore = {};
CallKit = {};
Carbon = { inherit ApplicationServices CoreServices Foundation IOKit QuartzCore Security libobjc; };
ClassKit = {};
CloudKit = { inherit CoreLocation; };
Cocoa = { inherit AppKit CoreData; };
Collaboration = {};
ColorSync = {};
Combine = {};
Contacts = {};
ContactsUI = {};
CoreAudio = { inherit IOKit CoreAudioTypes; };
CoreAudioKit = { inherit AudioUnit; };
CoreAudioTypes = {};
CoreBluetooth = {};
CoreData = { inherit CloudKit; };
CoreDisplay = {};
CoreFoundation = { inherit libobjc; };
CoreGraphics = { inherit Accelerate IOKit IOSurface SystemConfiguration; };
CoreHaptics = {};
CoreImage = {};
CoreLocation = {};
CoreMIDI = {};
CoreMIDIServer = { inherit CoreMIDI; };
CoreML = {};
CoreMedia = { inherit ApplicationServices AudioToolbox AudioUnit CoreAudio CoreGraphics CoreVideo; };
CoreMediaIO = { inherit CoreMedia; };
CoreMotion = {};
CoreServices = { inherit CFNetwork CoreAudio CoreData CoreFoundation DiskArbitration NetFS OpenDirectory Security ServiceManagement; };
CoreSpotlight = {};
CoreTelephony = {};
CoreText = { inherit CoreGraphics; };
CoreVideo = { inherit ApplicationServices CoreGraphics IOSurface OpenGL; };
CoreWLAN = { inherit SecurityFoundation; };
CryptoKit = {};
CryptoTokenKit = {};
DVDPlayback = {};
DeveloperToolsSupport = {};
DeviceCheck = {};
DirectoryService = {};
DiscRecording = { inherit CoreServices IOKit libobjc; };
DiscRecordingUI = {};
DiskArbitration = { inherit IOKit; };
DriverKit = {};
EventKit = {};
ExceptionHandling = {};
ExecutionPolicy = {};
ExternalAccessory = {};
FWAUserLib = {};
FileProvider = {};
FileProviderUI = {};
FinderSync = {};
ForceFeedback = { inherit IOKit; };
Foundation = { inherit ApplicationServices CoreFoundation Security SystemConfiguration libobjc; };
GLKit = {};
GLUT = { inherit OpenGL; };
GSS = {};
GameController = {};
GameKit = { inherit Cocoa Foundation GameCenterFoundation GameCenterUI GameCenterUICore GameController GameplayKit Metal MetalKit ModelIO ReplayKit SceneKit SpriteKit; };
GameplayKit = {};
HIDDriverKit = {};
Hypervisor = {};
ICADevices = { inherit Carbon IOBluetooth libobjc; };
IMServicePlugIn = {};
IOBluetooth = { inherit CoreBluetooth IOKit; };
IOBluetoothUI = { inherit IOBluetooth; };
IOKit = {};
# `IOSurface` should depend on `Libsystem` (in place of `xpc`) but this currently causes build
# issues due to incompatibility issues between `Libsystem` and `libcxx`.
IOSurface = { inherit IOKit xpc; };
IOUSBHost = {};
IdentityLookup = {};
ImageCaptureCore = {};
ImageIO = { inherit CoreGraphics; };
InputMethodKit = { inherit Carbon; };
InstallerPlugins = {};
InstantMessage = {};
Intents = {};
JavaNativeFoundation = {};
JavaRuntimeSupport = {};
JavaScriptCore = { inherit libobjc; };
Kerberos = {};
Kernel = { inherit IOKit; };
KernelManagement = {};
LDAP = {};
LatentSemanticMapping = { inherit Carbon; };
LinkPresentation = { inherit URLFormatting; };
LocalAuthentication = {};
MLCompute = {};
MapKit = {};
MediaAccessibility = { inherit CoreGraphics CoreText QuartzCore; };
MediaLibrary = {};
MediaPlayer = {};
MediaToolbox = { inherit AudioToolbox AudioUnit CoreMedia; };
Message = {};
Metal = {};
MetalKit = { inherit Metal ModelIO; };
MetalPerformanceShaders = {};
MetalPerformanceShadersGraph = {};
MetricKit = { inherit SignpostMetrics; };
ModelIO = {};
MultipeerConnectivity = {};
NaturalLanguage = {};
NearbyInteraction = {};
NetFS = {};
Network = { inherit libnetwork; };
NetworkExtension = { inherit Network; };
NetworkingDriverKit = {};
NotificationCenter = {};
OSAKit = { inherit Carbon; };
OSLog = {};
OpenAL = {};
OpenCL = { inherit IOSurface OpenGL; };
OpenDirectory = {};
OpenGL = {};
PCIDriverKit = {};
PCSC = { inherit CoreData; };
PDFKit = {};
ParavirtualizedGraphics = {};
PassKit = { inherit PassKitCore; };
PencilKit = {};
Photos = {};
PhotosUI = {};
PreferencePanes = {};
PushKit = {};
Python = {};
QTKit = { inherit CoreMedia CoreMediaIO MediaToolbox VideoToolbox; };
Quartz = { inherit QTKit QuartzCore QuickLook PDFKit; };
QuartzCore = { inherit ApplicationServices CoreImage CoreVideo Metal OpenCL libobjc; };
QuickLook = { inherit ApplicationServices; };
QuickLookThumbnailing = {};
RealityKit = {};
ReplayKit = {};
Ruby = {};
SafariServices = {};
SceneKit = {};
ScreenSaver = {};
ScreenTime = {};
ScriptingBridge = {};
Security = { inherit IOKit libDER; };
SecurityFoundation = { inherit Security; };
SecurityInterface = { inherit Security SecurityFoundation; };
SensorKit = {};
ServiceManagement = { inherit Security; };
Social = {};
SoundAnalysis = {};
Speech = {};
SpriteKit = {};
StoreKit = {};
SwiftUI = {};
SyncServices = {};
System = {};
SystemConfiguration = { inherit Security; };
SystemExtensions = {};
TWAIN = { inherit Carbon; };
Tcl = {};
Tk = {};
USBDriverKit = {};
UniformTypeIdentifiers = {};
UserNotifications = {};
UserNotificationsUI = {};
VideoDecodeAcceleration = { inherit CoreVideo; };
VideoSubscriberAccount = {};
VideoToolbox = { inherit CoreMedia CoreVideo; };
Virtualization = {};
Vision = {};
WebKit = { inherit ApplicationServices Carbon JavaScriptCore OpenGL libobjc; };
WidgetKit = {};
iTunesLibrary = {};
vmnet = {};
}

View file

@ -0,0 +1,78 @@
{ 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}
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 \
$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 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/ \
-r ${builtins.storeDir} \
"$tbd"
done
'';
}

View file

@ -0,0 +1,16 @@
{ 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

@ -0,0 +1,20 @@
{ 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

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

View file

@ -0,0 +1,24 @@
{ 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

@ -0,0 +1,21 @@
{ frameworks }: with 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 ContactsPersistence; };
AudioToolboxCore = {};
ContactsPersistence = {};
UIFoundation = {};
GameCenterFoundation = {};
GameCenterUI = {};
GameCenterUICore = {};
URLFormatting = {};
SignpostMetrics = {};
PassKitCore = {};
SkyLight = {};
# Also expose CoreSymbolication; used by `root` package.
CoreSymbolication = {};
}

View file

@ -0,0 +1,9 @@
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"
}
preConfigureHooks+=(linkSystemCoreFoundationFramework)

View file

@ -0,0 +1,339 @@
{ stdenv, fetchurl, xar, cpio, pkgs, python3, pbzx, lib, darwin-stubs, print-reexports }:
let
# sadly needs to be exported because security_tool needs it
sdk = stdenv.mkDerivation rec {
pname = "MacOS_SDK";
version = "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 = [ xar cpio python3 pbzx ];
outputs = [ "out" "dev" "man" ];
unpackPhase = ''
xar -x -f $src
'';
installPhase = ''
start="$(pwd)"
mkdir -p $out
cd $out
pbzx -n $start/Payload | cpio -idm
mv usr/* .
rmdir usr
mv System/* .
rmdir System
pushd 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;
# don't use pure CF for dylibs that depend on frameworks
setupHook = ./framework-setup-hook.sh;
# Not going to be more specific than this for now
__propagatedImpureHostDeps = lib.optionals (name != "Kernel") [
# The setup-hook ensures that everyone uses the impure CoreFoundation who uses these SDK frameworks, so let's expose it
"/System/Library/Frameworks/CoreFoundation.framework"
"/System/Library/Frameworks/${name}.framework"
"/System/Library/Frameworks/${name}.framework/${name}"
];
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
'';
};
};
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/
'';
});
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 [ "ContactsPersistence" "CoreSymbolication" "GameCenter" "SkyLight" "UIFoundation" ] (x: tbdOnlyFramework x {});
bareFrameworks = lib.mapAttrs framework (import ./frameworks.nix {
inherit frameworks libs;
inherit (pkgs.darwin) libobjc;
});
frameworks = bareFrameworks // overrides bareFrameworks;
inherit sdk;
}

View file

@ -0,0 +1,42 @@
# On macOS, frameworks are linked to the system CoreFoundation but
# dynamic libraries built with nix use a pure version of CF this
# causes segfaults for binaries that depend on it at runtime. This
# can be solved in two ways.
# 1. Rewrite references to the pure CF using this setup hook, this
# works for the simple case but this can still cause problems if other
# dependencies (eg. python) use the pure CF.
# 2. Create a wrapper for the binary that sets DYLD_FRAMEWORK_PATH to
# /System/Library/Frameworks. This will make everything load the
# system's CoreFoundation framework while still keeping the
# dependencies pure for other packages.
fixupOutputHooks+=('fixDarwinFrameworksIn $prefix')
fixDarwinFrameworks() {
local systemPrefix='/System/Library/Frameworks'
for fn in "$@"; do
if [ -L "$fn" ]; then continue; fi
echo "$fn: fixing dylib"
for framework in $(otool -L "$fn" | awk '/CoreFoundation\.framework/ {print $1}'); do
install_name_tool -change "$framework" "$systemPrefix/CoreFoundation.framework/Versions/A/CoreFoundation" "$fn" >&2
done
done
}
fixDarwinFrameworksIn() {
local dir="$1"
fixDarwinFrameworks $(find "$dir" -name "*.dylib")
}
# This configures the stdenv to use /System/Library/Frameworks/CoreFoundation.framework
# instead of the nix version by including the system frameworks path
# as an rpath entry when creating binaries.
useSystemCoreFoundationFramework () {
export NIX_COREFOUNDATION_RPATH=/System/Library/Frameworks
}
addEnvHooks "$hostOffset" useSystemCoreFoundationFramework

View file

@ -0,0 +1,129 @@
# 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 = {};
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

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

View file

@ -0,0 +1,10 @@
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

@ -0,0 +1,20 @@
{ 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.apsl20;
};
}

View file

@ -0,0 +1,42 @@
{ 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.apsl20;
};
}

View file

@ -0,0 +1,28 @@
{ 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)" ];
meta = with lib; {
description = "Apple's common startup stubs for darwin";
maintainers = with maintainers; [ copumpkin ];
platforms = platforms.darwin;
license = licenses.apsl20;
};
}

View file

@ -0,0 +1,86 @@
{ appleDerivation, lib, stdenv, buildPackages, python3 }:
let
formatVersionNumeric = version:
let
versionParts = lib.versions.splitVersion version;
major = lib.toInt (lib.elemAt versionParts 0);
minor = lib.toInt (lib.elemAt versionParts 1);
patch = if lib.length versionParts > 2 then lib.toInt (lib.elemAt versionParts 2) else 0;
in toString (major * 10000 + minor * 100 + patch);
in
appleDerivation {
nativeBuildInputs = [ python3 ];
depsBuildBuild = lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) [ buildPackages.stdenv.cc ];
postPatch = ''
substituteInPlace makefile \
--replace "/usr/bin/" "" \
--replace "xcrun --sdk macosx --find" "echo -n" \
--replace "xcrun --sdk macosx.internal --show-sdk-path" "echo -n /dev/null" \
--replace "-install_name " "-install_name $out"
substituteInPlace icuSources/config/mh-darwin \
--replace "-install_name " "-install_name $out/"
# drop using impure /var/db/timezone/icutz
substituteInPlace makefile \
--replace '-DU_TIMEZONE_FILES_DIR=\"\\\"$(TZDATA_LOOKUP_DIR)\\\"\" -DU_TIMEZONE_PACKAGE=\"\\\"$(TZDATA_PACKAGE)\\\"\"' ""
# FIXME: This will cause `ld: warning: OS version (12.0) too small, changing to 13.0.0`, APPLE should fix it.
substituteInPlace makefile \
--replace "ZIPPERING_LDFLAGS=-Wl,-iosmac_version_min,12.0" "ZIPPERING_LDFLAGS="
# skip test for missing encodingSamples data
substituteInPlace icuSources/test/cintltst/ucsdetst.c \
--replace "&TestMailFilterCSS" "NULL"
patchShebangs icuSources
'' + lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) ''
# This looks like a bug in the makefile. It defines ENV_BUILDHOST to
# propagate the correct value of CC, CXX, etc, but has the following double
# expansion that results in the empty string.
substituteInPlace makefile \
--replace '$($(ENV_BUILDHOST))' '$(ENV_BUILDHOST)'
'';
# APPLE is using makefile to save its default configuration and call ./configure, so we hack makeFlags
# instead of configuring ourself, trying to stay abreast of APPLE.
dontConfigure = true;
makeFlags = [
"DSTROOT=$(out)"
# remove /usr prefix on include and lib
"PRIVATE_HDR_PREFIX="
"libdir=/lib/"
"DATA_INSTALL_DIR=/share/icu/"
"DATA_LOOKUP_DIR=$(DSTROOT)$(DATA_INSTALL_DIR)"
] ++ lib.optionals stdenv.hostPlatform.isDarwin [ # darwin* platform properties are only defined on darwin
# hack to use our lower macos version
"MAC_OS_X_VERSION_MIN_REQUIRED=${formatVersionNumeric stdenv.hostPlatform.darwinMinVersion}"
"ICU_TARGET_VERSION=-m${stdenv.hostPlatform.darwinPlatform}-version-min=${stdenv.hostPlatform.darwinMinVersion}"
]
++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
"CROSS_BUILD=YES"
"BUILD_TYPE="
"RC_ARCHS=${stdenv.hostPlatform.darwinArch}"
"HOSTCC=cc"
"HOSTCXX=c++"
"CC=${stdenv.cc.targetPrefix}cc"
"CXX=${stdenv.cc.targetPrefix}c++"
"HOSTISYSROOT="
"OSX_HOST_VERSION_MIN_STRING=${stdenv.buildPlatform.darwinMinVersion}"
];
doCheck = true;
checkTarget = "check";
postInstall = ''
# we don't need all those in usr/local
rm -rf $out/usr
'';
}

View file

@ -0,0 +1,190 @@
{ lib, appleDerivation', stdenv, IOKitSrcs, xnu, darwin-stubs }:
# Someday it'll make sense to split these out into their own packages, but today is not that day.
appleDerivation' stdenv {
srcs = lib.attrValues IOKitSrcs;
sourceRoot = ".";
phases = [ "unpackPhase" "installPhase" ];
__propagatedImpureHostDeps = [
"/System/Library/Frameworks/IOKit.framework/IOKit"
"/System/Library/Frameworks/IOKit.framework/Resources"
"/System/Library/Frameworks/IOKit.framework/Versions"
];
installPhase = ''
mkdir -p $out/Library/Frameworks/IOKit.framework
###### IMPURITIES
ln -s /System/Library/Frameworks/IOKit.framework/Resources \
$out/Library/Frameworks/IOKit.framework
###### STUBS
cp ${darwin-stubs}/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit.tbd \
$out/Library/Frameworks/IOKit.framework
###### HEADERS
export dest=$out/Library/Frameworks/IOKit.framework/Headers
mkdir -p $dest
pushd $dest
mkdir audio avc DV firewire graphics hid hidsystem i2c kext ndrvsupport
mkdir network ps pwr_mgt sbp2 scsi serial storage stream usb video
popd
# root: complete
cp IOKitUser-*/IOCFBundle.h $dest
cp IOKitUser-*/IOCFPlugIn.h $dest
cp IOKitUser-*/IOCFSerialize.h $dest
cp IOKitUser-*/IOCFUnserialize.h $dest
cp IOKitUser-*/IOCFURLAccess.h $dest
cp IOKitUser-*/IODataQueueClient.h $dest
cp IOKitUser-*/IOKitLib.h $dest
cp IOKitUser-*/iokitmig.h $dest
cp ${xnu}/Library/PrivateFrameworks/IOKit.framework/Versions/A/Headers/*.h $dest
# audio: complete
cp IOAudioFamily-*/IOAudioDefines.h $dest/audio
cp IOKitUser-*/audio.subproj/IOAudioLib.h $dest/audio
cp IOAudioFamily-*/IOAudioTypes.h $dest/audio
# avc: complete
cp IOFireWireAVC-*/IOFireWireAVC/IOFireWireAVCConsts.h $dest/avc
cp IOFireWireAVC-*/IOFireWireAVCLib/IOFireWireAVCLib.h $dest/avc
# DV: complete
cp IOFWDVComponents-*/DVFamily.h $dest/DV
# firewire: complete
cp IOFireWireFamily-*/IOFireWireFamily.kmodproj/IOFireWireFamilyCommon.h $dest/firewire
cp IOFireWireFamily-*/IOFireWireLib.CFPlugInProj/IOFireWireLib.h $dest/firewire
cp IOFireWireFamily-*/IOFireWireLib.CFPlugInProj/IOFireWireLibIsoch.h $dest/firewire
cp IOFireWireFamily-*/IOFireWireFamily.kmodproj/IOFWIsoch.h $dest/firewire
# graphics: missing AppleGraphicsDeviceControlUserCommand.h
cp IOGraphics-*/IOGraphicsFamily/IOKit/graphics/IOAccelClientConnect.h $dest/graphics
cp IOGraphics-*/IOGraphicsFamily/IOKit/graphics/IOAccelSurfaceConnect.h $dest/graphics
cp IOGraphics-*/IOGraphicsFamily/IOKit/graphics/IOAccelTypes.h $dest/graphics
cp IOGraphics-*/IOGraphicsFamily/IOKit/graphics/IOFramebufferShared.h $dest/graphics
cp IOGraphics-*/IOGraphicsFamily/IOKit/graphics/IOGraphicsEngine.h $dest/graphics
cp IOGraphics-*/IOGraphicsFamily/IOKit/graphics/IOGraphicsInterface.h $dest/graphics
cp IOGraphics-*/IOGraphicsFamily/IOKit/graphics/IOGraphicsInterfaceTypes.h $dest/graphics
cp IOKitUser-*/graphics.subproj/IOGraphicsLib.h $dest/graphics
cp IOGraphics-*/IOGraphicsFamily/IOKit/graphics/IOGraphicsTypes.h $dest/graphics
# hid: complete
cp IOKitUser-*/hid.subproj/IOHIDBase.h $dest/hid
cp IOKitUser-*/hid.subproj/IOHIDDevice.h $dest/hid
cp IOKitUser-*/hid.subproj/IOHIDDevicePlugIn.h $dest/hid
cp IOKitUser-*/hid.subproj/IOHIDElement.h $dest/hid
cp IOKitUser-*/hid.subproj/IOHIDLib.h $dest/hid
cp IOKitUser-*/hid.subproj/IOHIDManager.h $dest/hid
cp IOKitUser-*/hid.subproj/IOHIDQueue.h $dest/hid
cp IOKitUser-*/hid.subproj/IOHIDTransaction.h $dest/hid
cp IOKitUser-*/hid.subproj/IOHIDValue.h $dest/hid
cp IOHIDFamily-*/IOHIDFamily/IOHIDKeys.h $dest/hid
cp IOHIDFamily-*/IOHIDFamily/IOHIDUsageTables.h $dest/hid
cp IOHIDFamily-*/IOHIDLib/IOHIDLibObsolete.h $dest/hid
# hidsystem: complete
cp IOHIDFamily-*/IOHIDSystem/IOKit/hidsystem/ev_keymap.h $dest/hidsystem
cp IOKitUser-*/hidsystem.subproj/event_status_driver.h $dest/hidsystem
cp IOKitUser-*/hidsystem.subproj/IOHIDLib.h $dest/hidsystem
cp IOHIDFamily-*/IOHIDSystem/IOKit/hidsystem/IOHIDParameter.h $dest/hidsystem
cp IOHIDFamily-*/IOHIDSystem/IOKit/hidsystem/IOHIDShared.h $dest/hidsystem
cp IOHIDFamily-*/IOHIDSystem/IOKit/hidsystem/IOHIDTypes.h $dest/hidsystem
cp IOHIDFamily-*/IOHIDSystem/IOKit/hidsystem/IOLLEvent.h $dest/hidsystem
# i2c: complete
cp IOGraphics-*/IOGraphicsFamily/IOKit/i2c/IOI2CInterface.h $dest/i2c
# kext: complete
cp IOKitUser-*/kext.subproj/KextManager.h $dest/kext
# ndrvsupport: complete
cp IOGraphics-*/IONDRVSupport/IOKit/ndrvsupport/IOMacOSTypes.h $dest/ndrvsupport
cp IOGraphics-*/IONDRVSupport/IOKit/ndrvsupport/IOMacOSVideo.h $dest/ndrvsupport
# network: complete
cp IONetworkingFamily-*/IOEthernetController.h $dest/network
cp IONetworkingFamily-*/IOEthernetInterface.h $dest/network
cp IONetworkingFamily-*/IOEthernetStats.h $dest/network
cp IONetworkingFamily-*/IONetworkController.h $dest/network
cp IONetworkingFamily-*/IONetworkData.h $dest/network
cp IONetworkingFamily-*/IONetworkInterface.h $dest/network
cp IOKitUser-*/network.subproj/IONetworkLib.h $dest/network
cp IONetworkingFamily-*/IONetworkMedium.h $dest/network
cp IONetworkingFamily-*/IONetworkStack.h $dest/network
cp IONetworkingFamily-*/IONetworkStats.h $dest/network
cp IONetworkingFamily-*/IONetworkUserClient.h $dest/network
# ps: missing IOUPSPlugIn.h
cp IOKitUser-*/ps.subproj/IOPowerSources.h $dest/ps
cp IOKitUser-*/ps.subproj/IOPSKeys.h $dest/ps
# pwr_mgt: complete
cp IOKitUser-*/pwr_mgt.subproj/IOPMKeys.h $dest/pwr_mgt
cp IOKitUser-*/pwr_mgt.subproj/IOPMLib.h $dest/pwr_mgt
cp ${xnu}/Library/PrivateFrameworks/IOKit.framework/Versions/A/Headers/pwr_mgt/*.h $dest/pwr_mgt
cp IOKitUser-*/pwr_mgt.subproj/IOPMLibPrivate.h $dest/pwr_mgt # Private
# sbp2: complete
cp IOFireWireSBP2-*/IOFireWireSBP2Lib/IOFireWireSBP2Lib.h $dest/sbp2
# scsi: omitted for now
# serial: complete
cp IOSerialFamily-*/IOSerialFamily.kmodproj/IOSerialKeys.h $dest/serial
cp IOSerialFamily-*/IOSerialFamily.kmodproj/ioss.h $dest/serial
# storage: complete
# Needs ata subdirectory
cp IOStorageFamily-*/IOAppleLabelScheme.h $dest/storage
cp IOStorageFamily-*/IOApplePartitionScheme.h $dest/storage
cp IOBDStorageFamily-*/IOBDBlockStorageDevice.h $dest/storage
cp IOBDStorageFamily-*/IOBDMedia.h $dest/storage
cp IOBDStorageFamily-*/IOBDMediaBSDClient.h $dest/storage
cp IOBDStorageFamily-*/IOBDTypes.h $dest/storage
cp IOStorageFamily-*/IOBlockStorageDevice.h $dest/storage
cp IOStorageFamily-*/IOBlockStorageDriver.h $dest/storage
cp IOCDStorageFamily-*/IOCDBlockStorageDevice.h $dest/storage
cp IOCDStorageFamily-*/IOCDMedia.h $dest/storage
cp IOCDStorageFamily-*/IOCDMediaBSDClient.h $dest/storage
cp IOCDStorageFamily-*/IOCDPartitionScheme.h $dest/storage
cp IOCDStorageFamily-*/IOCDTypes.h $dest/storage
cp IODVDStorageFamily-*/IODVDBlockStorageDevice.h $dest/storage
cp IODVDStorageFamily-*/IODVDMedia.h $dest/storage
cp IODVDStorageFamily-*/IODVDMediaBSDClient.h $dest/storage
cp IODVDStorageFamily-*/IODVDTypes.h $dest/storage
cp IOStorageFamily-*/IOFDiskPartitionScheme.h $dest/storage
cp IOStorageFamily-*/IOFilterScheme.h $dest/storage
cp IOFireWireSerialBusProtocolTransport-*/IOFireWireStorageCharacteristics.h $dest/storage
cp IOStorageFamily-*/IOGUIDPartitionScheme.h $dest/storage
cp IOStorageFamily-*/IOMedia.h $dest/storage
cp IOStorageFamily-*/IOMediaBSDClient.h $dest/storage
cp IOStorageFamily-*/IOPartitionScheme.h $dest/storage
cp IOStorageFamily-*/IOStorage.h $dest/storage
cp IOStorageFamily-*/IOStorageCardCharacteristics.h $dest/storage
cp IOStorageFamily-*/IOStorageDeviceCharacteristics.h $dest/storage
cp IOStorageFamily-*/IOStorageProtocolCharacteristics.h $dest/storage
# stream: missing altogether
# usb: complete
cp IOUSBFamily-630.4.5/IOUSBFamily/Headers/IOUSBLib.h $dest/usb
cp IOUSBFamily-630.4.5/IOUSBUserClient/Headers/IOUSBUserClient.h $dest/usb
cp IOUSBFamily-560.4.2/IOUSBFamily/Headers/USB.h $dest/usb # This file is empty in 630.4.5!
cp IOUSBFamily-630.4.5/IOUSBFamily/Headers/USBSpec.h $dest/usb
# video: missing altogether
'';
meta = with lib; {
maintainers = with maintainers; [ joelteon copumpkin ];
platforms = platforms.darwin;
license = licenses.apsl20;
};
}

View file

@ -0,0 +1,47 @@
From 187d0e8847d080790b22724352e51de50d214dd8 Mon Sep 17 00:00:00 2001
From: toonn <toonn@toonn.io>
Date: Tue, 27 Jul 2021 15:12:14 +0200
Subject: [PATCH] Define TARGET_OS_EMBEDDED in std{lib,io} if not defined
Originally attempted including `TargetConditionals.h` but this had
knock-on effects, for example, breaking the zlib build because of
`TARGET_OS_MAC` getting defined.
This should be the lowest impact solution and corresponds to the default
behavior IIUC.
---
include/stdio.h | 3 +++
include/stdlib.h | 3 +++
2 files changed, 6 insertions(+)
diff --git a/include/stdio.h b/include/stdio.h
index d0cf7a5..487496e 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -351,6 +351,9 @@ __END_DECLS
/* Additional functionality provided by:
* POSIX.2-1992 C Language Binding Option
*/
+#ifndef TARGET_OS_EMBEDDED
+# define TARGET_OS_EMBEDDED 0
+#endif
#if TARGET_OS_EMBEDDED
#define __swift_unavailable_on(osx_msg, ios_msg) __swift_unavailable(ios_msg)
#else
diff --git a/include/stdlib.h b/include/stdlib.h
index c04d3a7..0b454ba 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -183,6 +183,9 @@ unsigned long long
#ifndef LIBC_ALIAS_SYSTEM
//End-Libc
+#ifndef TARGET_OS_EMBEDDED
+# define TARGET_OS_EMBEDDED 0
+#endif
#if TARGET_OS_EMBEDDED
#define __swift_unavailable_on(osx_msg, ios_msg) __swift_unavailable(ios_msg)
#else
--
2.17.2 (Apple Git-113)

View file

@ -0,0 +1,13 @@
{ appleDerivation', stdenvNoCC, ed, unifdef }:
appleDerivation' stdenvNoCC {
nativeBuildInputs = [ ed unifdef ];
installPhase = ''
export SRCROOT=$PWD
export DSTROOT=$out
export PUBLIC_HEADERS_FOLDER_PATH=include
export PRIVATE_HEADERS_FOLDER_PATH=include
bash xcodescripts/headers.sh
'';
}

View file

@ -0,0 +1,51 @@
/*
* Copyright (c) 2010 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/***********************************************************************
* Not to be installed in /usr/local/include
***********************************************************************/
#ifndef _LIBC_CRASHREPORTERCLIENT_H
#define _LIBC_CRASHREPORTERCLIENT_H
#include "stdint.h"
/* Fake the CrashReporterClient API */
#define CRGetCrashLogMessage() 0
#define CRSetCrashLogMessage(m) true
#define CRASH_REPORTER_CLIENT_HIDDEN __attribute__((visibility("hidden")))
#define CRASHREPORTER_ANNOTATIONS_VERSION 4
#define CRASHREPORTER_ANNOTATIONS_SECTION "__crash_info"
struct crashreporter_annotations_t {
uint64_t version; // unsigned long
uint64_t message; // char *
uint64_t signature_string; // char *
uint64_t backtrace; // char *
uint64_t message2; // char *
uint64_t thread; // uint64_t
uint64_t dialog_mode; // unsigned int
};
#endif

View file

@ -0,0 +1,38 @@
{ appleDerivation', stdenvNoCC, ed, unifdef, Libc_old, Libc_10-9 }:
appleDerivation' stdenvNoCC {
nativeBuildInputs = [ ed unifdef ];
patches = [
./0001-Define-TARGET_OS_EMBEDDED-in-std-lib-io-if-not-defin.patch
];
# TODO: asl.h actually comes from syslog project now
installPhase = ''
export SRCROOT=$PWD
export DSTROOT=$out
export PUBLIC_HEADERS_FOLDER_PATH=include
export PRIVATE_HEADERS_FOLDER_PATH=include
bash xcodescripts/headers.sh
cp ${./CrashReporterClient.h} $out/include/CrashReporterClient.h
cp ${Libc_10-9}/include/NSSystemDirectories.h $out/include
# Ugh Apple stopped releasing this stuff so we need an older one...
cp ${Libc_old}/include/spawn.h $out/include
cp ${Libc_old}/include/setjmp.h $out/include
cp ${Libc_old}/include/ucontext.h $out/include
cp ${Libc_old}/include/pthread*.h $out/include
cp ${Libc_old}/include/sched.h $out/include
cp -R ${Libc_old}/include/malloc $out/include
mkdir -p $out/include/libkern
cp ${Libc_old}/include/asl.h $out/include
cp ${Libc_old}/include/libproc.h $out/include
cp ${Libc_old}/include/libkern/OSAtomic.h $out/include/libkern
cp ${Libc_old}/include/libkern/OSCacheControl.h $out/include/libkern
'';
appleHeaders = builtins.readFile ./headers.txt;
}

View file

@ -0,0 +1,138 @@
CrashReporterClient.h
NSSystemDirectories.h
_locale.h
_types.h
_types/_intmax_t.h
_types/_nl_item.h
_types/_uint16_t.h
_types/_uint32_t.h
_types/_uint64_t.h
_types/_uint8_t.h
_types/_uintmax_t.h
_types/_wctrans_t.h
_types/_wctype_t.h
_wctype.h
_xlocale.h
aio.h
alloca.h
ar.h
arpa/ftp.h
arpa/inet.h
arpa/nameser_compat.h
arpa/telnet.h
arpa/tftp.h
asl.h
assert.h
bitstring.h
cpio.h
crt_externs.h
ctype.h
db.h
dirent.h
disktab.h
err.h
errno.h
execinfo.h
fcntl.h
fmtmsg.h
fnmatch.h
fsproperties.h
fstab.h
fts.h
ftw.h
get_compat.h
getopt.h
glob.h
inttypes.h
iso646.h
langinfo.h
libc.h
libc_private.h
libgen.h
libkern/OSAtomic.h
libkern/OSCacheControl.h
libproc.h
limits.h
locale.h
malloc/malloc.h
memory.h
monetary.h
monitor.h
mpool.h
msgcat.h
ndbm.h
nl_types.h
nlist.h
os/assumes.h
os/debug_private.h
paths.h
poll.h
printf.h
protocols/routed.h
protocols/rwhod.h
protocols/talkd.h
protocols/timed.h
pthread.h
pthread_impl.h
pthread_spis.h
pthread_workqueue.h
ranlib.h
readpassphrase.h
regex.h
runetype.h
sched.h
search.h
secure/_common.h
secure/_stdio.h
secure/_string.h
semaphore.h
setjmp.h
sgtty.h
signal.h
spawn.h
stab.h
standards.h
stddef.h
stdint.h
stdio.h
stdlib.h
strhash.h
string.h
stringlist.h
strings.h
struct.h
sys/acl.h
sys/rbtree.h
sys/statvfs.h
sysexits.h
syslog.h
tar.h
termios.h
time.h
timeconv.h
ttyent.h
tzfile.h
ucontext.h
ulimit.h
unistd.h
util.h
utime.h
utmpx.h
utmpx_thread.h
vis.h
wchar.h
wctype.h
wordexp.h
xlocale.h
xlocale/__wctype.h
xlocale/_ctype.h
xlocale/_inttypes.h
xlocale/_langinfo.h
xlocale/_monetary.h
xlocale/_regex.h
xlocale/_stdio.h
xlocale/_stdlib.h
xlocale/_string.h
xlocale/_time.h
xlocale/_wchar.h
xlocale/_wctype.h

View file

@ -0,0 +1,50 @@
{ appleDerivation', stdenvNoCC }:
appleDerivation' stdenvNoCC {
installPhase = ''
substituteInPlace xcodescripts/install_files.sh \
--replace "/usr/local/" "/" \
--replace "/usr/" "/" \
--replace '-o "$INSTALL_OWNER" -g "$INSTALL_GROUP"' "" \
--replace "ln -h" "ln -n"
export DSTROOT=$out
sh xcodescripts/install_files.sh
'';
appleHeaders = ''
aliasdb.h
bootparams.h
configuration_profile.h
grp.h
ifaddrs.h
ils.h
kvbuf.h
libinfo.h
libinfo_muser.h
membership.h
membershipPriv.h
netdb.h
netdb_async.h
ntsid.h
printerdb.h
pwd.h
rpc/auth.h
rpc/auth_unix.h
rpc/clnt.h
rpc/pmap_clnt.h
rpc/pmap_prot.h
rpc/pmap_rmt.h
rpc/rpc.h
rpc/rpc_msg.h
rpc/svc.h
rpc/svc_auth.h
rpc/types.h
rpc/xdr.h
rpcsvc/yp_prot.h
rpcsvc/ypclnt.h
si_data.h
si_module.h
thread_data.h
'';
}

View file

@ -0,0 +1,11 @@
{ appleDerivation', stdenvNoCC }:
appleDerivation' stdenvNoCC {
installPhase = ''
mkdir -p $out/include
cp Source/Intel/math.h $out/include
cp Source/Intel/fenv.h $out/include
cp Source/complex.h $out/include
'';
}

View file

@ -0,0 +1,9 @@
{ appleDerivation', stdenvNoCC }:
appleDerivation' stdenvNoCC {
installPhase = ''
mkdir -p $out/include
cp notify.h $out/include
cp notify_keys.h $out/include
'';
}

View file

@ -0,0 +1,22 @@
{ lib, appleDerivation, developer_cmds }:
appleDerivation {
buildInputs = [ developer_cmds ];
installPhase = ''
export DSTROOT=$out
export SRCROOT=$PWD
export OBJROOT=$PWD
. ./xcodescripts/install_rpcsvc.sh
mv $out/usr/* $out
rmdir $out/usr/
'';
meta = with lib; {
maintainers = with maintainers; [ matthewbauer ];
platforms = platforms.darwin;
license = licenses.apsl20;
};
}

View file

@ -0,0 +1,146 @@
{ lib, stdenv, buildPackages
, appleDerivation', xnu, Libc, Libm, libdispatch, Libinfo
, dyld, Csu, architecture, libclosure, CarbonHeaders, ncurses, CommonCrypto
, copyfile, removefile, libresolvHeaders, libresolv, Libnotify, libplatform, libpthread
, mDNSResponder, launchd, libutilHeaders, hfsHeaders, darling, darwin-stubs
, headersOnly ? false
, withLibresolv ? !headersOnly
}:
appleDerivation' stdenv {
dontBuild = true;
dontFixup = true;
installPhase = ''
export NIX_ENFORCE_PURITY=
mkdir -p $out/lib $out/include
function copyHierarchy () {
mkdir -p $1
while read f; do
mkdir -p $1/$(dirname $f)
cp --parents -pn $f $1
done
}
# Set up our include directories
(cd ${xnu}/include && find . -name '*.h' -or -name '*.defs' | copyHierarchy $out/include)
cp ${xnu}/Library/Frameworks/Kernel.framework/Versions/A/Headers/Availability*.h $out/include
cp ${xnu}/Library/Frameworks/Kernel.framework/Versions/A/Headers/stdarg.h $out/include
for dep in ${Libc} ${Libm} ${Libinfo} ${dyld} ${architecture} \
${libclosure} ${CarbonHeaders} ${libdispatch} ${ncurses.dev} \
${CommonCrypto} ${copyfile} ${removefile} ${libresolvHeaders} \
${Libnotify} ${libplatform} ${mDNSResponder} ${launchd} \
${libutilHeaders} ${libpthread} ${hfsHeaders}; do
(cd $dep/include && find . -name '*.h' | copyHierarchy $out/include)
done
(cd ${buildPackages.darwin.cctools.dev}/include/mach-o && find . -name '*.h' | copyHierarchy $out/include/mach-o)
mkdir -p $out/include/os
cp ${darling.src}/src/libc/os/activity.h $out/include/os
cp ${darling.src}/src/libc/os/log.h $out/include/os
cp ${darling.src}/src/duct/include/os/trace.h $out/include/os
cat <<EOF > $out/include/os/availability.h
#ifndef __OS_AVAILABILITY__
#define __OS_AVAILABILITY__
#include <AvailabilityInternal.h>
#if defined(__has_feature) && defined(__has_attribute) && __has_attribute(availability)
#define API_AVAILABLE(...) __API_AVAILABLE_GET_MACRO(__VA_ARGS__, __API_AVAILABLE4, __API_AVAILABLE3, __API_AVAILABLE2, __API_AVAILABLE1)(__VA_ARGS__)
#define API_DEPRECATED(...) __API_DEPRECATED_MSG_GET_MACRO(__VA_ARGS__, __API_DEPRECATED_MSG5, __API_DEPRECATED_MSG4, __API_DEPRECATED_MSG3, __API_DEPRECATED_MSG2, __API_DEPRECATED_MSG1)(__VA_ARGS__)
#define API_DEPRECATED_WITH_REPLACEMENT(...) __API_DEPRECATED_REP_GET_MACRO(__VA_ARGS__, __API_DEPRECATED_REP5, __API_DEPRECATED_REP4, __API_DEPRECATED_REP3, __API_DEPRECATED_REP2, __API_DEPRECATED_REP1)(__VA_ARGS__)
#define API_UNAVAILABLE(...) __API_UNAVAILABLE_GET_MACRO(__VA_ARGS__, __API_UNAVAILABLE3, __API_UNAVAILABLE2, __API_UNAVAILABLE1)(__VA_ARGS__)
#else
#define API_AVAILABLE(...)
#define API_DEPRECATED(...)
#define API_DEPRECATED_WITH_REPLACEMENT(...)
#define API_UNAVAILABLE(...)
#endif
#endif
EOF
cat <<EOF > $out/include/TargetConditionals.h
#ifndef __TARGETCONDITIONALS__
#define __TARGETCONDITIONALS__
#define TARGET_OS_MAC 1
#define TARGET_OS_WIN32 0
#define TARGET_OS_UNIX 0
#define TARGET_OS_OSX 1
#define TARGET_OS_IPHONE 0
#define TARGET_OS_IOS 0
#define TARGET_OS_WATCH 0
#define TARGET_OS_BRIDGE 0
#define TARGET_OS_TV 0
#define TARGET_OS_SIMULATOR 0
#define TARGET_OS_EMBEDDED 0
#define TARGET_OS_EMBEDDED_OTHER 0 /* Used in configd */
#define TARGET_IPHONE_SIMULATOR TARGET_OS_SIMULATOR /* deprecated */
#define TARGET_OS_NANO TARGET_OS_WATCH /* deprecated */
#define TARGET_OS_LINUX 0
#define TARGET_CPU_PPC 0
#define TARGET_CPU_PPC64 0
#define TARGET_CPU_68K 0
#define TARGET_CPU_X86 0
#define TARGET_CPU_X86_64 1
#define TARGET_CPU_ARM 0
#define TARGET_CPU_ARM64 0
#define TARGET_CPU_MIPS 0
#define TARGET_CPU_SPARC 0
#define TARGET_CPU_ALPHA 0
#define TARGET_RT_MAC_CFM 0
#define TARGET_RT_MAC_MACHO 1
#define TARGET_RT_LITTLE_ENDIAN 1
#define TARGET_RT_BIG_ENDIAN 0
#define TARGET_RT_64_BIT 1
#endif /* __TARGETCONDITIONALS__ */
EOF
'' + lib.optionalString (!headersOnly) ''
# The startup object files
cp ${Csu}/lib/* $out/lib
cp -vr \
${darwin-stubs}/usr/lib/libSystem.B.tbd \
${darwin-stubs}/usr/lib/system \
$out/lib
substituteInPlace $out/lib/libSystem.B.tbd \
--replace "/usr/lib/system/" "$out/lib/system/"
ln -s libSystem.B.tbd $out/lib/libSystem.tbd
# Set up links to pretend we work like a conventional unix (Apple's design, not mine!)
for name in c dbm dl info m mx poll proc pthread rpcsvc util gcc_s.10.4 gcc_s.10.5; do
ln -s libSystem.tbd $out/lib/lib$name.tbd
done
'' + lib.optionalString withLibresolv ''
# This probably doesn't belong here, but we want to stay similar to glibc, which includes resolv internally...
cp ${libresolv}/lib/libresolv.9.dylib $out/lib/libresolv.9.dylib
resolv_libSystem=$(${stdenv.cc.bintools.targetPrefix}otool -L "$out/lib/libresolv.9.dylib" | tail -n +3 | grep -o "$NIX_STORE.*-\S*") || true
echo $libs
chmod +w $out/lib/libresolv.9.dylib
${stdenv.cc.bintools.targetPrefix}install_name_tool \
-id $out/lib/libresolv.9.dylib \
-change "$resolv_libSystem" /usr/lib/libSystem.dylib \
$out/lib/libresolv.9.dylib
ln -s libresolv.9.dylib $out/lib/libresolv.dylib
'';
appleHeaders = builtins.readFile ./headers.txt;
meta = with lib; {
description = "The Mac OS libc/libSystem (tapi library with pure headers)";
maintainers = with maintainers; [ copumpkin gridaphobe ];
platforms = platforms.darwin;
license = licenses.apsl20;
};
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1 @@
_mach_init_routine

View file

@ -0,0 +1,10 @@
{ appleDerivation, xcbuildHook, IOKit }:
appleDerivation {
nativeBuildInputs = [ xcbuildHook ];
buildInputs = [ IOKit ];
xcbuildFlags = [ "-target" "caffeinate" ];
installPhase = ''
install -D Products/Deployment/caffeinate $out/bin/caffeinate
'';
}

View file

@ -0,0 +1,117 @@
{ appleDerivation', stdenv, darwin-stubs }:
appleDerivation' stdenv {
phases = [ "unpackPhase" "installPhase" ];
__propagatedImpureHostDeps = [
"/System/Library/Frameworks/Security.framework/Security"
"/System/Library/Frameworks/Security.framework/Resources"
"/System/Library/Frameworks/Security.framework/PlugIns"
"/System/Library/Frameworks/Security.framework/XPCServices"
"/System/Library/Frameworks/Security.framework/Versions"
];
installPhase = ''
mkdir -p $out/Library/Frameworks/Security.framework
###### IMPURITIES
ln -s /System/Library/Frameworks/Security.framework/{Resources,Plugins,XPCServices} \
$out/Library/Frameworks/Security.framework
###### STUBS
cp ${darwin-stubs}/System/Library/Frameworks/Security.framework/Versions/A/Security.tbd \
$out/Library/Frameworks/Security.framework
###### HEADERS
export dest=$out/Library/Frameworks/Security.framework/Headers
mkdir -p $dest
cp libsecurity_asn1/lib/SecAsn1Coder.h $dest
cp libsecurity_asn1/lib/SecAsn1Templates.h $dest
cp libsecurity_asn1/lib/SecAsn1Types.h $dest
cp libsecurity_asn1/lib/oidsalg.h $dest
cp libsecurity_asn1/lib/oidsattr.h $dest
cp libsecurity_authorization/lib/AuthSession.h $dest
cp libsecurity_authorization/lib/Authorization.h $dest
cp libsecurity_authorization/lib/AuthorizationDB.h $dest
cp libsecurity_authorization/lib/AuthorizationPlugin.h $dest
cp libsecurity_authorization/lib/AuthorizationTags.h $dest
cp libsecurity_cms/lib/CMSDecoder.h $dest
cp libsecurity_cms/lib/CMSEncoder.h $dest
cp libsecurity_codesigning/lib/CSCommon.h $dest
cp libsecurity_codesigning/lib/CodeSigning.h $dest
cp libsecurity_codesigning/lib/SecCode.h $dest
cp libsecurity_codesigning/lib/SecCodeHost.h $dest
cp libsecurity_codesigning/lib/SecRequirement.h $dest
cp libsecurity_codesigning/lib/SecStaticCode.h $dest
cp libsecurity_codesigning/lib/SecTask.h $dest
cp libsecurity_cssm/lib/certextensions.h $dest
cp libsecurity_cssm/lib/cssm.h $dest
cp libsecurity_cssm/lib/cssmaci.h $dest
cp libsecurity_cssm/lib/cssmapi.h $dest
cp libsecurity_cssm/lib/cssmapple.h $dest
cp libsecurity_cssm/lib/cssmcli.h $dest
cp libsecurity_cssm/lib/cssmconfig.h $dest
cp libsecurity_cssm/lib/cssmcspi.h $dest
cp libsecurity_cssm/lib/cssmdli.h $dest
cp libsecurity_cssm/lib/cssmerr.h $dest
cp libsecurity_cssm/lib/cssmkrapi.h $dest
cp libsecurity_cssm/lib/cssmkrspi.h $dest
cp libsecurity_cssm/lib/cssmspi.h $dest
cp libsecurity_cssm/lib/cssmtpi.h $dest
cp libsecurity_cssm/lib/cssmtype.h $dest
cp libsecurity_cssm/lib/eisl.h $dest
cp libsecurity_cssm/lib/emmspi.h $dest
cp libsecurity_cssm/lib/emmtype.h $dest
cp libsecurity_cssm/lib/oidsbase.h $dest
cp libsecurity_cssm/lib/oidscert.h $dest
cp libsecurity_cssm/lib/oidscrl.h $dest
cp libsecurity_cssm/lib/x509defs.h $dest
cp libsecurity_keychain/lib/SecACL.h $dest
cp libsecurity_keychain/lib/SecAccess.h $dest
cp libsecurity_keychain/lib/SecBase.h $dest
cp libsecurity_keychain/lib/SecCertificate.h $dest
cp libsecurity_keychain/lib/SecCertificatePriv.h $dest # Private
cp libsecurity_keychain/lib/SecCertificateOIDs.h $dest
cp libsecurity_keychain/lib/SecIdentity.h $dest
cp libsecurity_keychain/lib/SecIdentitySearch.h $dest
cp libsecurity_keychain/lib/SecImportExport.h $dest
cp libsecurity_keychain/lib/SecItem.h $dest
cp libsecurity_keychain/lib/SecKey.h $dest
cp libsecurity_keychain/lib/SecKeychain.h $dest
cp libsecurity_keychain/lib/SecKeychainItem.h $dest
cp libsecurity_keychain/lib/SecKeychainSearch.h $dest
cp libsecurity_keychain/lib/SecPolicy.h $dest
cp libsecurity_keychain/lib/SecPolicySearch.h $dest
cp libsecurity_keychain/lib/SecRandom.h $dest
cp libsecurity_keychain/lib/SecTrust.h $dest
cp libsecurity_keychain/lib/SecTrustSettings.h $dest
cp libsecurity_keychain/lib/SecTrustedApplication.h $dest
cp libsecurity_keychain/lib/Security.h $dest
cp libsecurity_manifest/lib/SecureDownload.h $dest
cp libsecurity_mds/lib/mds.h $dest
cp libsecurity_mds/lib/mds_schema.h $dest
cp libsecurity_ssl/lib/CipherSuite.h $dest
cp libsecurity_ssl/lib/SecureTransport.h $dest
cp libsecurity_transform/lib/SecCustomTransform.h $dest
cp libsecurity_transform/lib/SecDecodeTransform.h $dest
cp libsecurity_transform/lib/SecDigestTransform.h $dest
cp libsecurity_transform/lib/SecEncodeTransform.h $dest
cp libsecurity_transform/lib/SecEncryptTransform.h $dest
cp libsecurity_transform/lib/SecReadTransform.h $dest
cp libsecurity_transform/lib/SecSignVerifyTransform.h $dest
cp libsecurity_transform/lib/SecTransform.h $dest
cp libsecurity_transform/lib/SecTransformReadTransform.h $dest
'';
}

View file

@ -0,0 +1,19 @@
{ appleDerivation, xcbuildHook, xpc, dtrace, xnu }:
appleDerivation {
nativeBuildInputs = [ xcbuildHook dtrace ];
# buildInputs = [ Foundation xpc darling ];
buildInputs = [ xpc xnu ];
xcbuildFlags = [ "-target" "Security_frameworks_osx" ];
# NIX_CFLAGS_COMPILE = "-Wno-error -I${xnu}/include/libkern -DPRIVATE -I${xnu}/Library/Frameworks/System.framework/Headers";
preBuild = ''
dtrace -h -C -s OSX/libsecurity_utilities/lib/security_utilities.d -o OSX/libsecurity_utilities/lib/utilities_dtrace.h
xcodebuild SYMROOT=$PWD/Products OBJROOT=$PWD/Intermediates -target copyHeadersToSystem
NIX_CFLAGS_COMPILE+=" -F./Products/Release"
ln -s $PWD/Products/Release/Security.bundle/Contents $PWD/Products/Release/Security.framework
'';
}

View file

@ -0,0 +1,92 @@
{ lib, stdenv, buildPackages, appleDerivation, fetchzip, bsdmake, perl, flex, bison
}:
# this derivation sucks
# locale data was removed after adv_cmds-118, so our base is that because it's easier than
# replicating the bizarre bsdmake file structure
#
# sadly adv_cmds-118 builds a mklocale and colldef that generate files that our libc can no
# longer understand
#
# the more recent adv_cmds release is used for everything else in this package
let recentAdvCmds = fetchzip {
url = "https://opensource.apple.com/tarballs/adv_cmds/adv_cmds-158.tar.gz";
sha256 = "0z081kcprzg5jcvqivfnwvvv6wfxzkjg2jc2lagsf8c7j7vgm8nn";
};
in appleDerivation {
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [ bsdmake perl bison flex ];
buildInputs = [ flex ];
patchPhase = ''
substituteInPlace BSDmakefile \
--replace chgrp true \
--replace /Developer/Makefiles/bin/compress-man-pages.pl true \
--replace "ps.tproj" "" --replace "gencat.tproj" "" --replace "md.tproj" "" \
--replace "tabs.tproj" "" --replace "cap_mkdb.tproj" "" \
--replace "!= tconf --test TARGET_OS_EMBEDDED" "= NO"
substituteInPlace Makefile --replace perl true
for subproject in colldef mklocale monetdef msgdef numericdef timedef; do
substituteInPlace usr-share-locale.tproj/$subproject/BSDmakefile \
--replace /usr/share/locale "" \
--replace '-o ''${BINOWN} -g ''${BINGRP}' "" \
--replace "rsync -a" "cp -r"
done
'';
preBuild = ''
cp -r --no-preserve=all ${recentAdvCmds}/colldef .
pushd colldef
mv locale/collate.h .
flex -t -8 -i scan.l > scan.c
yacc -d parse.y
clang *.c -o colldef -lfl
popd
mv colldef/colldef colldef.tproj/colldef
cp -r --no-preserve=all ${recentAdvCmds}/mklocale .
pushd mklocale
flex -t -8 -i lex.l > lex.c
yacc -d yacc.y
clang *.c -o mklocale -lfl
popd
mv mklocale/mklocale mklocale.tproj/mklocale
'';
buildPhase = ''
runHook preBuild
bsdmake -C usr-share-locale.tproj
${stdenv.cc.targetPrefix}clang ${recentAdvCmds}/ps/*.c -o ps
'';
installPhase = ''
bsdmake -C usr-share-locale.tproj install DESTDIR="$locale/share/locale"
# need to get rid of runtime dependency on flex
# install -d 0755 $locale/bin
# install -m 0755 colldef.tproj/colldef $locale/bin
# install -m 0755 mklocale.tproj/mklocale $locale/bin
install -d 0755 $ps/bin
install ps $ps/bin/ps
touch "$out"
'';
outputs = [
"out"
"ps"
"locale"
];
setOutputFlags = false;
meta = {
platforms = lib.platforms.darwin;
maintainers = with lib.maintainers; [ gridaphobe ];
};
}

View file

@ -0,0 +1,51 @@
{ lib, appleDerivation, xcbuild, ncurses, libutil }:
appleDerivation {
# We can't just run the root build, because https://github.com/facebook/xcbuild/issues/264
patchPhase = ''
substituteInPlace adv_cmds.xcodeproj/project.pbxproj \
--replace '/usr/lib/libtermcap.dylib' 'libncurses.dylib'
'';
# pkill requires special private headers that are unavailable in
# NixPkgs. These ones are needed:
# - xpc/xpxc.h
# - os/base_private.h
# - _simple.h
# We disable it here for now. TODO: build pkill inside adv_cmds
buildPhase = ''
targets=$(xcodebuild -list \
| awk '/Targets:/{p=1;print;next} p&&/^\s*$/{p=0};p' \
| tail -n +2 | sed 's/^[ \t]*//' \
| grep -v -e Desktop -e Embedded -e mklocale -e pkill -e pgrep -e colldef)
for i in $targets; do
xcodebuild SYMROOT=$PWD/Products OBJROOT=$PWD/Intermediates -target $i
done
'';
# temporary install phase until xcodebuild has "install" support
installPhase = ''
for f in Products/Release/*; do
if [ -f $f ]; then
install -D $f $out/bin/$(basename $f)
fi
done
mkdir -p $out/System/Library/LaunchDaemons
install fingerd/finger.plist $out/System/Library/LaunchDaemons
# from variant_links.sh
# ln -s $out/bin/pkill $out/bin/pgrep
# ln -s $out/share/man/man1/pkill.1 $out/share/man/man1/pgrep.1
'';
nativeBuildInputs = [ xcbuild ];
buildInputs = [ ncurses libutil ];
meta = {
platforms = lib.platforms.darwin;
maintainers = with lib.maintainers; [ matthewbauer ];
};
}

View file

@ -0,0 +1,39 @@
{ lib, appleDerivation', stdenvNoCC }:
appleDerivation' stdenvNoCC {
dontBuild = true;
postPatch = ''
substituteInPlace Makefile \
--replace '/bin/mkdir' 'mkdir' \
--replace '/usr/bin/install' 'install'
'';
installFlags = [ "EXPORT_DSTDIR=/include/architecture" ];
DSTROOT = "$(out)";
appleHeaders = ''
architecture/alignment.h
architecture/byte_order.h
architecture/i386/alignment.h
architecture/i386/asm_help.h
architecture/i386/byte_order.h
architecture/i386/cpu.h
architecture/i386/desc.h
architecture/i386/fpu.h
architecture/i386/frame.h
architecture/i386/io.h
architecture/i386/pio.h
architecture/i386/reg_help.h
architecture/i386/sel.h
architecture/i386/table.h
architecture/i386/tss.h
'';
meta = with lib; {
maintainers = with maintainers; [ copumpkin ];
platforms = platforms.darwin;
license = licenses.apsl20;
};
}

View file

@ -0,0 +1,32 @@
{ lib, appleDerivation, xcbuildHook }:
appleDerivation {
nativeBuildInputs = [ xcbuildHook ];
# These PBXcp calls should be patched in xcbuild to allow them to
# automatically be prefixed.
patchPhase = ''
substituteInPlace basic_cmds.xcodeproj/project.pbxproj \
--replace "dstPath = /usr/share/man/man1;" "dstPath = $out/share/man/man1;" \
--replace "dstPath = /usr/share/man/man5;" "dstPath = $out/share/man/man5;"
'';
# temporary install phase until xcodebuild has "install" support
installPhase = ''
for f in Products/Release/*; do
if [ -f $f ]; then
install -D $f $out/bin/$(basename $f)
fi
done
for n in 1; do
mkdir -p $out/share/man/man$n
install */*.$n $out/share/man/man$n
done
'';
meta = {
platforms = lib.platforms.darwin;
maintainers = with lib.maintainers; [ matthewbauer ];
};
}

View file

@ -0,0 +1,43 @@
{ lib, appleDerivation, stdenv, bison, flex }:
let
# Hard to get CC to pull this off without infinite recursion
targetTargetPrefix = lib.optionalString
(with stdenv; hostPlatform != targetPlatform)
(stdenv.targetPlatform.config + "-");
in
appleDerivation {
nativeBuildInputs = [ bison flex ];
buildPhase = ''
cd migcom.tproj
# redundant file, don't know why apple not removing it.
rm handler.c
yacc -d parser.y
flex --header-file=lexxer.yy.h -o lexxer.yy.c lexxer.l
$CC -std=gnu99 -Os -dead_strip -DMIG_VERSION=\"$pname-$version\" -I. -o migcom *.c
'';
installPhase = ''
mkdir -p $out/bin $out/libexec $out/share/man/man1
chmod +x mig.sh
cp mig.sh $out/bin/mig
cp migcom $out/libexec
ln -s $out/libexec/migcom $out/bin/migcom
cp mig.1 $out/share/man/man1
cp migcom.1 $out/share/man/man1
substituteInPlace $out/bin/mig \
--replace 'arch=`/usr/bin/arch`' 'arch=${stdenv.targetPlatform.darwinArch}' \
--replace '/usr/bin/' "" \
--replace '/bin/rmdir' "rmdir" \
--replace 'C=''${MIGCC}' "C=${targetTargetPrefix}cc"
'';
}

View file

@ -0,0 +1,49 @@
{ lib, appleDerivation, makeWrapper }:
appleDerivation {
nativeBuildInputs = [ makeWrapper ];
patchPhase = ''
substituteInPlace mk/bsd.prog.mk \
--replace '-o ''${BINOWN} -g ''${BINGRP}' "" \
--replace '-o ''${SCRIPTSOWN_''${.ALLSRC:T}}' "" \
--replace '-g ''${SCRIPTSGRP_''${.ALLSRC:T}}' ""
substituteInPlace mk/bsd.lib.mk --replace '-o ''${LIBOWN} -g ''${LIBGRP}' ""
substituteInPlace mk/bsd.info.mk --replace '-o ''${INFOOWN} -g ''${INFOGRP}' ""
substituteInPlace mk/bsd.doc.mk --replace '-o ''${BINOWN} -g ''${BINGRP}' ""
substituteInPlace mk/bsd.man.mk --replace '-o ''${MANOWN} -g ''${MANGRP}' ""
substituteInPlace mk/bsd.files.mk \
--replace '-o ''${''${group}OWN_''${.ALLSRC:T}}' "" \
--replace '-g ''${''${group}GRP_''${.ALLSRC:T}}' "" \
--replace '-o ''${''${group}OWN} -g ''${''${group}GRP}' ""
substituteInPlace mk/bsd.incs.mk \
--replace '-o ''${''${group}OWN_''${.ALLSRC:T}}' "" \
--replace '-g ''${''${group}GRP_''${.ALLSRC:T}}' "" \
--replace '-o ''${''${group}OWN} -g ''${''${group}GRP}' ""
'';
buildPhase = ''
objs=()
for file in $(find . -name '*.c'); do
obj="$(basename "$file" .c).o"
objs+=("$obj")
$CC -c "$file" -o "$obj" -DDEFSHELLNAME='"sh"' -D__FBSDID=__RCSID -mdynamic-no-pic -g
done
$CC "''${objs[@]}" -o bsdmake
'';
installPhase = ''
install -d 0644 $out/bin
install -m 0755 bsdmake $out/bin
install -d 0644 $out/share/mk
install -m 0755 mk/* $out/share/mk
'';
preFixup = ''
wrapProgram "$out/bin/bsdmake" --add-flags "-m $out/share/mk"
'';
meta = {
platforms = lib.platforms.darwin;
};
}

View file

@ -0,0 +1,216 @@
{ lib, stdenv, appleDerivation', launchd, bootstrap_cmds, xnu, ppp, IOKit, eap8021x, Security
, headersOnly ? false }:
appleDerivation' stdenv {
meta.broken = stdenv.cc.nativeLibc;
nativeBuildInputs = lib.optionals (!headersOnly) [ bootstrap_cmds ];
buildInputs = lib.optionals (!headersOnly) [ launchd ppp IOKit eap8021x ];
propagatedBuildInputs = lib.optionals (!headersOnly) [ Security ];
patchPhase = lib.optionalString (!headersOnly) ''
HACK=$PWD/hack
mkdir $HACK
cp -r ${xnu}/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/net $HACK
substituteInPlace SystemConfiguration.fproj/SCNetworkReachabilityInternal.h \
--replace '#include <xpc/xpc.h>' ""
substituteInPlace SystemConfiguration.fproj/SCNetworkReachability.c \
--replace ''$'#define\tHAVE_VPN_STATUS' ""
substituteInPlace SystemConfiguration.fproj/reachability/SCNetworkReachabilityServer_client.c \
--replace '#include <xpc/xpc.h>' '#include "fake_xpc.h"' \
--replace '#include <xpc/private.h>' "" \
# Our neutered CoreFoundation doesn't have this function, but I think we'll live...
substituteInPlace SystemConfiguration.fproj/SCNetworkConnectionPrivate.c \
--replace 'CFPreferencesAppValueIsForced(serviceID, USER_PREFERENCES_APPLICATION_ID)' 'FALSE' \
--replace 'CFPreferencesAppValueIsForced(userPrivate->serviceID, USER_PREFERENCES_APPLICATION_ID)' 'FALSE'
cat >SystemConfiguration.fproj/fake_xpc.h <<EOF
typedef void *xpc_type_t;
typedef void *xpc_object_t;
typedef void *xpc_connection_t;
xpc_type_t xpc_get_type(xpc_object_t object);
xpc_object_t xpc_dictionary_create(const char * const *keys, const xpc_object_t *values, size_t count);
char *xpc_copy_description(xpc_object_t object);
int64_t xpc_dictionary_get_int64(xpc_object_t xdict, const char *key);
uint64_t xpc_dictionary_get_uint64(xpc_object_t xdict, const char *key);
void xpc_connection_set_event_handler(xpc_connection_t connection, void *handler);
extern const struct _xpc_type_s _xpc_type_error;
#define XPC_TYPE_ERROR (&_xpc_type_error)
extern const struct _xpc_type_s _xpc_type_dictionary;
#define XPC_TYPE_DICTIONARY (&_xpc_type_dictionary)
extern const struct _xpc_type_s _xpc_type_array;
#define XPC_TYPE_ARRAY (&_xpc_type_array)
extern const struct _xpc_dictionary_s _xpc_error_connection_interrupted;
#define XPC_ERROR_CONNECTION_INTERRUPTED (&_xpc_error_connection_interrupted)
extern const struct _xpc_dictionary_s _xpc_error_connection_invalid;
#define XPC_ERROR_CONNECTION_INVALID (&_xpc_error_connection_invalid)
extern const char *const _xpc_error_key_description;
#define XPC_ERROR_KEY_DESCRIPTION _xpc_error_key_description
#define XPC_CONNECTION_MACH_SERVICE_PRIVILEGED (1 << 1)
EOF
'';
dontBuild = headersOnly;
buildPhase = ''
pushd SystemConfiguration.fproj >/dev/null
mkdir -p SystemConfiguration.framework/Resources
cp ../get-mobility-info SystemConfiguration.framework/Resources
cp Info.plist SystemConfiguration.framework/Resources
cp -r English.lproj SystemConfiguration.framework/Resources
cp NetworkConfiguration.plist SystemConfiguration.framework/Resources
mkdir -p SystemConfiguration.framework/Headers
mkdir -p SystemConfiguration.framework/PrivateHeaders
# The standard public headers
cp SCSchemaDefinitions.h SystemConfiguration.framework/Headers
cp SystemConfiguration.h SystemConfiguration.framework/Headers
cp SCDynamicStore.h SystemConfiguration.framework/Headers
cp SCDynamicStoreCopySpecific.h SystemConfiguration.framework/Headers
cp SCPreferences.h SystemConfiguration.framework/Headers
cp CaptiveNetwork.h SystemConfiguration.framework/Headers
cp SCPreferencesPath.h SystemConfiguration.framework/Headers
cp SCDynamicStoreKey.h SystemConfiguration.framework/Headers
cp SCPreferencesSetSpecific.h SystemConfiguration.framework/Headers
cp SCNetworkConfiguration.h SystemConfiguration.framework/Headers
cp SCNetworkConnection.h SystemConfiguration.framework/Headers
cp SCNetworkReachability.h SystemConfiguration.framework/Headers
cp DHCPClientPreferences.h SystemConfiguration.framework/Headers
cp SCNetwork.h SystemConfiguration.framework/Headers
cp SCDynamicStoreCopyDHCPInfo.h SystemConfiguration.framework/Headers
# TODO: Do we want to preserve private headers or just make them public?
cp SCDPlugin.h SystemConfiguration.framework/PrivateHeaders
cp SCPrivate.h SystemConfiguration.framework/PrivateHeaders
cp SCDynamicStorePrivate.h SystemConfiguration.framework/PrivateHeaders
cp SCDynamicStoreCopySpecificPrivate.h SystemConfiguration.framework/PrivateHeaders
cp SCDynamicStoreSetSpecificPrivate.h SystemConfiguration.framework/PrivateHeaders
cp SCValidation.h SystemConfiguration.framework/PrivateHeaders
cp SCPreferencesPrivate.h SystemConfiguration.framework/PrivateHeaders
cp DeviceOnHold.h SystemConfiguration.framework/PrivateHeaders
cp LinkConfiguration.h SystemConfiguration.framework/PrivateHeaders
cp SCPreferencesPathKey.h SystemConfiguration.framework/PrivateHeaders
cp SCPreferencesSetSpecificPrivate.h SystemConfiguration.framework/PrivateHeaders
cp SCNetworkConnectionPrivate.h SystemConfiguration.framework/PrivateHeaders
cp SCPreferencesGetSpecificPrivate.h SystemConfiguration.framework/PrivateHeaders
cp SCSchemaDefinitionsPrivate.h SystemConfiguration.framework/PrivateHeaders
cp SCNetworkConfigurationPrivate.h SystemConfiguration.framework/PrivateHeaders
cp SCPreferencesKeychainPrivate.h SystemConfiguration.framework/PrivateHeaders
cp SCNetworkSignature.h SystemConfiguration.framework/PrivateHeaders
cp SCNetworkSignaturePrivate.h SystemConfiguration.framework/PrivateHeaders
cp VPNPrivate.h SystemConfiguration.framework/PrivateHeaders
cp VPNConfiguration.h SystemConfiguration.framework/PrivateHeaders
cp VPNTunnelPrivate.h SystemConfiguration.framework/PrivateHeaders
cp VPNTunnel.h SystemConfiguration.framework/PrivateHeaders
mkdir derived
cat >derived/SystemConfiguration_vers.c <<EOF
const unsigned char SystemConfigurationVersionString[] __attribute__ ((used)) = "@(#)PROGRAM:SystemConfiguration PROJECT:configd-" "\n"; const double SystemConfigurationVersionNumber __attribute__ ((used)) = (double)0.;
EOF
mig -arch x86_64 -header derived/shared_dns_info.h -user derived/shared_dns_infoUser.c -sheader /dev/null -server /dev/null ../dnsinfo/shared_dns_info.defs
mig -arch x86_64 -header derived/config.h -user derived/configUser.c -sheader /dev/null -server /dev/null config.defs
mig -arch x86_64 -header derived/helper.h -user derived/helperUser.c -sheader /dev/null -server /dev/null helper/helper.defs
mig -arch x86_64 -header derived/pppcontroller.h -user derived/pppcontrollerUser.c -sheader /dev/null -server /dev/null pppcontroller.defs
$CC -I. -Ihelper -Iderived -F. -c SCSchemaDefinitions.c -o SCSchemaDefinitions.o
$CC -I. -Ihelper -Iderived -F. -c SCD.c -o SCD.o
$CC -I. -Ihelper -Iderived -F. -c SCDKeys.c -o SCDKeys.o
$CC -I. -Ihelper -Iderived -F. -c SCDPrivate.c -o SCDPrivate.o
$CC -I. -Ihelper -Iderived -F. -c SCDPlugin.c -o SCDPlugin.o
$CC -I. -Ihelper -Iderived -F. -c CaptiveNetwork.c -o CaptiveNetwork.o
$CC -I. -Ihelper -Iderived -F. -c SCDOpen.c -o SCDOpen.o
$CC -I. -Ihelper -Iderived -F. -c SCDList.c -o SCDList.o
$CC -I. -Ihelper -Iderived -F. -c SCDAdd.c -o SCDAdd.o
$CC -I. -Ihelper -Iderived -F. -c SCDGet.c -o SCDGet.o
$CC -I. -Ihelper -Iderived -F. -c SCDSet.c -o SCDSet.o
$CC -I. -Ihelper -Iderived -F. -c SCDRemove.c -o SCDRemove.o
$CC -I. -Ihelper -Iderived -F. -c SCDNotify.c -o SCDNotify.o
$CC -I. -Ihelper -Iderived -F. -c SCDNotifierSetKeys.c -o SCDNotifierSetKeys.o
$CC -I. -Ihelper -Iderived -F. -c SCDNotifierAdd.c -o SCDNotifierAdd.o
$CC -I. -Ihelper -Iderived -F. -c SCDNotifierRemove.c -o SCDNotifierRemove.o
$CC -I. -Ihelper -Iderived -F. -c SCDNotifierGetChanges.c -o SCDNotifierGetChanges.o
$CC -I. -Ihelper -Iderived -F. -c SCDNotifierWait.c -o SCDNotifierWait.o
$CC -I. -Ihelper -Iderived -F. -c SCDNotifierInformViaCallback.c -o SCDNotifierInformViaCallback.o
$CC -I. -Ihelper -Iderived -F. -c SCDNotifierInformViaFD.c -o SCDNotifierInformViaFD.o
$CC -I. -Ihelper -Iderived -F. -c SCDNotifierInformViaSignal.c -o SCDNotifierInformViaSignal.o
$CC -I. -Ihelper -Iderived -F. -c SCDNotifierCancel.c -o SCDNotifierCancel.o
$CC -I. -Ihelper -Iderived -F. -c SCDSnapshot.c -o SCDSnapshot.o
$CC -I. -Ihelper -Iderived -F. -c SCP.c -o SCP.o
$CC -I. -Ihelper -Iderived -F. -c SCPOpen.c -o SCPOpen.o
$CC -I. -Ihelper -Iderived -F. -c SCPLock.c -o SCPLock.o
$CC -I. -Ihelper -Iderived -F. -c SCPUnlock.c -o SCPUnlock.o
$CC -I. -Ihelper -Iderived -F. -c SCPList.c -o SCPList.o
$CC -I. -Ihelper -Iderived -F. -c SCPGet.c -o SCPGet.o
$CC -I. -Ihelper -Iderived -F. -c SCPAdd.c -o SCPAdd.o
$CC -I. -Ihelper -Iderived -F. -c SCPSet.c -o SCPSet.o
$CC -I. -Ihelper -Iderived -F. -c SCPRemove.c -o SCPRemove.o
$CC -I. -Ihelper -Iderived -F. -c SCPCommit.c -o SCPCommit.o
$CC -I. -Ihelper -Iderived -F. -c SCPApply.c -o SCPApply.o
$CC -I. -Ihelper -Iderived -F. -c SCPPath.c -o SCPPath.o
$CC -I. -Ihelper -Iderived -F. -c SCDConsoleUser.c -o SCDConsoleUser.o
$CC -I. -Ihelper -Iderived -F. -c SCDHostName.c -o SCDHostName.o
$CC -I. -Ihelper -Iderived -F. -c SCLocation.c -o SCLocation.o
$CC -I. -Ihelper -Iderived -F. -c SCNetwork.c -o SCNetwork.o
$CC -I. -Ihelper -Iderived -F. -c derived/pppcontrollerUser.c -o pppcontrollerUser.o
$CC -I. -Ihelper -Iderived -F. -c SCNetworkConnection.c -o SCNetworkConnection.o
$CC -I. -Ihelper -Iderived -F. -c SCNetworkConnectionPrivate.c -o SCNetworkConnectionPrivate.o
$CC -I. -Ihelper -Iderived -I../dnsinfo -F. -c SCNetworkReachability.c -o SCNetworkReachability.o
$CC -I. -Ihelper -Iderived -F. -c SCProxies.c -o SCProxies.o
$CC -I. -Ihelper -Iderived -F. -c DHCP.c -o DHCP.o
$CC -I. -Ihelper -Iderived -F. -c moh.c -o moh.o
$CC -I. -Ihelper -Iderived -F. -c DeviceOnHold.c -o DeviceOnHold.o
$CC -I. -Ihelper -Iderived -I $HACK -F. -c LinkConfiguration.c -o LinkConfiguration.o
$CC -I. -Ihelper -Iderived -F. -c dy_framework.c -o dy_framework.o
$CC -I. -Ihelper -Iderived -I $HACK -F. -c VLANConfiguration.c -o VLANConfiguration.o
$CC -I. -Ihelper -Iderived -F. -c derived/configUser.c -o configUser.o
$CC -I. -Ihelper -Iderived -F. -c SCPreferencesPathKey.c -o SCPreferencesPathKey.o
$CC -I. -Ihelper -Iderived -I../dnsinfo -F. -c derived/shared_dns_infoUser.c -o shared_dns_infoUser.o
$CC -I. -Ihelper -Iderived -F. -c SCNetworkConfigurationInternal.c -o SCNetworkConfigurationInternal.o
$CC -I. -Ihelper -Iderived -F. -c SCNetworkInterface.c -o SCNetworkInterface.o
$CC -I. -Ihelper -Iderived -F. -c SCNetworkProtocol.c -o SCNetworkProtocol.o
$CC -I. -Ihelper -Iderived -F. -c SCNetworkService.c -o SCNetworkService.o
$CC -I. -Ihelper -Iderived -F. -c SCNetworkSet.c -o SCNetworkSet.o
$CC -I. -Ihelper -Iderived -I $HACK -F. -c BondConfiguration.c -o BondConfiguration.o
$CC -I. -Ihelper -Iderived -I $HACK -F. -c BridgeConfiguration.c -o BridgeConfiguration.o
$CC -I. -Ihelper -Iderived -F. -c helper/SCHelper_client.c -o SCHelper_client.o
$CC -I. -Ihelper -Iderived -F. -c SCPreferencesKeychainPrivate.c -o SCPreferencesKeychainPrivate.o
$CC -I. -Ihelper -Iderived -F. -c SCNetworkSignature.c -o SCNetworkSignature.o
$CC -I. -Ihelper -Iderived -F. -c VPNPrivate.c -o VPNPrivate.o
$CC -I. -Ihelper -Iderived -F. -c VPNConfiguration.c -o VPNConfiguration.o
$CC -I. -Ihelper -Iderived -F. -c VPNTunnel.c -o VPNTunnel.o
$CC -I. -Ihelper -Iderived -F. -c derived/helperUser.c -o helperUser.o
$CC -I. -Ihelper -Iderived -F. -c reachability/SCNetworkReachabilityServer_client.c -o SCNetworkReachabilityServer_client.o
$CC -I. -Ihelper -Iderived -F. -c reachability/rb.c -o rb.o
$CC -I. -Ihelper -Iderived -F. -c derived/SystemConfiguration_vers.c -o SystemConfiguration_vers.o
$CC -dynamiclib *.o -install_name $out/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration -dead_strip -framework CoreFoundation -single_module -o SystemConfiguration.framework/SystemConfiguration
popd >/dev/null
'';
installPhase = ''
mkdir -p $out/include
cp dnsinfo/*.h $out/include/
'' + lib.optionalString (!headersOnly) ''
mkdir -p $out/Library/Frameworks/
mv SystemConfiguration.fproj/SystemConfiguration.framework $out/Library/Frameworks
'';
}

View file

@ -0,0 +1,9 @@
{ appleDerivation', stdenvNoCC }:
appleDerivation' stdenvNoCC {
dontBuild = true;
installPhase = ''
mkdir -p $out/include/
cp copyfile.h $out/include/
'';
}

View file

@ -0,0 +1,315 @@
{ lib, stdenv, fetchurl, fetchzip, pkgs }:
let
# This attrset can in theory be computed automatically, but for that to work nicely we need
# import-from-derivation to work properly. Currently it's rather ugly when we try to bootstrap
# a stdenv out of something like this. With some care we can probably get rid of this, but for
# now it's staying here.
versions = {
"osx-10.12.6" = {
xnu = "3789.70.16";
libiconv = "50";
Libnotify = "165.20.1";
objc4 = "709.1";
dyld = "433.5";
CommonCrypto = "60092.50.5";
copyfile = "138";
ppp = "838.50.1";
libclosure = "67";
Libinfo = "503.50.4";
Libsystem = "1238.60.2";
removefile = "45";
libresolv = "64";
libplatform = "126.50.8";
mDNSResponder = "765.50.9";
libutil = "47.30.1";
libunwind = "35.3";
Libc = "1158.50.2";
dtrace = "209.50.12";
libpthread = "218.60.3";
hfs = "366.70.1";
};
"osx-10.11.6" = {
PowerManagement = "572.50.1";
dtrace = "168";
xnu = "3248.60.10";
libpthread = "138.10.4";
libiconv = "44";
Libnotify = "150.40.1";
objc4 = "680";
eap8021x = "222.40.1";
dyld = "360.22";
architecture = "268";
CommonCrypto = "60075.50.1";
copyfile = "127";
Csu = "85";
ppp = "809.50.2";
libclosure = "65";
Libinfo = "477.50.4";
Libsystem = "1226.10.1";
removefile = "41";
libresolv = "60";
# Their release page is a bit of a mess here, so I'm going to lie a bit and say this version
# is the right one, even though it isn't. The version I have here doesn't appear to be linked
# to any OS releases, but Apple also doesn't mention mDNSResponder from 10.11 to 10.11.6, and
# neither of those versions are publicly available.
libplatform = "125";
mDNSResponder = "625.41.2";
# IOKit contains a set of packages with different versions, so we don't have a general version
IOKit = "";
libutil = "43";
libunwind = "35.3";
Librpcsvc = "26";
developer_cmds= "62";
network_cmds = "481.20.1";
basic_cmds = "55";
adv_cmds = "163";
file_cmds = "264.1.1";
shell_cmds = "187";
system_cmds = "550.6";
diskdev_cmds = "593";
top = "108";
text_cmds = "99";
};
"osx-10.11.5" = {
Libc = "1082.50.1"; # 10.11.6 still unreleased :/
};
"osx-10.10.5" = {
adv_cmds = "158";
CF = "1153.18";
ICU = "531.48";
libdispatch = "442.1.4";
Security = "57031.40.6";
IOAudioFamily = "203.3";
IOFireWireFamily = "458";
IOFWDVComponents = "207.4.1";
IOFireWireAVC = "423";
IOFireWireSBP2 = "427";
IOFireWireSerialBusProtocolTransport = "251.0.1";
IOGraphics = "485.40.1";
IOHIDFamily = "606.40.1";
IONetworkingFamily = "101";
IOSerialFamily = "74.20.1";
IOStorageFamily = "182.1.1";
IOBDStorageFamily = "14";
IOCDStorageFamily = "51";
IODVDStorageFamily = "35";
IOKitUser = "1050.20.2";
};
"osx-10.9.5" = {
launchd = "842.92.1";
libauto = "185.5";
Libc = "997.90.3"; # We use this, but not from here
Libsystem = "1197.1.1";
Security = "55471.14.18";
security_dotmac_tp = "55107.1";
IOStorageFamily = "172";
};
"osx-10.8.5" = {
configd = "453.19";
Libc = "825.40.1";
IOUSBFamily = "630.4.5";
};
"osx-10.8.4" = {
IOUSBFamily = "560.4.2";
};
"osx-10.7.4" = {
Libm = "2026";
};
"osx-10.6.2" = {
CarbonHeaders = "18.1";
};
"osx-10.5.8" = {
adv_cmds = "119";
};
"dev-tools-7.0" = {
bootstrap_cmds = "93";
};
"dev-tools-5.1" = {
bootstrap_cmds = "86";
};
"dev-tools-3.2.6" = {
bsdmake = "24";
};
};
fetchApple' = pname: version: sha256: let
# When cross-compiling, fetchurl depends on libiconv, resulting
# in an infinite recursion without this. It's not clear why this
# worked fine when not cross-compiling
fetch = if pname == "libiconv"
then stdenv.fetchurlBoot
else fetchurl;
in fetch {
url = "http://www.opensource.apple.com/tarballs/${pname}/${pname}-${version}.tar.gz";
inherit sha256;
};
fetchApple = sdkName: sha256: pname: let
version = versions.${sdkName}.${pname};
in fetchApple' pname version sha256;
appleDerivation'' = stdenv: pname: version: sdkName: sha256: attrs: stdenv.mkDerivation ({
inherit pname version;
src = if attrs ? srcs then null else (fetchApple' pname version sha256);
enableParallelBuilding = true;
# In rare cases, APPLE may drop some headers quietly on new release.
doInstallCheck = attrs ? appleHeaders;
passAsFile = [ "appleHeaders" ];
installCheckPhase = ''
cd $out/include
result=$(diff -u "$appleHeadersPath" <(find * -type f | sort) --label "Listed in appleHeaders" --label "Found in \$out/include" || true)
if [ -z "$result" ]; then
echo "Apple header list is matched."
else
echo >&2 "\
Apple header list is inconsistent, please ensure no header file is unexpectedly dropped.
$result
"
exit 1
fi
'';
} // attrs // {
meta = (with lib; {
platforms = platforms.darwin;
license = licenses.apsl20;
}) // (attrs.meta or {});
});
IOKitSpecs = {
IOAudioFamily = fetchApple "osx-10.10.5" "0ggq7za3iq8g02j16rj67prqhrw828jsw3ah3bxq8a1cvr55aqnq";
IOFireWireFamily = fetchApple "osx-10.10.5" "059qa1m668kwvchl90cqcx35b31zaqdg61zi11y1imn5s389y2g1";
IOFWDVComponents = fetchApple "osx-10.10.5" "1brr0yn6mxgapw3bvlhyissfksifzj2mqsvj9vmps6zwcsxjfw7m";
IOFireWireAVC = fetchApple "osx-10.10.5" "194an37gbqs9s5s891lmw6prvd1m2362602s8lj5m89fp9h8mbal";
IOFireWireSBP2 = fetchApple "osx-10.10.5" "1mym158kp46y1vfiq625b15ihh4jjbpimfm7d56wlw6l2syajqvi";
IOFireWireSerialBusProtocolTransport = fetchApple "osx-10.10.5" "09kiq907qpk94zbij1mrcfcnyyc5ncvlxavxjrj4v5braxm78lhi";
IOGraphics = fetchApple "osx-10.10.5" "1z0x3yrv0p8pfdqnvwf8rvrf9wip593lhm9q6yzbclz3fn53ad0p";
IOHIDFamily = fetchApple "osx-10.10.5" "0yibagwk74imp3j3skjycm703s5ybdqw0qlsmnml6zwjpbrz5894";
IONetworkingFamily = fetchApple "osx-10.10.5" "04as1hc8avncijf61mp9dmplz8vb1inhirkd1g74gah08lgrfs9j";
IOSerialFamily = fetchApple "osx-10.10.5" "0jh12aanxcigqi9w6wqzbwjdin9m48zwrhdj3n4ki0h41sg89y91";
IOStorageFamily = fetchApple "osx-10.9.5" "0w5yr8ppl82anwph2zba0ppjji6ipf5x410zhcm1drzwn4bbkxrj";
IOBDStorageFamily = fetchApple "osx-10.10.5" "1rbvmh311n853j5qb6hfda94vym9wkws5w736w2r7dwbrjyppc1q";
IOCDStorageFamily = fetchApple "osx-10.10.5" "1905sxwmpxdcnm6yggklc5zimx1558ygm3ycj6b34f9h48xfxzgy";
IODVDStorageFamily = fetchApple "osx-10.10.5" "1fv82rn199mi998l41c0qpnlp3irhqp2rb7v53pxbx7cra4zx3i6";
# There should be an IOStreamFamily project here, but they haven't released it :(
IOUSBFamily = fetchApple "osx-10.8.5" "1znqb6frxgab9mkyv7csa08c26p9p0ip6hqb4wm9c7j85kf71f4j"; # This is from 10.8 :(
IOUSBFamily_older = fetchApple "osx-10.8.4" "113lmpz8n6sibd27p42h8bl7a6c3myc6zngwri7gnvf8qlajzyml" "IOUSBFamily"; # This is even older :(
IOKitUser = fetchApple "osx-10.10.5" "1jzndziv97bhjxmla8nib5fpcswbvsxr04447g251ls81rw313lb";
# There should be an IOVideo here, but they haven't released it :(
};
IOKitSrcs = lib.mapAttrs (name: value: if lib.isFunction value then value name else value) IOKitSpecs;
in
# darwin package set
self:
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:
let
pname = builtins.head (lib.splitString "/" namePath);
appleDerivation' = stdenv: appleDerivation'' stdenv pname version sdkName sha256;
appleDerivation = appleDerivation' stdenv;
callPackage = self.newScope { inherit appleDerivation' appleDerivation; };
in callPackage (./. + "/${namePath}");
applePackage = namePath: sdkName: sha256: let
pname = builtins.head (lib.splitString "/" namePath);
version = versions.${sdkName}.${pname};
in applePackage' namePath version sdkName sha256;
# Only used for bootstrapping. Its convenient because it was the last version to come with a real makefile.
adv_cmds-boot = applePackage "adv_cmds/boot.nix" "osx-10.5.8" "102ssayxbg9wb35mdmhswbnw0bg7js3pfd8fcbic83c5q3bqa6c6" {};
in
developerToolsPackages_11_3_1 // macosPackages_11_0_1 // {
# TODO: shorten this list, we should cut down to a minimum set of bootstrap or necessary packages here.
inherit (adv_cmds-boot) ps locale;
architecture = applePackage "architecture" "osx-10.11.6" "1pbpjcd7is69hn8y29i98ci0byik826if8gnp824ha92h90w0fq3" {};
bsdmake = applePackage "bsdmake" "dev-tools-3.2.6" "11a9kkhz5bfgi1i8kpdkis78lhc6b5vxmhd598fcdgra1jw4iac2" {};
CarbonHeaders = applePackage "CarbonHeaders" "osx-10.6.2" "1zam29847cxr6y9rnl76zqmkbac53nx0szmqm9w5p469a6wzjqar" {};
CommonCrypto = applePackage "CommonCrypto" "osx-10.12.6" "0sgsqjcxbdm2g2zfpc50mzmk4b4ldyw7xvvkwiayhpczg1fga4ff" {};
configd = applePackage "configd" "osx-10.8.5" "1gxakahk8gallf16xmhxhprdxkh3prrmzxnmxfvj0slr0939mmr2" {
Security = applePackage "Security/boot.nix" "osx-10.9.5" "1nv0dczf67dhk17hscx52izgdcyacgyy12ag0jh6nl5hmfzsn8yy" {};
};
copyfile = applePackage "copyfile" "osx-10.12.6" "0a70bvzndkava1a946cdq42lnjhg7i7b5alpii3lap6r5fkvas0n" {};
Csu = applePackage "Csu" "osx-10.11.6" "0yh5mslyx28xzpv8qww14infkylvc1ssi57imhi471fs91sisagj" {};
dtrace = applePackage "dtrace" "osx-10.12.6" "0hpd6348av463yqf70n3xkygwmf1i5zza8kps4zys52sviqz3a0l" {};
dyld = applePackage "dyld" "osx-10.12.6" "0q4jmk78b5ajn33blh4agyq6v2a63lpb3fln78az0dy12bnp1qqk" {};
eap8021x = applePackage "eap8021x" "osx-10.11.6" "0iw0qdib59hihyx2275rwq507bq2a06gaj8db4a8z1rkaj1frskh" {};
IOKit = applePackage "IOKit" "osx-10.11.6" "0kcbrlyxcyirvg5p95hjd9k8a01k161zg0bsfgfhkb90kh2s8x00" { inherit IOKitSrcs; };
launchd = applePackage "launchd" "osx-10.9.5" "0w30hvwqq8j5n90s3qyp0fccxflvrmmjnicjri4i1vd2g196jdgj" {};
libauto = applePackage "libauto" "osx-10.9.5" "17z27yq5d7zfkwr49r7f0vn9pxvj95884sd2k6lq6rfaz9gxqhy3" {};
Libc = applePackage "Libc" "osx-10.12.6" "183wcy1nlj2wkpfsx3k3lyv917mk8r2p72qw8lb89mbjsw3yw0xx" {
Libc_10-9 = fetchzip {
url = "http://www.opensource.apple.com/tarballs/Libc/Libc-997.90.3.tar.gz";
sha256 = "1xchgxkxg5288r2b9yfrqji2gsgdap92k4wx2dbjwslixws12pq7";
};
Libc_old = applePackage "Libc/825_40_1.nix" "osx-10.8.5" "0xsx1im52gwlmcrv4lnhhhn9dyk5ci6g27k6yvibn9vj8fzjxwcf" {};
};
libclosure = applePackage "libclosure" "osx-10.11.6" "1zqy1zvra46cmqv6vsf1mcsz3a76r9bky145phfwh4ab6y15vjpq" {};
libdispatch = applePackage "libdispatch" "osx-10.10.5" "0jsfbzp87lwk9snlby0hd4zvj7j894p5q3cw0wdx9ny1mcp3kdcj" {};
libiconv = applePackage "libiconv" "osx-10.12.6" "1gg5h6z8sk851bhv87vyxzs54jmqz6lh57ny8j4s51j7srja0nly" {};
Libinfo = applePackage "Libinfo" "osx-10.11.6" "0qjgkd4y8sjvwjzv5wwyzkb61pg8wwg95bkp721dgzv119dqhr8x" {};
Libm = applePackage "Libm" "osx-10.7.4" "02sd82ig2jvvyyfschmb4gpz6psnizri8sh6i982v341x6y4ysl7" {};
Libnotify = applePackage "Libnotify" "osx-10.12.6" "0p5qhvalf6j1w6n8xwywhn6dvbpzv74q5wqrgs8rwfpf74wg6s9z" {};
libplatform = applePackage "libplatform" "osx-10.12.6" "0rh1f5ybvwz8s0nwfar8s0fh7jbgwqcy903cv2x8m15iq1x599yn" {};
libpthread = applePackage "libpthread" "osx-10.12.6" "1j6541rcgjpas1fc77ip5krjgw4bvz6jq7bq7h9q7axb0jv2ns6c" {};
libresolv = applePackage "libresolv" "osx-10.12.6" "077j6ljfh7amqpk2146rr7dsz5vasvr3als830mgv5jzl7l6vz88" {};
Libsystem = applePackage "Libsystem" "osx-10.12.6" "1082ircc1ggaq3wha218vmfa75jqdaqidsy1bmrc4ckfkbr3bwx2" {};
libutil = applePackage "libutil" "osx-10.12.6" "0lqdxaj82h8yjbjm856jjz9k2d96k0viimi881akfng08xk1246y" {};
libunwind = applePackage "libunwind" "osx-10.12.6" "0miffaa41cv0lzf8az5k1j1ng8jvqvxcr4qrlkf3xyj479arbk1b" {};
mDNSResponder = applePackage "mDNSResponder" "osx-10.12.6" "02ms1p8zlgmprzn65jzr7yaqxykh3zxjcrw0c06aayim6h0dsqfy" {};
objc4 = applePackage "objc4" "osx-10.12.6" "1cj1vhbcs9pkmag2ms8wslagicnq9bxi2qjkszmp3ys7z7ccrbwz" {};
ppp = applePackage "ppp" "osx-10.12.6" "1kcc2nc4x1kf8sz0a23i6nfpvxg381kipi0qdisrp8x9z2gbkxb8" {};
removefile = applePackage "removefile" "osx-10.12.6" "0jzjxbmxgjzhssqd50z7kq9dlwrv5fsdshh57c0f8mdwcs19bsyx" {};
xnu = applePackage "xnu" "osx-10.12.6" "1sjb0i7qzz840v2h4z3s4jyjisad4r5yyi6sg8pakv3wd81i5fg5" {
python3 = pkgs.buildPackages.buildPackages.python3; # TODO(@Ericson2314) this shouldn't be needed.
};
hfs = applePackage "hfs" "osx-10.12.6" "1mj3xvqpq1mgd80b6kl1s04knqnap7hccr0gz8rjphalq14rbl5g" {};
Librpcsvc = applePackage "Librpcsvc" "osx-10.11.6" "1zwfwcl9irxl1dlnf2b4v30vdybp0p0r6n6g1pd14zbdci1jcg2k" {};
adv_cmds = applePackage "adv_cmds" "osx-10.11.6" "12gbv35i09aij9g90p6b3x2f3ramw43qcb2gjrg8lzkzmwvcyw9q" {};
basic_cmds = applePackage "basic_cmds" "osx-10.11.6" "0hvab4b1v5q2x134hdkal0rmz5gsdqyki1vb0dbw4py1bqf0yaw9" {};
developer_cmds = applePackage "developer_cmds" "osx-10.11.6" "1r9c2b6dcl22diqf90x58psvz797d3lxh4r2wppr7lldgbgn24di" {};
diskdev_cmds = applePackage "diskdev_cmds" "osx-10.11.6" "1ssdyiaq5m1zfy96yy38yyknp682ki6bvabdqd5z18fa0rv3m2ar" {
macosPackages_11_0_1 = macosPackages_11_0_1;
};
network_cmds = applePackage "network_cmds" "osx-10.11.6" "0lhi9wz84qr1r2ab3fb4nvmdg9gxn817n5ldg7zw9gnf3wwn42kw" {};
file_cmds = applePackage "file_cmds" "osx-10.11.6" "1zfxbmasps529pnfdjvc13p7ws2cfx8pidkplypkswyff0nff4wp" {};
shell_cmds = applePackage "shell_cmds" "osx-10.11.6" "0084k271v66h4jqp7q7rmjvv7w4mvhx3aq860qs8jbd30canm86n" {};
system_cmds = applePackage "system_cmds" "osx-10.11.6" "1h46j2c5v02pkv5d9fyv6cpgyg0lczvwicrx6r9s210cl03l77jl" {};
text_cmds = applePackage "text_cmds" "osx-10.11.6" "1f93m7dd0ghqb2hwh905mjhzblyfr7dwffw98xhgmv1mfdnigxg0" {};
top = applePackage "top" "osx-10.11.6" "0i9120rfwapgwdvjbfg0ya143i29s1m8zbddsxh39pdc59xnsg5l" {};
PowerManagement = applePackage "PowerManagement" "osx-10.11.6" "1llimhvp0gjffd47322lnjq7cqwinx0c5z7ikli04ad5srpa68mh" {};
# `configdHeaders` cant use an override because `pkgs.darwin.configd` on aarch64-darwin will
# be replaced by SystemConfiguration.framework from the macOS SDK.
configdHeaders = applePackage "configd" "osx-10.8.5" "1gxakahk8gallf16xmhxhprdxkh3prrmzxnmxfvj0slr0939mmr2" {
headersOnly = true;
Security = null;
};
libutilHeaders = pkgs.darwin.libutil.override { headersOnly = true; };
hfsHeaders = pkgs.darwin.hfs.override { headersOnly = true; };
libresolvHeaders= pkgs.darwin.libresolv.override { headersOnly = true; };
# 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" "1nv0dczf67dhk17hscx52izgdcyacgyy12ag0jh6nl5hmfzsn8yy" {};
}

View file

@ -0,0 +1,8 @@
# Generated using: ./generate-sdk-packages.sh developer-tools 11.3.1
{ applePackage' }:
{
bootstrap_cmds = applePackage' "bootstrap_cmds" "116" "developer-tools-11.3.1" "148xpqkf5xzpslqxch5l8h6vsz7sys8sdzk4ghbg9mkcivp8qa03" {};
developer_cmds = applePackage' "developer_cmds" "66" "developer-tools-11.3.1" "0q08m4cxxwph7gxqravmx13l418p1i050bd46zwksn9j9zpw9mlr" {};
}

View file

@ -0,0 +1,37 @@
{ lib, appleDerivation, xcbuildHook, llvmPackages, makeWrapper }:
appleDerivation {
nativeBuildInputs = [ xcbuildHook makeWrapper ];
patches = [
# The following copied from
# https://github.com/Homebrew/homebrew-core/commit/712ed3e948868e17f96b7e59972b5f45d4faf688
# is needed to build libvirt.
./rpcgen-support-hyper-and-quad-types.patch
];
postPatch = ''
makeWrapper ${llvmPackages.clang}/bin/clang $out/bin/clang-cpp --add-flags "--driver-mode=cpp"
substituteInPlace rpcgen/rpc_main.c \
--replace "/usr/bin/cpp" "$out/bin/clang-cpp"
'';
# temporary install phase until xcodebuild has "install" support
installPhase = ''
for f in Products/Release/*; do
if [ -f $f ]; then
install -D $f $out/bin/$(basename $f)
fi
done
for n in 1; do
mkdir -p $out/share/man/man$n
install */*.$n $out/share/man/man$n
done
'';
meta = {
platforms = lib.platforms.darwin;
maintainers = with lib.maintainers; [ matthewbauer ];
};
}

View file

@ -0,0 +1,66 @@
diff --git a/rpcgen/rpc_parse.c b/rpcgen/rpc_parse.c
index 52edc9f..db0c1f1 100644
--- a/rpcgen/rpc_parse.c
+++ b/rpcgen/rpc_parse.c
@@ -580,6 +580,10 @@ get_type(prefixp, typep, dkind)
*typep = "long";
(void) peekscan(TOK_INT, &tok);
break;
+ case TOK_HYPER:
+ *typep = "int64_t";
+ (void) peekscan(TOK_INT, &tok);
+ break;
case TOK_VOID:
if (dkind != DEF_UNION && dkind != DEF_PROGRAM) {
error("voids allowed only inside union and program definitions with one argument");
@@ -592,6 +596,7 @@ get_type(prefixp, typep, dkind)
case TOK_INT:
case TOK_FLOAT:
case TOK_DOUBLE:
+ case TOK_QUAD:
case TOK_BOOL:
*typep = tok.str;
break;
@@ -622,6 +627,11 @@ unsigned_dec(typep)
*typep = "u_long";
(void) peekscan(TOK_INT, &tok);
break;
+ case TOK_HYPER:
+ get_token(&tok);
+ *typep = "u_int64_t";
+ (void) peekscan(TOK_INT, &tok);
+ break;
case TOK_INT:
get_token(&tok);
*typep = "u_int";
diff --git a/rpcgen/rpc_scan.c b/rpcgen/rpc_scan.c
index a8df441..4130107 100644
--- a/rpcgen/rpc_scan.c
+++ b/rpcgen/rpc_scan.c
@@ -419,8 +419,10 @@ static token symbols[] = {
{TOK_UNSIGNED, "unsigned"},
{TOK_SHORT, "short"},
{TOK_LONG, "long"},
+ {TOK_HYPER, "hyper"},
{TOK_FLOAT, "float"},
{TOK_DOUBLE, "double"},
+ {TOK_QUAD, "quadruple"},
{TOK_STRING, "string"},
{TOK_PROGRAM, "program"},
{TOK_VERSION, "version"},
diff --git a/rpcgen/rpc_scan.h b/rpcgen/rpc_scan.h
index bac2be4..e4c57c8 100644
--- a/rpcgen/rpc_scan.h
+++ b/rpcgen/rpc_scan.h
@@ -66,9 +66,11 @@ enum tok_kind {
TOK_INT,
TOK_SHORT,
TOK_LONG,
+ TOK_HYPER,
TOK_UNSIGNED,
TOK_FLOAT,
TOK_DOUBLE,
+ TOK_QUAD,
TOK_OPAQUE,
TOK_CHAR,
TOK_STRING,

View file

@ -0,0 +1,41 @@
{ lib, appleDerivation, xcbuildHook, Libc, stdenv, macosPackages_11_0_1, xnu
, fetchurl, libutil }:
let
xnu-src = if stdenv.isAarch64 then macosPackages_11_0_1.xnu.src else xnu.src;
arch = if stdenv.isAarch64 then "arm" else "i386";
in appleDerivation {
nativeBuildInputs = [ xcbuildHook ];
buildInputs = [ libutil ];
NIX_CFLAGS_COMPILE = "-I.";
NIX_LDFLAGS = "-lutil";
patchPhase = ''
# ugly hacks for missing headers
# most are bsd related - probably should make this a drv
unpackFile ${Libc.src}
unpackFile ${xnu-src}
mkdir System sys machine ${arch}
cp xnu-*/bsd/sys/disklabel.h sys
cp xnu-*/bsd/machine/disklabel.h machine
cp xnu-*/bsd/${arch}/disklabel.h ${arch}
cp -r xnu-*/bsd/sys System
cp -r Libc-*/uuid System
substituteInPlace diskdev_cmds.xcodeproj/project.pbxproj \
--replace 'DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";' ""
'';
installPhase = ''
install -D Products/Release/libdisk.a $out/lib/libdisk.a
rm Products/Release/libdisk.a
for f in Products/Release/*; do
if [ -f $f ]; then
install -D $f $out/bin/$(basename $f)
fi
done
'';
meta = {
platforms = lib.platforms.darwin;
maintainers = with lib.maintainers; [ matthewbauer ];
};
}

View file

@ -0,0 +1,55 @@
{ appleDerivation, xcbuildHook, CoreSymbolication
, xnu, bison, flex, darling, stdenv, fixDarwinDylibNames }:
appleDerivation {
nativeBuildInputs = [ xcbuildHook flex bison fixDarwinDylibNames ];
buildInputs = [ CoreSymbolication darling xnu ];
# -fcommon: workaround build failure on -fno-common toolchains:
# duplicate symbol '_kCSRegionMachHeaderName' in: libproc.o dt_module_apple.o
NIX_CFLAGS_COMPILE = "-DCTF_OLD_VERSIONS -DPRIVATE -DYYDEBUG=1 -I${xnu}/Library/Frameworks/System.framework/Headers -Wno-error=implicit-function-declaration -fcommon";
NIX_LDFLAGS = "-L./Products/Release";
xcbuildFlags = [ "-target" "dtrace_frameworks" "-target" "dtrace" ];
doCheck = false;
checkPhase = "xcodebuild -target dtrace_tests";
postPatch = ''
substituteInPlace dtrace.xcodeproj/project.pbxproj \
--replace "/usr/sbin" ""
substituteInPlace libdtrace/dt_open.c \
--replace /usr/bin/clang ${stdenv.cc.cc}/bin/clang \
--replace /usr/bin/ld ${stdenv.cc.bintools.bintools}/bin/ld \
--replace /usr/lib/dtrace/dt_cpp.h $out/include/dt_cpp.h \
--replace /usr/lib/dtrace $out/lib/dtrace
'';
# hack to handle xcbuild's broken lex handling
preBuild = ''
pushd libdtrace
yacc -d dt_grammar.y
flex -l -d dt_lex.l
popd
substituteInPlace dtrace.xcodeproj/project.pbxproj \
--replace '6EBC9800099BFBBF0001019C /* dt_grammar.y */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.yacc; name = dt_grammar.y; path = libdtrace/dt_grammar.y; sourceTree = "<group>"; };' '6EBC9800099BFBBF0001019C /* y.tab.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = y.tab.c; path = libdtrace/y.tab.c; sourceTree = "<group>"; };' \
--replace '6EBC9808099BFBBF0001019C /* dt_lex.l */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.lex; name = dt_lex.l; path = libdtrace/dt_lex.l; sourceTree = "<group>"; };' '6EBC9808099BFBBF0001019C /* lex.yy.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = lex.yy.c; path = libdtrace/lex.yy.c; sourceTree = "<group>"; };'
'';
# xcbuild doesn't support install
installPhase = ''
mkdir -p $out
cp -r Products/Release/usr/include $out/include
cp scripts/dt_cpp.h $out/include/dt_cpp.h
mkdir $out/lib
cp Products/Release/*.dylib $out/lib
mkdir $out/bin
cp Products/Release/dtrace $out/bin
mkdir -p $out/lib/dtrace
install_name_tool -change $PWD/Products/Release/libdtrace.dylib $out/lib/libdtrace.dylib $out/bin/dtrace
'';
}

View file

@ -0,0 +1,16 @@
{ lib, appleDerivation', stdenvNoCC }:
appleDerivation' stdenvNoCC {
installPhase = ''
mkdir -p $out/lib $out/include
ln -s /usr/lib/dyld $out/lib/dyld
cp -r include $out/
'';
meta = with lib; {
description = "Impure primitive symlinks to the Mac OS native dyld, along with headers";
maintainers = with maintainers; [ copumpkin ];
platforms = platforms.darwin;
license = licenses.apsl20;
};
}

View file

@ -0,0 +1,10 @@
{ appleDerivation', stdenv }:
appleDerivation' stdenv {
dontBuild = true;
installPhase = ''
mkdir -p $out/Library/Frameworks/EAP8021X.framework/Headers
cp EAP8021X.fproj/EAPClientProperties.h $out/Library/Frameworks/EAP8021X.framework/Headers
'';
}

View file

@ -0,0 +1,38 @@
{ lib, appleDerivation, xcbuildHook, zlib, bzip2, xz, ncurses, libutil, Libinfo }:
appleDerivation {
nativeBuildInputs = [ xcbuildHook ];
buildInputs = [ zlib bzip2 xz ncurses libutil Libinfo ];
# some commands not working:
# mtree: _simple.h not found
# ipcs: sys/ipcs.h not found
# so remove their targets from the project
patchPhase = ''
substituteInPlace file_cmds.xcodeproj/project.pbxproj \
--replace "FC8A8CAA14B655FD001B97AD /* PBXTargetDependency */," "" \
--replace "FC8A8C9C14B655FD001B97AD /* PBXTargetDependency */," "" \
--replace "productName = file_cmds;" "" \
--replace '/usr/lib/libcurses.dylib' 'libncurses.dylib'
sed -i -re "s/name = ([a-zA-Z]+);/name = \1; productName = \1;/" file_cmds.xcodeproj/project.pbxproj
'';
# temporary install phase until xcodebuild has "install" support
installPhase = ''
for f in Products/Release/*; do
if [ -f $f ]; then
install -D $f $out/bin/$(basename $f)
fi
done
for n in 1; do
mkdir -p $out/share/man/man$n
install */*.$n $out/share/man/man$n
done
'';
meta = {
platforms = lib.platforms.darwin;
maintainers = with lib.maintainers; [ matthewbauer ];
};
}

View file

@ -0,0 +1,29 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl
# usage:
# generate-sdk-packages.sh macos 11.0.1
cd $(dirname "$0")
sdkName="$1-$2"
outfile="$sdkName.nix"
>$outfile echo "# Generated using: ./$(basename "$0") $1 $2
{ applePackage' }:
{"
parse_line() {
readarray -t -d$'\t' package <<<$2
local pname=${package[0]} version=${package[1]}
if [ -d $pname ]; then
sha256=$(nix-prefetch-url "https://opensource.apple.com/tarballs/$pname/$pname-$version.tar.gz")
>>$outfile echo "$pname = applePackage' \"$pname\" \"$version\" \"$sdkName\" \"$sha256\" {};"
fi
}
readarray -s1 -c1 -C parse_line < <(curl -sS "https://opensource.apple.com/text/${sdkName//./}.txt")
>>$outfile echo '}'

View file

@ -0,0 +1,47 @@
{ appleDerivation', stdenv, stdenvNoCC, lib, headersOnly ? true }:
appleDerivation' (if headersOnly then stdenvNoCC else stdenv) {
installPhase = lib.optionalString headersOnly ''
mkdir -p $out/include/hfs
cp core/*.h $out/include/hfs
'';
appleHeaders = ''
hfs/BTreeScanner.h
hfs/BTreesInternal.h
hfs/BTreesPrivate.h
hfs/CatalogPrivate.h
hfs/FileMgrInternal.h
hfs/HFSUnicodeWrappers.h
hfs/UCStringCompareData.h
hfs/hfs.h
hfs/hfs_alloc_trace.h
hfs/hfs_attrlist.h
hfs/hfs_btreeio.h
hfs/hfs_catalog.h
hfs/hfs_cnode.h
hfs/hfs_cprotect.h
hfs/hfs_dbg.h
hfs/hfs_endian.h
hfs/hfs_extents.h
hfs/hfs_format.h
hfs/hfs_fsctl.h
hfs/hfs_hotfiles.h
hfs/hfs_iokit.h
hfs/hfs_journal.h
hfs/hfs_kdebug.h
hfs/hfs_key_roll.h
hfs/hfs_macos_defs.h
hfs/hfs_mount.h
hfs/hfs_quota.h
hfs/hfs_unistr.h
hfs/kext-config.h
hfs/rangelist.h
'';
meta = {
# Seems nobody wants its binary, so we didn't implement building.
broken = !headersOnly;
platforms = lib.platforms.darwin;
};
}

View file

@ -0,0 +1,26 @@
{ appleDerivation', stdenvNoCC }:
appleDerivation' stdenvNoCC {
# No clue why the same file has two different names. Ask Apple!
installPhase = ''
mkdir -p $out/include/ $out/include/servers
cp liblaunch/*.h $out/include
cp liblaunch/bootstrap.h $out/include/servers
cp liblaunch/bootstrap.h $out/include/servers/bootstrap_defs.h
'';
appleHeaders = ''
bootstrap.h
bootstrap_priv.h
launch.h
launch_internal.h
launch_priv.h
reboot2.h
servers/bootstrap.h
servers/bootstrap_defs.h
vproc.h
vproc_internal.h
vproc_priv.h
'';
}

View file

@ -0,0 +1,129 @@
/*
* Generated by dtrace(1M).
*/
#ifndef _AUTO_DTRACE_H
#define _AUTO_DTRACE_H
#include <unistd.h>
#ifdef __cplusplus
extern "C" {
#endif
#define GARBAGE_COLLECTION_STABILITY "___dtrace_stability$garbage_collection$v1$1_1_0_1_1_0_1_1_0_1_1_0_1_1_0"
#define GARBAGE_COLLECTION_TYPEDEFS "___dtrace_typedefs$garbage_collection$v2$6175746f5f636f6c6c656374696f6e5f70686173655f74$6175746f5f636f6c6c656374696f6e5f747970655f74$6d616c6c6f635f7a6f6e655f74"
#if !defined(DTRACE_PROBES_DISABLED) || !DTRACE_PROBES_DISABLED
#define GARBAGE_COLLECTION_AUTO_BLOCK_LOST_THREAD_LOCALITY(arg0, arg1) \
do { \
__asm__ volatile(".reference " GARBAGE_COLLECTION_TYPEDEFS); \
__dtrace_probe$garbage_collection$auto_block_lost_thread_locality$v1$766f6964202a$75696e7436345f74(arg0, arg1); \
__asm__ volatile(".reference " GARBAGE_COLLECTION_STABILITY); \
} while (0)
#define GARBAGE_COLLECTION_AUTO_BLOCK_LOST_THREAD_LOCALITY_ENABLED() \
({ int _r = __dtrace_isenabled$garbage_collection$auto_block_lost_thread_locality$v1(); \
__asm__ volatile(""); \
_r; })
#define GARBAGE_COLLECTION_AUTO_REFCOUNT_ONE_ALLOCATION(arg0) \
do { \
__asm__ volatile(".reference " GARBAGE_COLLECTION_TYPEDEFS); \
__dtrace_probe$garbage_collection$auto_refcount_one_allocation$v1$75696e7436345f74(arg0); \
__asm__ volatile(".reference " GARBAGE_COLLECTION_STABILITY); \
} while (0)
#define GARBAGE_COLLECTION_AUTO_REFCOUNT_ONE_ALLOCATION_ENABLED() \
({ int _r = __dtrace_isenabled$garbage_collection$auto_refcount_one_allocation$v1(); \
__asm__ volatile(""); \
_r; })
#define GARBAGE_COLLECTION_COLLECTION_BEGIN(arg0, arg1) \
do { \
__asm__ volatile(".reference " GARBAGE_COLLECTION_TYPEDEFS); \
__dtrace_probe$garbage_collection$collection_begin$v1$6d616c6c6f635f7a6f6e655f74202a$6175746f5f636f6c6c656374696f6e5f747970655f74(arg0, arg1); \
__asm__ volatile(".reference " GARBAGE_COLLECTION_STABILITY); \
} while (0)
#define GARBAGE_COLLECTION_COLLECTION_BEGIN_ENABLED() \
({ int _r = __dtrace_isenabled$garbage_collection$collection_begin$v1(); \
__asm__ volatile(""); \
_r; })
#define GARBAGE_COLLECTION_COLLECTION_END(arg0, arg1, arg2, arg3, arg4) \
do { \
__asm__ volatile(".reference " GARBAGE_COLLECTION_TYPEDEFS); \
__dtrace_probe$garbage_collection$collection_end$v1$6d616c6c6f635f7a6f6e655f74202a$75696e7436345f74$75696e7436345f74$75696e7436345f74$75696e7436345f74(arg0, arg1, arg2, arg3, arg4); \
__asm__ volatile(".reference " GARBAGE_COLLECTION_STABILITY); \
} while (0)
#define GARBAGE_COLLECTION_COLLECTION_END_ENABLED() \
({ int _r = __dtrace_isenabled$garbage_collection$collection_end$v1(); \
__asm__ volatile(""); \
_r; })
#define GARBAGE_COLLECTION_COLLECTION_PHASE_BEGIN(arg0, arg1) \
do { \
__asm__ volatile(".reference " GARBAGE_COLLECTION_TYPEDEFS); \
__dtrace_probe$garbage_collection$collection_phase_begin$v1$6d616c6c6f635f7a6f6e655f74202a$6175746f5f636f6c6c656374696f6e5f70686173655f74(arg0, arg1); \
__asm__ volatile(".reference " GARBAGE_COLLECTION_STABILITY); \
} while (0)
#define GARBAGE_COLLECTION_COLLECTION_PHASE_BEGIN_ENABLED() \
({ int _r = __dtrace_isenabled$garbage_collection$collection_phase_begin$v1(); \
__asm__ volatile(""); \
_r; })
#define GARBAGE_COLLECTION_COLLECTION_PHASE_END(arg0, arg1, arg2, arg3) \
do { \
__asm__ volatile(".reference " GARBAGE_COLLECTION_TYPEDEFS); \
__dtrace_probe$garbage_collection$collection_phase_end$v1$6d616c6c6f635f7a6f6e655f74202a$6175746f5f636f6c6c656374696f6e5f70686173655f74$75696e7436345f74$75696e7436345f74(arg0, arg1, arg2, arg3); \
__asm__ volatile(".reference " GARBAGE_COLLECTION_STABILITY); \
} while (0)
#define GARBAGE_COLLECTION_COLLECTION_PHASE_END_ENABLED() \
({ int _r = __dtrace_isenabled$garbage_collection$collection_phase_end$v1(); \
__asm__ volatile(""); \
_r; })
extern void __dtrace_probe$garbage_collection$auto_block_lost_thread_locality$v1$766f6964202a$75696e7436345f74(const void *, uint64_t);
extern int __dtrace_isenabled$garbage_collection$auto_block_lost_thread_locality$v1(void);
extern void __dtrace_probe$garbage_collection$auto_refcount_one_allocation$v1$75696e7436345f74(uint64_t);
extern int __dtrace_isenabled$garbage_collection$auto_refcount_one_allocation$v1(void);
extern void __dtrace_probe$garbage_collection$collection_begin$v1$6d616c6c6f635f7a6f6e655f74202a$6175746f5f636f6c6c656374696f6e5f747970655f74(const malloc_zone_t *, auto_collection_type_t);
extern int __dtrace_isenabled$garbage_collection$collection_begin$v1(void);
extern void __dtrace_probe$garbage_collection$collection_end$v1$6d616c6c6f635f7a6f6e655f74202a$75696e7436345f74$75696e7436345f74$75696e7436345f74$75696e7436345f74(const malloc_zone_t *, uint64_t, uint64_t, uint64_t, uint64_t);
extern int __dtrace_isenabled$garbage_collection$collection_end$v1(void);
extern void __dtrace_probe$garbage_collection$collection_phase_begin$v1$6d616c6c6f635f7a6f6e655f74202a$6175746f5f636f6c6c656374696f6e5f70686173655f74(const malloc_zone_t *, auto_collection_phase_t);
extern int __dtrace_isenabled$garbage_collection$collection_phase_begin$v1(void);
extern void __dtrace_probe$garbage_collection$collection_phase_end$v1$6d616c6c6f635f7a6f6e655f74202a$6175746f5f636f6c6c656374696f6e5f70686173655f74$75696e7436345f74$75696e7436345f74(const malloc_zone_t *, auto_collection_phase_t, uint64_t, uint64_t);
extern int __dtrace_isenabled$garbage_collection$collection_phase_end$v1(void);
#else
#define GARBAGE_COLLECTION_AUTO_BLOCK_LOST_THREAD_LOCALITY(arg0, arg1) \
do { \
} while (0)
#define GARBAGE_COLLECTION_AUTO_BLOCK_LOST_THREAD_LOCALITY_ENABLED() (0)
#define GARBAGE_COLLECTION_AUTO_REFCOUNT_ONE_ALLOCATION(arg0) \
do { \
} while (0)
#define GARBAGE_COLLECTION_AUTO_REFCOUNT_ONE_ALLOCATION_ENABLED() (0)
#define GARBAGE_COLLECTION_COLLECTION_BEGIN(arg0, arg1) \
do { \
} while (0)
#define GARBAGE_COLLECTION_COLLECTION_BEGIN_ENABLED() (0)
#define GARBAGE_COLLECTION_COLLECTION_END(arg0, arg1, arg2, arg3, arg4) \
do { \
} while (0)
#define GARBAGE_COLLECTION_COLLECTION_END_ENABLED() (0)
#define GARBAGE_COLLECTION_COLLECTION_PHASE_BEGIN(arg0, arg1) \
do { \
} while (0)
#define GARBAGE_COLLECTION_COLLECTION_PHASE_BEGIN_ENABLED() (0)
#define GARBAGE_COLLECTION_COLLECTION_PHASE_END(arg0, arg1, arg2, arg3) \
do { \
} while (0)
#define GARBAGE_COLLECTION_COLLECTION_PHASE_END_ENABLED() (0)
#endif /* !defined(DTRACE_PROBES_DISABLED) || !DTRACE_PROBES_DISABLED */
#ifdef __cplusplus
}
#endif
#endif /* _AUTO_DTRACE_H */

View file

@ -0,0 +1,86 @@
{ lib, stdenv, appleDerivation, libdispatch, Libsystem }:
appleDerivation {
# these are included in the pure libc
buildInputs = lib.optionals stdenv.cc.nativeLibc [ libdispatch Libsystem ];
buildPhase = ''
cp ${./auto_dtrace.h} ./auto_dtrace.h
substituteInPlace ThreadLocalCollector.h --replace SubZone.h Subzone.h
substituteInPlace auto_zone.cpp \
--replace "#include <msgtracer_client.h>" ''$'#include <asl.h>\nstatic void msgtracer_log_with_keys(...) { };'
substituteInPlace Definitions.h \
--replace "#include <System/pthread_machdep.h>" "" \
--replace 'void * const, void * const' 'void * const, void *'
# getspecific_direct is more efficient, but this should be equivalent...
substituteInPlace Zone.h \
--replace "_pthread_getspecific_direct" "pthread_getspecific" \
--replace "_pthread_has_direct_tsd()" "0" \
--replace "__PTK_FRAMEWORK_GC_KEY0" "110" \
--replace "__PTK_FRAMEWORK_GC_KEY1" "111" \
--replace "__PTK_FRAMEWORK_GC_KEY2" "112" \
--replace "__PTK_FRAMEWORK_GC_KEY3" "113" \
--replace "__PTK_FRAMEWORK_GC_KEY4" "114" \
--replace "__PTK_FRAMEWORK_GC_KEY5" "115" \
--replace "__PTK_FRAMEWORK_GC_KEY6" "116" \
--replace "__PTK_FRAMEWORK_GC_KEY7" "117" \
--replace "__PTK_FRAMEWORK_GC_KEY8" "118" \
--replace "__PTK_FRAMEWORK_GC_KEY9" "119"
substituteInPlace auto_zone.cpp \
--replace "__PTK_FRAMEWORK_GC_KEY9" "119" \
--replace "__PTK_FRAMEWORK_GC_KEY0" "110" \
substituteInPlace Zone.cpp \
--replace "_pthread_getspecific_direct" "pthread_getspecific" \
--replace "__PTK_FRAMEWORK_GC_KEY9" "119" \
--replace "__PTK_FRAMEWORK_GC_KEY0" "110" \
--replace "__PTK_LIBDISPATCH_KEY0" "20" \
--replace "struct auto_zone_cursor {" ''$'extern "C" int pthread_key_init_np(int, void (*)(void *));\nstruct auto_zone_cursor {'
substituteInPlace auto_impl_utilities.c \
--replace "# include <CrashReporterClient.h>" "void CRSetCrashLogMessage(void *msg) { };"
c++ -I. -O3 -c -Wno-c++11-extensions auto_zone.cpp
cc -I. -O3 -Iauto_tester -c auto_impl_utilities.c
c++ -I. -O3 -c auto_weak.cpp
c++ -I. -O3 -c Admin.cpp
c++ -I. -O3 -c Bitmap.cpp
c++ -I. -O3 -c Definitions.cpp
c++ -I. -O3 -c Environment.cpp
c++ -I. -O3 -c Large.cpp
c++ -I. -O3 -c Region.cpp
c++ -I. -O3 -c Subzone.cpp
c++ -I. -O3 -c WriteBarrier.cpp
c++ -I. -O3 -c Zone.cpp
c++ -I. -O3 -c Thread.cpp
c++ -I. -O3 -c InUseEnumerator.cpp
c++ -I. -O3 -c auto_gdb_interface.cpp
c++ -I. -O3 -c PointerHash.cpp
c++ -I. -O3 -c ThreadLocalCollector.cpp
c++ -I. -O3 -c ZoneDump.cpp
c++ -I. -O3 -c ZoneCollectors.cpp
c++ -I. -O3 -c SubzonePartition.cpp
c++ -I. -O3 -c ZoneCollectionChecking.cpp
c++ -I. -O3 -c ZoneCompaction.cpp
c++ -I. -O3 -c BlockRef.cpp
c++ -Wl,-no_dtrace_dof --stdlib=libc++ -dynamiclib -install_name $out/lib/libauto.dylib -o libauto.dylib *.o
'';
installPhase = ''
mkdir -p $out/lib $out/include
cp auto_zone.h auto_weak.h auto_tester/auto_tester.h auto_gdb_interface.h $out/include
cp libauto.dylib $out/lib
'';
meta = {
# libauto is only used by objc4/pure.nix , but objc4 is now using the impure approach, so we don't bother to fix this.
broken = true;
platforms = lib.platforms.darwin;
};
}

View file

@ -0,0 +1,13 @@
{ appleDerivation', stdenvNoCC }:
appleDerivation' stdenvNoCC {
installPhase = ''
mkdir -p $out/include
cp *.h $out/include/
'';
appleHeaders = ''
Block.h
Block_private.h
'';
}

View file

@ -0,0 +1,54 @@
{ appleDerivation', stdenvNoCC }:
appleDerivation' stdenvNoCC {
dontConfigure = true;
dontBuild = true;
installPhase = ''
mkdir -p $out/include/dispatch $out/include/os
# Move these headers so CF can find <os/voucher_private.h>
mv private/voucher*.h $out/include/os
cp -r private/*.h $out/include/dispatch
cp -r dispatch/*.h $out/include/dispatch
cp -r os/object*.h $out/include/os
# gcc compatability. Source: https://stackoverflow.com/a/28014302/3714556
substituteInPlace $out/include/dispatch/object.h \
--replace 'typedef void (^dispatch_block_t)(void);' \
'#ifdef __clang__
typedef void (^dispatch_block_t)(void);
#else
typedef void* dispatch_block_t;
#endif'
'';
appleHeaders = ''
dispatch/base.h
dispatch/benchmark.h
dispatch/block.h
dispatch/data.h
dispatch/data_private.h
dispatch/dispatch.h
dispatch/group.h
dispatch/introspection.h
dispatch/introspection_private.h
dispatch/io.h
dispatch/io_private.h
dispatch/layout_private.h
dispatch/mach_private.h
dispatch/object.h
dispatch/once.h
dispatch/private.h
dispatch/queue.h
dispatch/queue_private.h
dispatch/semaphore.h
dispatch/source.h
dispatch/source_private.h
dispatch/time.h
os/object.h
os/object_private.h
os/voucher_activity_private.h
os/voucher_private.h
'';
}

View file

@ -0,0 +1,37 @@
{ stdenv, appleDerivation, lib
, enableStatic ? stdenv.hostPlatform.isStatic
, enableShared ? !stdenv.hostPlatform.isStatic
}:
appleDerivation {
postUnpack = "sourceRoot=$sourceRoot/libiconv";
preConfigure = lib.optionalString stdenv.hostPlatform.isiOS ''
sed -i 's/darwin\*/ios\*/g' configure libcharset/configure
'';
configureFlags = [
(lib.enableFeature enableStatic "static")
(lib.enableFeature enableShared "shared")
];
postInstall = lib.optionalString enableShared ''
mv $out/lib/libiconv.dylib $out/lib/libiconv-nocharset.dylib
${stdenv.cc.bintools.targetPrefix}install_name_tool -id $out/lib/libiconv-nocharset.dylib $out/lib/libiconv-nocharset.dylib
# re-export one useless symbol; ld will reject a dylib that only reexports other dylibs
echo 'void dont_use_this(){}' | ${stdenv.cc.bintools.targetPrefix}clang -dynamiclib -x c - -current_version 2.4.0 \
-compatibility_version 7.0.0 -current_version 7.0.0 -o $out/lib/libiconv.dylib \
-Wl,-reexport_library -Wl,$out/lib/libiconv-nocharset.dylib \
-Wl,-reexport_library -Wl,$out/lib/libcharset.dylib
'';
setupHooks = [
../../../../build-support/setup-hooks/role.bash
../../../../development/libraries/libiconv/setup-hook.sh
];
meta = {
platforms = lib.platforms.darwin;
};
}

View file

@ -0,0 +1,32 @@
{ appleDerivation', stdenvNoCC }:
appleDerivation' stdenvNoCC {
installPhase = ''
mkdir $out
cp -r include $out/include
'';
appleHeaders = ''
_simple.h
libkern/OSAtomic.h
libkern/OSAtomicDeprecated.h
libkern/OSAtomicQueue.h
libkern/OSCacheControl.h
libkern/OSSpinLockDeprecated.h
os/alloc_once_impl.h
os/base.h
os/base_private.h
os/internal/atomic.h
os/internal/crashlog.h
os/internal/internal_shared.h
os/lock.h
os/lock_private.h
os/once_private.h
os/semaphore_private.h
platform/compat.h
platform/introspection_private.h
platform/string.h
setjmp.h
ucontext.h
'';
}

View file

@ -0,0 +1,55 @@
{ lib, appleDerivation', stdenvNoCC, libdispatch, xnu }:
appleDerivation' stdenvNoCC {
propagatedBuildInputs = [ libdispatch xnu ];
installPhase = ''
mkdir -p $out/include/pthread/
mkdir -p $out/include/sys/_types
cp pthread/*.h $out/include/pthread/
# This overwrites qos.h, and is probably not necessary, but I'll leave it here for now
# cp private/*.h $out/include/pthread/
cp -r sys $out/include
cp -r sys/_pthread/*.h $out/include/sys/_types/
'';
appleHeaders = ''
pthread/introspection.h
pthread/pthread.h
pthread/pthread_impl.h
pthread/pthread_spis.h
pthread/qos.h
pthread/sched.h
pthread/spawn.h
sys/_pthread/_pthread_attr_t.h
sys/_pthread/_pthread_cond_t.h
sys/_pthread/_pthread_condattr_t.h
sys/_pthread/_pthread_key_t.h
sys/_pthread/_pthread_mutex_t.h
sys/_pthread/_pthread_mutexattr_t.h
sys/_pthread/_pthread_once_t.h
sys/_pthread/_pthread_rwlock_t.h
sys/_pthread/_pthread_rwlockattr_t.h
sys/_pthread/_pthread_t.h
sys/_pthread/_pthread_types.h
sys/_types/_pthread_attr_t.h
sys/_types/_pthread_cond_t.h
sys/_types/_pthread_condattr_t.h
sys/_types/_pthread_key_t.h
sys/_types/_pthread_mutex_t.h
sys/_types/_pthread_mutexattr_t.h
sys/_types/_pthread_once_t.h
sys/_types/_pthread_rwlock_t.h
sys/_types/_pthread_rwlockattr_t.h
sys/_types/_pthread_t.h
sys/_types/_pthread_types.h
sys/qos.h
sys/qos_private.h
'';
meta = {
platforms = lib.platforms.darwin;
};
}

View file

@ -0,0 +1,52 @@
{ lib, appleDerivation', stdenv, stdenvNoCC, Libinfo, configdHeaders, mDNSResponder
, headersOnly ? false
}:
appleDerivation' (if headersOnly then stdenvNoCC else stdenv) {
buildInputs = lib.optionals (!headersOnly) [ Libinfo configdHeaders mDNSResponder ];
buildPhase = lib.optionalString (!headersOnly) ''
$CC -I. -c dns_util.c
$CC -I. -c dns.c
$CC -I. -c dns_async.c
$CC -I. -c base64.c
$CC -I. -c dst_api.c
$CC -I. -c dst_hmac_link.c
$CC -I. -c dst_support.c
$CC -I. -c ns_date.c
$CC -I. -c ns_name.c
$CC -I. -c ns_netint.c
$CC -I. -c ns_parse.c
$CC -I. -c ns_print.c
$CC -I. -c ns_samedomain.c
$CC -I. -c ns_sign.c
$CC -I. -c ns_ttl.c
$CC -I. -c ns_verify.c
$CC -I. -c res_comp.c
$CC -I. -c res_data.c
$CC -I. -c res_debug.c
$CC -I. -c res_findzonecut.c
$CC -I. -c res_init.c
$CC -I. -c res_mkquery.c
$CC -I. -c res_mkupdate.c
$CC -I. -c res_query.c
$CC -I. -c res_send.c
$CC -I. -c res_sendsigned.c
$CC -I. -c res_update.c
$CC -dynamiclib -install_name $out/lib/libresolv.9.dylib -current_version 1.0.0 -compatibility_version 1.0.0 -o libresolv.9.dylib *.o
'';
installPhase = ''
mkdir -p $out/include $out/include/arpa $out/lib
cp dns.h $out/include/
cp dns_util.h $out/include
cp nameser.h $out/include
ln -s ../nameser.h $out/include/arpa
cp resolv.h $out/include
'' + lib.optionalString (!headersOnly) ''
cp libresolv.9.dylib $out/lib
ln -s libresolv.9.dylib $out/lib/libresolv.dylib
'';
}

View file

@ -0,0 +1,17 @@
{ lib, appleDerivation }:
appleDerivation {
dontBuild = true;
# install headers only
installPhase = ''
mkdir -p $out/lib
cp -R include $out/include
'';
meta = with lib; {
maintainers = with maintainers; [ copumpkin lnl7 ];
platforms = platforms.darwin;
license = licenses.apsl20;
};
}

View file

@ -0,0 +1,43 @@
{ lib, stdenv, stdenvNoCC, appleDerivation', xcbuildHook
# headersOnly is true when building for libSystem
, headersOnly ? false }:
appleDerivation' (if headersOnly then stdenvNoCC else stdenv) {
nativeBuildInputs = lib.optional (!headersOnly) xcbuildHook;
prePatch = ''
substituteInPlace tzlink.c \
--replace '#include <xpc/xpc.h>' ""
'';
xcbuildFlags = [ "-target" "util" ];
installPhase = ''
mkdir -p $out/include
'' + lib.optionalString headersOnly ''
cp *.h $out/include
'' + lib.optionalString (!headersOnly)''
mkdir -p $out/lib $out/include
cp Products/Release/*.dylib $out/lib
cp Products/Release/*.h $out/include
# TODO: figure out how to get this to be right the first time around
install_name_tool -id $out/lib/libutil.dylib $out/lib/libutil.dylib
'';
# FIXME: headers are different against headersOnly. And all the headers are NOT in macos, do we really want them?
# appleHeaders = ''
# libutil.h
# mntopts.h
# tzlink.h
# wipefs.h
# '';
meta = with lib; {
maintainers = with maintainers; [ copumpkin ];
platforms = platforms.darwin;
license = licenses.apsl20;
};
}

View file

@ -0,0 +1,10 @@
{ appleDerivation', stdenvNoCC }:
appleDerivation' stdenvNoCC {
phases = [ "unpackPhase" "installPhase" ];
installPhase = ''
mkdir -p $out/include
cp mDNSShared/dns_sd.h $out/include
'';
}

View file

@ -0,0 +1,46 @@
# Generated using: ./generate-sdk-packages.sh macos 11.0.1
{ applePackage' }:
{
adv_cmds = applePackage' "adv_cmds" "176" "macos-11.0.1" "0x8c25rh6fnzndbc26vcb65vcxilvqyfvm2klfyci1wr4bh3ixgk" {};
architecture = applePackage' "architecture" "279" "macos-11.0.1" "1cgp33ywa30max6cyp69kvii299hx2vgwvmy3ms8n4gaq2mkpaky" {};
basic_cmds = applePackage' "basic_cmds" "55" "macos-11.0.1" "0hvab4b1v5q2x134hdkal0rmz5gsdqyki1vb0dbw4py1bqf0yaw9" {};
bootstrap_cmds = applePackage' "bootstrap_cmds" "121" "macos-11.0.1" "09bwclws6adxb1ky9q35f4ikddk4mbalmgds0cmqaf7j23qxl3fv" {};
CommonCrypto = applePackage' "CommonCrypto" "60178.40.2" "macos-11.0.1" "0r3b1mlfmbdzpwn6pbsbfaga3k63gpwcwbhkbi4r09aq82skl02v" {};
configd = applePackage' "configd" "1109.40.9" "macos-11.0.1" "173i55wfzli9pg2x2rw437hs68h6l4ngss5jfgf18g26zjkjzv5v" {};
copyfile = applePackage' "copyfile" "173.40.2" "macos-11.0.1" "0qyp15qj3fdb7yx033n57l7s61d70mv17f43yiwcbhx09mmlrp07" {};
Csu = applePackage' "Csu" "88" "macos-11.0.1" "029lgcyj0i16036h2lcx6fd6r1yf1bkj5dnvz905rh6ncl8skgdr" {};
diskdev_cmds = applePackage' "diskdev_cmds" "667.40.1" "macos-11.0.1" "1bqwkwkwd556rba5000ap77xrhaf4xnmy83mszd7a0yvl2xlma7j" {};
dtrace = applePackage' "dtrace" "370.40.1" "macos-11.0.1" "1941yczmn94ng5zlnhf0i5mjw2f4g7znisgvhkhn5f86gxmd98wl" {};
dyld = applePackage' "dyld" "832.7.1" "macos-11.0.1" "1s77ca6jg20z91qlph59da8j61m97y23vrw48xs4rywdzh4915n0" {};
eap8021x = applePackage' "eap8021x" "304.40.1" "macos-11.0.1" "1ph3kcpf527s0jqsi60j2sgg3m8h128spf292d8kyc08siz9mf9c" {};
file_cmds = applePackage' "file_cmds" "321.40.3" "macos-11.0.1" "04789vn1wghclfr3ma3ncg716xdsxfj66hrcxi5h3h1ryag2ycfz" {};
hfs = applePackage' "hfs" "556.41.1" "macos-11.0.1" "1rhkmn2yj5p4wmi4aajy5hj2h0gxk63s8j4qz4ziy4g4bjpdgwmy" {};
ICU = applePackage' "ICU" "66108" "macos-11.0.1" "1d76cyyqpwkzjlxfajm4nsglxmfrcafbnjwnjxc3j5w3nw67pqhx" {};
Libc = applePackage' "Libc" "1439.40.11" "macos-11.0.1" "0d5xlnks4lc9391wg31c9126vflb40lc5ffkgxmf2kpyglac1280" {};
libclosure = applePackage' "libclosure" "78" "macos-11.0.1" "089i2bl4agpnfplrg23xbzma1674g0w05988nxdps6ghxl4kz66f" {};
libdispatch = applePackage' "libdispatch" "1271.40.12" "macos-11.0.1" "0z7r42zfb8y48f0nrw0qw7fanfvimycimgnrg3jig101kjvjar98" {};
libiconv = applePackage' "libiconv" "59" "macos-11.0.1" "0hqbsqggjrr0sv6h70lcr3gabgk9inyc8aq1b30wibgjm6crjwpp" {};
Libinfo = applePackage' "Libinfo" "542.40.3" "macos-11.0.1" "0y5x6wxd3mwn6my1jdp8qrak3y7x7sgjdmwyw9cvvbn3kg9v6z1p" {};
Libnotify = applePackage' "Libnotify" "279.40.4" "macos-11.0.1" "0aswflxki877izp6sacv35sydn6a3639cflv3zhs3i7vkfbsvbf5" {};
libplatform = applePackage' "libplatform" "254.40.4" "macos-11.0.1" "1mhi8n66864y98dr3n0pkqad3aqim800kn9bxzp6h5jf2jni3aql" {};
libpthread = applePackage' "libpthread" "454.40.3" "macos-11.0.1" "18rb4dqjdf3krzi4hdj5i310gy49ipf01klbkp9g51i02a55gphq" {};
libresolv = applePackage' "libresolv" "68" "macos-11.0.1" "1ysvg6d28xyaky9sn7giglnsflhjsbj17h3h3i6knlzxnzznpkql" {};
Librpcsvc = applePackage' "Librpcsvc" "26" "macos-11.0.1" "1zwfwcl9irxl1dlnf2b4v30vdybp0p0r6n6g1pd14zbdci1jcg2k" {};
Libsystem = applePackage' "Libsystem" "1292.50.1" "macos-11.0.1" "0w16zaigq18jfsnw15pfyz2mkfqdkn0cc16q617kmgw2khld8j7j" {};
libunwind = applePackage' "libunwind" "200.10" "macos-11.0.1" "1pmymcqpfk7lfxh6zqch429vfpvmd2m1dlg898170pkx5zhxisl2" {};
libutil = applePackage' "libutil" "58.40.2" "macos-11.0.1" "1hhgashfj9g4vjv02070c5pn818a5n0bh5l81l2pflmvb2rrqs3f" {};
mDNSResponder = applePackage' "mDNSResponder" "1310.40.42" "macos-11.0.1" "0d0b9wwah9rg7rwrr29dxd6iy0y4rlmss3wcz2wcqmnd2qb9x8my" {};
network_cmds = applePackage' "network_cmds" "606.40.2" "macos-11.0.1" "1dlslk67npvmxx5m50385kmn3ysxih2iv220hhzkin11f8abdjv7" {};
objc4 = applePackage' "objc4" "818.2" "macos-11.0.1" "177gmh9m9ajy6mvcd2sf7gqydgljy44n3iih0yqsn1b13j784azx" {};
PowerManagement = applePackage' "PowerManagement" "1132.50.3" "macos-11.0.1" "1n5yn6sc8w67g8iism6ilkyl33j46gcnlqcaq6k16zkngx6lprba" {};
ppp = applePackage' "ppp" "877.40.2" "macos-11.0.1" "1z506z8ndvb1lfr4pypfy2bnig6qimhmq3yhjvqwfnliv91965iq" {};
removefile = applePackage' "removefile" "49.40.3" "macos-11.0.1" "1fhp47awi15f02385r25qgw1ag5z0kr1v3kvgqm3r8i8yysfqvwp" {};
Security = applePackage' "Security" "59754.41.1" "macos-11.0.1" "00kqgg7k80ba70ar2c02f0q9yrdgqcb56nb9z5g0bxwkvi40ryph" {};
shell_cmds = applePackage' "shell_cmds" "216.40.4" "macos-11.0.1" "1mvp1fp34kkm4mi85fdn3i0l0gig4c0w09zg2mvkpxcf68cq2f69" {};
system_cmds = applePackage' "system_cmds" "880.40.5" "macos-11.0.1" "1kys4vwfz4559sspdsfhmxc238nd8qgylqypza3zdzaqhfh7lx2x" {};
text_cmds = applePackage' "text_cmds" "106" "macos-11.0.1" "0cpnfpllwpx20hbxzg5i5488gcjyi9adnbac1sd5hpv3bq6z1hs5" {};
top = applePackage' "top" "129" "macos-11.0.1" "1nyz5mvq7js3zhsi3dwxl5fslg6m7nhlgc6p2hr889xgyl5prw8f" {};
xnu = applePackage' "xnu" "7195.50.7.100.1" "macos-11.0.1" "14wqkqp3lcxgpm1sjnsysybrc4ppzkghwv3mb5nr5v8ml37prkib" {};
}

View file

@ -0,0 +1,50 @@
{ lib, appleDerivation, xcbuildHook
, libressl, Librpcsvc, xnu, libpcap, developer_cmds }:
appleDerivation {
nativeBuildInputs = [ xcbuildHook ];
buildInputs = [ libressl xnu Librpcsvc libpcap developer_cmds ];
NIX_CFLAGS_COMPILE = " -I./unbound -I${xnu}/Library/Frameworks/System.framework/Headers/";
# "spray" requires some files that aren't compiling correctly in xcbuild.
# "rtadvd" seems to fail with some missing constants.
# "traceroute6" and "ping6" require ipsec which doesn't build correctly
patchPhase = ''
substituteInPlace network_cmds.xcodeproj/project.pbxproj \
--replace "7294F0EA0EE8BAC80052EC88 /* PBXTargetDependency */," "" \
--replace "7216D34D0EE89FEC00AE70E4 /* PBXTargetDependency */," "" \
--replace "72CD1D9C0EE8C47C005F825D /* PBXTargetDependency */," "" \
--replace "7216D2C20EE89ADF00AE70E4 /* PBXTargetDependency */," ""
'';
# temporary install phase until xcodebuild has "install" support
installPhase = ''
for f in Products/Release/*; do
if [ -f $f ]; then
install -D $f $out/bin/$(basename $f)
fi
done
for n in 1 5; do
mkdir -p $out/share/man/man$n
install */*.$n $out/share/man/man$n
done
# TODO: patch files to load from $out/ instead of /usr/
# mkdir -p $out/etc/
# install rtadvd.tproj/rtadvd.conf ip6addrctl.tproj/ip6addrctl.conf $out/etc/
# mkdir -p $out/local/OpenSourceVersions/
# install network_cmds.plist $out/local/OpenSourceVersions/
# mkdir -p $out/System/Library/LaunchDaemons
# install kdumpd.tproj/com.apple.kdumpd.plist $out/System/Library/LaunchDaemons
'';
meta = {
platforms = lib.platforms.darwin;
maintainers = with lib.maintainers; [ matthewbauer ];
};
}

View file

@ -0,0 +1,37 @@
{ appleDerivation, darwin-stubs }:
appleDerivation {
phases = [ "unpackPhase" "installPhase" ];
# Not strictly necessary, since libSystem depends on it, but it's nice to be explicit so we
# can easily find out what's impure.
__propagatedImpureHostDeps = [
"/usr/lib/libauto.dylib"
"/usr/lib/libc++abi.dylib"
"/usr/lib/libc++.1.dylib"
"/usr/lib/libSystem.B.dylib"
];
installPhase = ''
mkdir -p $out/include/objc $out/lib
cp ${darwin-stubs}/usr/lib/libobjc.A.tbd $out/lib/libobjc.A.tbd
ln -s libobjc.A.tbd $out/lib/libobjc.tbd
cp runtime/OldClasses.subproj/List.h $out/include/objc/List.h
cp runtime/NSObjCRuntime.h $out/include/objc/NSObjCRuntime.h
cp runtime/NSObject.h $out/include/objc/NSObject.h
cp runtime/Object.h $out/include/objc/Object.h
cp runtime/Protocol.h $out/include/objc/Protocol.h
cp runtime/hashtable.h $out/include/objc/hashtable.h
cp runtime/hashtable2.h $out/include/objc/hashtable2.h
cp runtime/message.h $out/include/objc/message.h
cp runtime/objc-api.h $out/include/objc/objc-api.h
cp runtime/objc-auto.h $out/include/objc/objc-auto.h
cp runtime/objc-class.h $out/include/objc/objc-class.h
cp runtime/objc-exception.h $out/include/objc/objc-exception.h
cp runtime/objc-load.h $out/include/objc/objc-load.h
cp runtime/objc-runtime.h $out/include/objc/objc-runtime.h
cp runtime/objc-sync.h $out/include/objc/objc-sync.h
cp runtime/objc.h $out/include/objc/objc.h
cp runtime/runtime.h $out/include/objc/runtime.h
'';
}

View file

@ -0,0 +1,65 @@
/*
* Generated by dtrace(1M).
*/
#ifndef _OBJC_PROBES_H
#define _OBJC_PROBES_H
#include <unistd.h>
#ifdef __cplusplus
extern "C" {
#endif
#define OBJC_RUNTIME_STABILITY "___dtrace_stability$objc_runtime$v1$1_1_0_1_1_0_1_1_0_1_1_0_1_1_0"
#define OBJC_RUNTIME_TYPEDEFS "___dtrace_typedefs$objc_runtime$v2"
#if !defined(DTRACE_PROBES_DISABLED) || !DTRACE_PROBES_DISABLED
#define OBJC_RUNTIME_OBJC_EXCEPTION_RETHROW() \
do { \
__asm__ volatile(".reference " OBJC_RUNTIME_TYPEDEFS); \
__dtrace_probe$objc_runtime$objc_exception_rethrow$v1(); \
__asm__ volatile(".reference " OBJC_RUNTIME_STABILITY); \
} while (0)
#define OBJC_RUNTIME_OBJC_EXCEPTION_RETHROW_ENABLED() \
({ int _r = __dtrace_isenabled$objc_runtime$objc_exception_rethrow$v1(); \
__asm__ volatile(""); \
_r; })
#define OBJC_RUNTIME_OBJC_EXCEPTION_THROW(arg0) \
do { \
__asm__ volatile(".reference " OBJC_RUNTIME_TYPEDEFS); \
__dtrace_probe$objc_runtime$objc_exception_throw$v1$766f6964202a(arg0); \
__asm__ volatile(".reference " OBJC_RUNTIME_STABILITY); \
} while (0)
#define OBJC_RUNTIME_OBJC_EXCEPTION_THROW_ENABLED() \
({ int _r = __dtrace_isenabled$objc_runtime$objc_exception_throw$v1(); \
__asm__ volatile(""); \
_r; })
extern void __dtrace_probe$objc_runtime$objc_exception_rethrow$v1(void);
extern int __dtrace_isenabled$objc_runtime$objc_exception_rethrow$v1(void);
extern void __dtrace_probe$objc_runtime$objc_exception_throw$v1$766f6964202a(const void *);
extern int __dtrace_isenabled$objc_runtime$objc_exception_throw$v1(void);
#else
#define OBJC_RUNTIME_OBJC_EXCEPTION_RETHROW() \
do { \
} while (0)
#define OBJC_RUNTIME_OBJC_EXCEPTION_RETHROW_ENABLED() (0)
#define OBJC_RUNTIME_OBJC_EXCEPTION_THROW(arg0) \
do { \
} while (0)
#define OBJC_RUNTIME_OBJC_EXCEPTION_THROW_ENABLED() (0)
#endif /* !defined(DTRACE_PROBES_DISABLED) || !DTRACE_PROBES_DISABLED */
#ifdef __cplusplus
}
#endif
#endif /* _OBJC_PROBES_H */

View file

@ -0,0 +1,118 @@
{ stdenv, fetchapplesource, libauto, launchd, libc_old, libunwind }:
stdenv.mkDerivation rec {
version = "551.1";
pname = "objc4";
src = fetchapplesource {
inherit version;
name = "objc4";
sha256 = "1jrdb6yyb5jwwj27c1r0nr2y2ihqjln8ynj61mpkvp144c1cm5bg";
};
patches = [ ./spinlocks.patch ];
buildInputs = [ libauto launchd libc_old libunwind ];
buildPhase = ''
cp ${./objc-probes.h} runtime/objc-probes.h
mkdir -p build/include/objc
cp runtime/hashtable.h build/include/objc/hashtable.h
cp runtime/OldClasses.subproj/List.h build/include/objc/List.h
cp runtime/hashtable2.h build/include/objc/hashtable2.h
cp runtime/message.h build/include/objc/message.h
cp runtime/objc-api.h build/include/objc/objc-api.h
cp runtime/objc-auto.h build/include/objc/objc-auto.h
cp runtime/objc-class.h build/include/objc/objc-class.h
cp runtime/objc-exception.h build/include/objc/objc-exception.h
cp runtime/objc-load.h build/include/objc/objc-load.h
cp runtime/objc-sync.h build/include/objc/objc-sync.h
cp runtime/objc.h build/include/objc/objc.h
cp runtime/objc-runtime.h build/include/objc/objc-runtime.h
cp runtime/Object.h build/include/objc/Object.h
cp runtime/Protocol.h build/include/objc/Protocol.h
cp runtime/runtime.h build/include/objc/runtime.h
cp runtime/NSObject.h build/include/objc/NSObject.h
cp runtime/NSObjCRuntime.h build/include/objc/NSObjCRuntime.h
# These would normally be in local/include but we don't do local, so they're
# going in with the others
cp runtime/maptable.h build/include/objc/maptable.h
cp runtime/objc-abi.h build/include/objc/objc-abi.h
cp runtime/objc-auto-dump.h build/include/objc/objc-auto-dump.h
cp runtime/objc-gdb.h build/include/objc/objc-gdb.h
cp runtime/objc-internal.h build/include/objc/objc-internal.h
cc -o markgc markgc.c
FLAGS="-Wno-deprecated-register -Wno-unknown-pragmas -Wno-deprecated-objc-isa-usage -Wno-invalid-offsetof -Wno-inline-new-delete -Wno-cast-of-sel-type -Iruntime -Ibuild/include -Iruntime/Accessors.subproj -D_LIBCPP_VISIBLE= -DOS_OBJECT_USE_OBJC=0 -DNDEBUG=1"
cc -std=gnu++11 $FLAGS -c runtime/hashtable2.mm
cc -std=gnu++11 $FLAGS -c runtime/maptable.mm
cc -std=gnu++11 $FLAGS -c runtime/objc-auto.mm
cc -std=gnu++11 $FLAGS -c runtime/objc-cache.mm
cc -std=gnu++11 $FLAGS -c runtime/objc-class-old.mm
cc -std=gnu++11 $FLAGS -c runtime/objc-class.mm
cc -std=gnu++11 $FLAGS -c runtime/objc-errors.mm
cc -std=gnu++11 $FLAGS -c runtime/objc-exception.mm
cc -std=gnu++11 $FLAGS -c runtime/objc-file.mm
cc -std=gnu++11 $FLAGS -c runtime/objc-initialize.mm
cc -std=gnu++11 $FLAGS -c runtime/objc-layout.mm
cc -std=gnu++11 $FLAGS -c runtime/objc-load.mm
cc -std=gnu++11 $FLAGS -c runtime/objc-loadmethod.mm
cc -std=gnu++11 $FLAGS -c runtime/objc-lockdebug.mm
cc -std=gnu++11 $FLAGS -c runtime/objc-runtime-new.mm
cc -std=gnu++11 $FLAGS -c runtime/objc-runtime-old.mm
cc -std=gnu++11 $FLAGS -c runtime/objc-runtime.mm
cc -std=gnu++11 $FLAGS -c runtime/objc-sel-set.mm
cc -std=gnu++11 $FLAGS -c runtime/objc-sel.mm
cc -std=gnu++11 $FLAGS -c runtime/objc-sync.mm
cc -std=gnu++11 $FLAGS -c runtime/objc-typeencoding.mm
cc -std=gnu++11 $FLAGS -c runtime/Object.mm
cc -std=gnu++11 $FLAGS -c runtime/Protocol.mm
cc -std=gnu++11 $FLAGS -c runtime/objc-references.mm
cc -std=gnu++11 $FLAGS -c runtime/objc-os.mm
cc -std=gnu++11 $FLAGS -c runtime/objc-auto-dump.mm
cc -std=gnu++11 $FLAGS -c runtime/objc-file-old.mm
cc -std=gnu++11 $FLAGS -c runtime/objc-block-trampolines.mm
cc -std=gnu++11 $FLAGS -c runtime/objc-externalref.mm
cc -std=gnu++11 $FLAGS -c runtime/objc-weak.mm
cc -std=gnu++11 $FLAGS -c runtime/NSObject.mm
cc -std=gnu++11 $FLAGS -c runtime/objc-opt.mm
cc -std=gnu++11 $FLAGS -c runtime/objc-cache-old.mm
cc -std=gnu++11 $FLAGS -c runtime/objc-sel-old.mm
cc -std=gnu++11 $FLAGS -c runtime/Accessors.subproj/objc-accessors.mm
cc $FLAGS -c runtime/objc-sel-table.s
cc $FLAGS -c runtime/OldClasses.subproj/List.m
cc $FLAGS -c runtime/Messengers.subproj/objc-msg-arm.s
cc $FLAGS -c runtime/Messengers.subproj/objc-msg-i386.s
cc $FLAGS -c runtime/Messengers.subproj/objc-msg-x86_64.s
cc $FLAGS -c runtime/Messengers.subproj/objc-msg-simulator-i386.s
cc $FLAGS -c runtime/a1a2-blocktramps-i386.s
cc $FLAGS -c runtime/a2a3-blocktramps-i386.s
cc $FLAGS -c runtime/a1a2-blocktramps-x86_64.s
cc $FLAGS -c runtime/a2a3-blocktramps-x86_64.s
cc $FLAGS -c runtime/a1a2-blocktramps-arm.s
cc $FLAGS -c runtime/a2a3-blocktramps-arm.s
c++ -Wl,-no_dtrace_dof --stdlib=libc++ -dynamiclib -lauto -install_name $out/lib/libobjc.dylib -o libobjc.dylib *.o
./markgc -p libobjc.dylib
'';
installPhase = ''
mkdir -p $out/include $out/lib
mv build/include/objc $out/include
mv libobjc.dylib $out/lib
'';
}

View file

@ -0,0 +1,107 @@
--- objc4-551.1/runtime/objc-os.h 2013-06-10 21:16:15.000000000 -0400
+++ ../objc4-551.1/runtime/objc-os.h 2015-01-19 01:01:36.000000000 -0500
@@ -77,27 +77,72 @@
# include <mach-o/getsect.h>
# include <mach-o/dyld_priv.h>
# include <malloc/malloc.h>
-# include <os/lock_private.h>
# include <libkern/OSAtomic.h>
# include <libkern/OSCacheControl.h>
-# include <System/pthread_machdep.h>
# include "objc-probes.h" // generated dtrace probe definitions.
+#define __PTK_FRAMEWORK_OBJC_KEY5 45
+#define __PTK_FRAMEWORK_OBJC_KEY6 46
+#define __PTK_FRAMEWORK_OBJC_KEY7 47
+#define __PTK_FRAMEWORK_OBJC_KEY8 48
+#define __PTK_FRAMEWORK_OBJC_KEY9 49
+
+extern "C" int pthread_key_init_np(int, void (*)(void *));
+
// Some libc functions call objc_msgSend()
// so we can't use them without deadlocks.
void syslog(int, const char *, ...) UNAVAILABLE_ATTRIBUTE;
void vsyslog(int, const char *, va_list) UNAVAILABLE_ATTRIBUTE;
+#if defined(__i386__) || defined(__x86_64__)
+
+// Inlined spinlock.
+// Not for arm on iOS because it hurts uniprocessor performance.
+
+#define ARR_SPINLOCK_INIT 0
+// XXX -- Careful: OSSpinLock isn't volatile, but should be
+typedef volatile int ARRSpinLock;
+__attribute__((always_inline))
+static inline void ARRSpinLockLock(ARRSpinLock *l)
+{
+ unsigned y;
+again:
+ if (__builtin_expect(__sync_lock_test_and_set(l, 1), 0) == 0) {
+ return;
+ }
+ for (y = 1000; y; y--) {
+#if defined(__i386__) || defined(__x86_64__)
+ asm("pause");
+#endif
+ if (*l == 0) goto again;
+ }
+ thread_switch(THREAD_NULL, SWITCH_OPTION_DEPRESS, 1);
+ goto again;
+}
+__attribute__((always_inline))
+static inline void ARRSpinLockUnlock(ARRSpinLock *l)
+{
+ __sync_lock_release(l);
+}
+__attribute__((always_inline))
+static inline int ARRSpinLockTry(ARRSpinLock *l)
+{
+ return __sync_bool_compare_and_swap(l, 0, 1);
+}
+
+#define spinlock_t ARRSpinLock
+#define spinlock_trylock(l) ARRSpinLockTry(l)
+#define spinlock_lock(l) ARRSpinLockLock(l)
+#define spinlock_unlock(l) ARRSpinLockUnlock(l)
+#define SPINLOCK_INITIALIZER ARR_SPINLOCK_INIT
-#define spinlock_t os_lock_handoff_s
-#define spinlock_trylock(l) os_lock_trylock(l)
-#define spinlock_lock(l) os_lock_lock(l)
-#define spinlock_unlock(l) os_lock_unlock(l)
-#define SPINLOCK_INITIALIZER OS_LOCK_HANDOFF_INIT
+#endif
#if !TARGET_OS_IPHONE
-# include <CrashReporterClient.h>
+#define CRSetCrashLogMessage(msg)
+#define CRGetCrashLogMessage() 0
+#define CRSetCrashLogMessage2(msg)
#else
// CrashReporterClient not yet available on iOS
__BEGIN_DECLS
@@ -594,21 +639,13 @@
{
assert(is_valid_direct_key(k));
- if (_pthread_has_direct_tsd()) {
- return _pthread_getspecific_direct(k);
- } else {
- return pthread_getspecific(k);
- }
+ return pthread_getspecific(k);
}
static inline void tls_set_direct(tls_key_t k, void *value)
{
assert(is_valid_direct_key(k));
- if (_pthread_has_direct_tsd()) {
- _pthread_setspecific_direct(k, value);
- } else {
- pthread_setspecific(k, value);
- }
+ pthread_setspecific(k, value);
}
// not arm

View file

@ -0,0 +1,15 @@
{ appleDerivation', stdenv }:
appleDerivation' stdenv {
dontBuild = true;
installPhase = ''
mkdir -p $out/include/ppp
cp Controller/ppp_msg.h $out/include/ppp
cp Controller/pppcontroller_types.h $out/include/ppp
cp Controller/pppcontroller_types.h $out/include
cp Controller/pppcontroller.defs $out/include/ppp
cp Controller/pppcontroller_mach_defines.h $out/include
cp Controller/PPPControllerPriv.h $out/include/ppp
'';
}

View file

@ -0,0 +1,13 @@
{ appleDerivation', stdenvNoCC }:
appleDerivation' stdenvNoCC {
installPhase = ''
mkdir -p $out/include/
cp removefile.h checkint.h $out/include/
'';
appleHeaders = ''
checkint.h
removefile.h
'';
}

View file

@ -0,0 +1,50 @@
{ lib, appleDerivation, xcbuildHook, launchd }:
appleDerivation {
nativeBuildInputs = [ xcbuildHook launchd ];
patchPhase = ''
# NOTE: these hashes must be recalculated for each version change
# disables:
# - su ('security/pam_appl.h' file not found)
# - find (Undefined symbol '_get_date')
# - w (Undefined symbol '_res_9_init')
# - expr
substituteInPlace shell_cmds.xcodeproj/project.pbxproj \
--replace "FCBA168714A146D000AA698B /* PBXTargetDependency */," "" \
--replace "FCBA165914A146D000AA698B /* PBXTargetDependency */," "" \
--replace "FCBA169514A146D000AA698B /* PBXTargetDependency */," "" \
--replace "FCBA165514A146D000AA698B /* PBXTargetDependency */," ""
# disable w, test install
# get rid of permission stuff
substituteInPlace xcodescripts/install-files.sh \
--replace 'ln -f "$BINDIR/w" "$BINDIR/uptime"' "" \
--replace 'ln -f "$DSTROOT/bin/test" "$DSTROOT/bin/["' "" \
--replace "-o root -g wheel -m 0755" "" \
--replace "-o root -g wheel -m 0644" ""
'';
# temporary install phase until xcodebuild has "install" support
installPhase = ''
for f in Products/Release/*; do
if [ -f $f ]; then
install -D $f $out/usr/bin/$(basename $f)
fi
done
export DSTROOT=$out
export SRCROOT=$PWD
. xcodescripts/install-files.sh
mv $out/usr/* $out
mv $out/private/etc $out
rmdir $out/usr $out/private
'';
meta = {
platforms = lib.platforms.darwin;
maintainers = with lib.maintainers; [ matthewbauer ];
};
}

View file

@ -0,0 +1,109 @@
{ stdenv, appleDerivation, lib
, libutil, Librpcsvc, apple_sdk, pam, CF, openbsm }:
appleDerivation {
# xcbuild fails with:
# /nix/store/fc0rz62dh8vr648qi7hnqyik6zi5sqx8-xcbuild-wrapper/nix-support/setup-hook: line 1: 9083 Segmentation fault: 11 xcodebuild OTHER_CFLAGS="$NIX_CFLAGS_COMPILE" OTHER_CPLUSPLUSFLAGS="$NIX_CFLAGS_COMPILE" OTHER_LDFLAGS="$NIX_LDFLAGS" build
# see issue facebook/xcbuild#188
# buildInputs = [ xcbuild ];
buildInputs = [ libutil Librpcsvc apple_sdk.frameworks.OpenDirectory pam CF
apple_sdk.frameworks.IOKit openbsm ];
# NIX_CFLAGS_COMPILE = lib.optionalString hostPlatform.isi686 "-D__i386__"
# + lib.optionalString hostPlatform.isx86_64 "-D__x86_64__"
# + lib.optionalString hostPlatform.isAarch32 "-D__arm__";
NIX_CFLAGS_COMPILE = [ "-DDAEMON_UID=1"
"-DDAEMON_GID=1"
"-DDEFAULT_AT_QUEUE='a'"
"-DDEFAULT_BATCH_QUEUE='b'"
"-DPERM_PATH=\"/usr/lib/cron/\""
"-DOPEN_DIRECTORY"
"-DNO_DIRECT_RPC"
"-DAPPLE_GETCONF_UNDERSCORE"
"-DAPPLE_GETCONF_SPEC"
"-DUSE_PAM"
"-DUSE_BSM_AUDIT"
"-D_PW_NAME_LEN=MAXLOGNAME"
"-D_PW_YPTOKEN=\"__YP!\""
"-DAHZV1=64 "
"-DAU_SESSION_FLAG_HAS_TTY=0x4000"
"-DAU_SESSION_FLAG_HAS_AUTHENTICATED=0x4000"
] ++ lib.optional (!stdenv.isLinux) " -D__FreeBSD__ ";
patchPhase = ''
substituteInPlace login.tproj/login.c \
--replace bsm/audit_session.h bsm/audit.h
substituteInPlace login.tproj/login_audit.c \
--replace bsm/audit_session.h bsm/audit.h
'' + lib.optionalString stdenv.isAarch64 ''
substituteInPlace sysctl.tproj/sysctl.c \
--replace "GPROF_STATE" "0"
substituteInPlace login.tproj/login.c \
--replace "defined(__arm__)" "defined(__arm__) || defined(__arm64__)"
'';
buildPhase = ''
for dir in *.tproj; do
name=$(basename $dir)
name=''${name%.tproj}
CFLAGS=""
case $name in
arch) CFLAGS="-framework CoreFoundation";;
atrun) CFLAGS="-Iat.tproj";;
chkpasswd)
CFLAGS="-framework OpenDirectory -framework CoreFoundation -lpam";;
getconf)
for f in getconf.tproj/*.gperf; do
cfile=''${f%.gperf}.c
LC_ALL=C awk -f getconf.tproj/fake-gperf.awk $f > $cfile
done
;;
iostat) CFLAGS="-framework IOKit -framework CoreFoundation";;
login) CFLAGS="-lbsm -lpam";;
nvram) CFLAGS="-framework CoreFoundation -framework IOKit";;
sadc) CFLAGS="-framework IOKit -framework CoreFoundation";;
sar) CFLAGS="-Isadc.tproj";;
esac
echo "Building $name"
case $name in
# These are all broken currently.
arch) continue;;
chpass) continue;;
dirhelper) continue;;
dynamic_pager) continue;;
fs_usage) continue;;
latency) continue;;
pagesize) continue;;
passwd) continue;;
reboot) continue;;
sc_usage) continue;;
shutdown) continue;;
trace) continue;;
*) cc $dir/*.c -I''${dir} $CFLAGS -o $name ;;
esac
done
'';
installPhase = ''
for dir in *.tproj; do
name=$(basename $dir)
name=''${name%.tproj}
[ -x $name ] && install -D $name $out/bin/$name
for n in 1 2 3 4 5 6 7 8 9; do
for f in $dir/*.$n; do
install -D $f $out/share/man/man$n/$(basename $f)
done
done
done
'';
meta = {
platforms = lib.platforms.darwin;
maintainers = with lib.maintainers; [ shlevy matthewbauer ];
};
}

View file

@ -0,0 +1,29 @@
{ lib, appleDerivation, xcbuildHook, ncurses, bzip2, zlib, xz }:
appleDerivation {
nativeBuildInputs = [ xcbuildHook ];
buildInputs = [ ncurses bzip2 zlib xz ];
# patches to use ncursees
# disables md5
patchPhase = ''
substituteInPlace text_cmds.xcodeproj/project.pbxproj \
--replace 'FC6C98FB149A94EB00DDCC47 /* libcurses.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libcurses.dylib; path = /usr/lib/libcurses.dylib; sourceTree = "<absolute>"; };' 'FC6C98FB149A94EB00DDCC47 /* libncurses.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libncurses.dylib; path = /usr/lib/libncurses.dylib; sourceTree = "<absolute>"; };' \
--replace 'FC7A7EB5149875E00086576A /* PBXTargetDependency */,' ""
'';
installPhase = ''
for f in Products/Release/*; do
if [ -f $f ]; then
install -D $f $out/bin/$(basename $f)
fi
done
'';
NIX_CFLAGS_COMPILE=[ "-Wno-error=format-security" ]; # hardeningDisable doesn't cut it
meta = {
platforms = lib.platforms.darwin;
maintainers = with lib.maintainers; [ matthewbauer ];
};
}

View file

@ -0,0 +1,16 @@
{xcbuildHook, appleDerivation, apple_sdk, ncurses, libutil, lib}:
appleDerivation {
nativeBuildInputs = [ xcbuildHook ];
buildInputs = [ apple_sdk.frameworks.IOKit ncurses libutil ];
NIX_LDFLAGS = "-lutil";
installPhase = ''
install -D Products/Release/libtop.a $out/lib/libtop.a
install -D Products/Release/libtop.h $out/include/libtop.h
install -D Products/Release/top $out/bin/top
'';
meta = {
platforms = lib.platforms.darwin;
maintainers = with lib.maintainers; [ matthewbauer ];
};
}

View file

@ -0,0 +1,145 @@
{ appleDerivation', lib, stdenv, stdenvNoCC, buildPackages
, bootstrap_cmds, bison, flex
, gnum4, unifdef, perl, python3
, headersOnly ? true
}:
appleDerivation' (if headersOnly then stdenvNoCC else stdenv) ({
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [ bootstrap_cmds bison flex gnum4 unifdef perl python3 ];
patches = [ ./python3.patch ];
postPatch = ''
substituteInPlace Makefile \
--replace "/bin/" "" \
--replace "MAKEJOBS := " '# MAKEJOBS := '
substituteInPlace makedefs/MakeInc.cmd \
--replace "/usr/bin/" "" \
--replace "/bin/" "" \
--replace "-Werror " ""
substituteInPlace makedefs/MakeInc.def \
--replace "-c -S -m" "-c -m"
substituteInPlace makedefs/MakeInc.top \
--replace "MEMORY_SIZE := " 'MEMORY_SIZE := 1073741824 # '
substituteInPlace libkern/kxld/Makefile \
--replace "-Werror " ""
substituteInPlace SETUP/kextsymboltool/Makefile \
--replace "-lstdc++" "-lc++"
substituteInPlace libsyscall/xcodescripts/mach_install_mig.sh \
--replace "/usr/include" "/include" \
--replace "/usr/local/include" "/include" \
--replace 'MIG=`' "# " \
--replace 'MIGCC=`' "# " \
--replace " -o 0" "" \
--replace '$SRC/$mig' '-I$DSTROOT/include $SRC/$mig' \
--replace '$SRC/servers/netname.defs' '-I$DSTROOT/include $SRC/servers/netname.defs' \
--replace '$BUILT_PRODUCTS_DIR/mig_hdr' '$BUILT_PRODUCTS_DIR'
patchShebangs .
'';
PLATFORM = "MacOSX";
SDKVERSION = "10.11";
CC = "${stdenv.cc.targetPrefix or ""}cc";
CXX = "${stdenv.cc.targetPrefix or ""}c++";
MIG = "mig";
MIGCOM = "migcom";
STRIP = "${stdenv.cc.bintools.targetPrefix or ""}strip";
NM = "${stdenv.cc.bintools.targetPrefix or ""}nm";
UNIFDEF = "unifdef";
DSYMUTIL = "dsymutil";
HOST_OS_VERSION = "10.10";
HOST_CC = "${buildPackages.stdenv.cc.targetPrefix or ""}cc";
HOST_FLEX = "flex";
HOST_BISON = "bison";
HOST_GM4 = "m4";
MIGCC = "cc";
ARCHS = "x86_64";
NIX_CFLAGS_COMPILE = "-Wno-error";
preBuild = ''
# 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 10.0 10.1 10.2 10.3 10.4 10.5 10.6 10.7 10.8 10.9 10.10 10.11
elif [ "\$1" == "--ios" ]; then
echo 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 8.0 9.0
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 -rf $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.txt;
} // lib.optionalAttrs headersOnly {
HOST_CODESIGN = "echo";
HOST_CODESIGN_ALLOCATE = "echo";
LIPO = "echo";
LIBTOOL = "echo";
CTFCONVERT = "echo";
CTFMERGE = "echo";
CTFINSERT = "echo";
NMEDIT = "echo";
})

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