Merge pull request #234857 from reckenrode/configd-fix

configd: fix build with newer LLVM and bootstrap
This commit is contained in:
toonn 2023-06-05 19:26:06 +02:00 committed by GitHub
commit 501dcc2d3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 52 deletions

View File

@ -1,6 +1,9 @@
{ stdenv, fetchurl, xar, cpio, pkgs, python3, pbzx, lib, darwin-stubs, print-reexports }:
{ stdenv, fetchurl, libxml2, xar, cpio, pkgs, python3Minimal, pbzx, lib, darwin-stubs, print-reexports }:
let
xarMinimal = xar.override {
libxml2 = libxml2.override { pythonSupport = false; };
};
# sadly needs to be exported because security_tool needs it
sdk = stdenv.mkDerivation rec {
pname = "MacOS_SDK";
@ -16,7 +19,7 @@ let
sha256 = "13xq34sb7383b37hwy076gnhf96prpk1b4087p87xnwswxbrisih";
};
nativeBuildInputs = [ xar cpio python3 pbzx ];
nativeBuildInputs = [ xarMinimal cpio python3Minimal pbzx ];
outputs = [ "out" "dev" "man" ];

View File

@ -1,67 +1,32 @@
{ lib, stdenv, appleDerivation', launchd, bootstrap_cmds, xnu, ppp, IOKit, eap8021x, Security
{ lib, stdenv, appleDerivation', launchd, bootstrap_cmds, xnu, xpc, 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 ];
buildInputs = lib.optionals (!headersOnly) [ launchd ppp xpc IOKit eap8021x ];
propagatedBuildInputs = lib.optionals (!headersOnly) [ Security ];
env = lib.optionalAttrs (!headersOnly) {
NIX_CFLAGS_COMPILE = toString [
"-ISystemConfiguration.framework/Headers"
"-I${xnu}/Library/Frameworks/System.framework/Versions/B/PrivateHeaders"
];
};
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/reachability/SCNetworkReachabilityServer_client.c \
--replace '#include <xpc/private.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;
@ -177,9 +142,9 @@ appleDerivation' stdenv {
$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 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 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
@ -188,8 +153,8 @@ appleDerivation' stdenv {
$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 BondConfiguration.c -o BondConfiguration.o
$CC -I. -Ihelper -Iderived -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

View File

@ -248,6 +248,7 @@ developerToolsPackages_11_3_1 // macosPackages_11_0_1 // {
CommonCrypto = applePackage "CommonCrypto" "osx-10.12.6" "sha256-FLgODBrfv+XsGaAjddncYAm/BIJJYw6LcwX/z7ncKFM=" {};
configd = applePackage "configd" "osx-10.8.5" "sha256-6I3FWNjTgds5abEcZrD++s9b+P9a2+qUf8KFAb72DwI=" {
Security = applePackage "Security/boot.nix" "osx-10.9.5" "sha256-7qr0IamjCXCobIJ6V9KtvbMBkJDfRCy4C5eqpHJlQLI=" {};
inherit (pkgs.darwin.apple_sdk.libs) xpc;
};
copyfile = applePackage "copyfile" "osx-10.12.6" "sha256-uHqLFOIpXK+n0RHyOZzVsP2DDZcFDivKCnqHBaXvHns=" {};
Csu = applePackage "Csu" "osx-10.11.6" "sha256-h6a/sQMEVeFxKNWAPgKBXjWhyL2L2nvX9BQUMaTQ6sY=" {};
@ -310,6 +311,7 @@ developerToolsPackages_11_3_1 // macosPackages_11_0_1 // {
configdHeaders = applePackage "configd" "osx-10.8.5" "sha256-6I3FWNjTgds5abEcZrD++s9b+P9a2+qUf8KFAb72DwI=" {
headersOnly = true;
Security = null;
xpc = null;
};
libutilHeaders = pkgs.darwin.libutil.override { headersOnly = true; };
hfsHeaders = pkgs.darwin.hfs.override { headersOnly = true; };