Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions pkgs/development/tools/misc/indent/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [ texinfo ];
pkgsBuildBuild = [ buildPackages.stdenv.cc ]; # needed when cross-compiling

env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang
"-Wno-implicit-function-declaration";
env.NIX_CFLAGS_COMPILE = toString (
lib.optional stdenv.cc.isClang "-Wno-implicit-function-declaration"
++ lib.optional (stdenv.cc.isClang && lib.versionAtLeast (lib.getVersion stdenv.cc) "13") "-Wno-unused-but-set-variable"
);

hardeningDisable = [ "format" ];

Expand Down
3 changes: 3 additions & 0 deletions pkgs/development/tools/misc/pkg-config/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ stdenv.mkDerivation rec {
"ac_cv_func_posix_getgrgid_r=yes"
];

# Silence "incompatible integer to pointer conversion passing 'gsize'" when building with Clang.
env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-Wno-int-conversion";

enableParallelBuilding = true;
doCheck = true;

Expand Down
2 changes: 2 additions & 0 deletions pkgs/os-specific/darwin/apple-sdk-11.0/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ let
mkStdenv = stdenv:
if stdenv.isAarch64 then stdenv
else

(overrideCC stdenv (mkCc stdenv.cc)).override {
extraBuildInputs = [ pkgs.darwin.apple_sdk_11_0.frameworks.CoreFoundation ];
targetPlatform = stdenv.targetPlatform // {
darwinMinVersion = "10.12";
darwinSdkVersion = "11.0";
Expand Down
4 changes: 2 additions & 2 deletions pkgs/os-specific/darwin/apple-sdk/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ stdenv, fetchurl, xar, cpio, pkgs, python3, pbzx, lib, darwin-stubs, print-reexports }:
{ stdenv, fetchurl, xar, cpio, pkgs, python3Minimal, pbzx, lib, darwin-stubs, print-reexports }:

let
# sadly needs to be exported because security_tool needs it
Expand All @@ -16,7 +16,7 @@ let
sha256 = "13xq34sb7383b37hwy076gnhf96prpk1b4087p87xnwswxbrisih";
};

nativeBuildInputs = [ xar cpio python3 pbzx ];
nativeBuildInputs = [ xar cpio python3Minimal pbzx ];

outputs = [ "out" "dev" "man" ];

Expand Down
65 changes: 15 additions & 50 deletions pkgs/os-specific/darwin/apple-source-releases/configd/default.nix
Original file line number Diff line number Diff line change
@@ -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 ];

patchPhase = lib.optionalString (!headersOnly) ''
HACK=$PWD/hack
mkdir $HACK
cp -r ${xnu}/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/net $HACK

env = lib.optionalAttrs (!headersOnly) {
NIX_CFLAGS_COMPILE = toString [
"-ISystemConfiguration.framework/Headers"
"-I${xnu}/Library/Frameworks/System.framework/Versions/B/PrivateHeaders"
];
};

substituteInPlace SystemConfiguration.fproj/SCNetworkReachabilityInternal.h \
--replace '#include <xpc/xpc.h>' ""
patchPhase = lib.optionalString (!headersOnly) ''
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;
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions pkgs/os-specific/darwin/apple-source-releases/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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=" {};
Expand Down Expand Up @@ -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; };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ appleDerivation' (if headersOnly then stdenvNoCC else stdenv) (
--replace "-Werror " ""

substituteInPlace SETUP/kextsymboltool/Makefile \
--replace "-lstdc++" "-lc++"
--replace "-lstdc++" "-lc++ -lc++abi"

substituteInPlace libsyscall/xcodescripts/mach_install_mig.sh \
--replace "/usr/include" "/include" \
Expand Down
80 changes: 80 additions & 0 deletions pkgs/os-specific/darwin/cctools/llvm.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Create a cctools-compatible bintools that uses equivalent tools from LLVM in place of the ones
# from cctools when possible.

{ lib, stdenv, makeWrapper, cctools-port, llvmPackages, useLLD ? false }:

let
# `lipo` crashes when running the LLVM test suite when building a fat bundle. This is fixed in LLVM 16.
# See https://github.com/llvm/llvm-project/issues/59535
use_llvm_lipo = lib.versionAtLeast llvmPackages.release_version "16";

llvm_bins = [
"bitcode_strip"
"dwarfdump"
"nm"
"objdump"
"otool"
"ranlib"
"size"
"strings"
"strip"
] ++ lib.optional use_llvm_lipo "lipo";

# Only include the tools that LLVM doesn’t provide and that are present normally on Darwin.
cctools_bins = [
"cmpdylib"
"codesign_allocate"
"ctf_insert"
"install_name_tool"
"libtool"
"nmedit"
"pagestuff"
"segedit"
"vtool"
] ++ lib.optional (! use_llvm_lipo) "lipo";

ld_path = if useLLD
then "${lib.getBin llvmPackages.lld}/bin/ld64"
else "${lib.getBin cctools-port}/bin/ld";

inherit (stdenv.cc) targetPrefix;
in
stdenv.mkDerivation {
pname = "cctools-llvm-${if useLLD then "lld" else "ld64"}";
version = llvmPackages.release_version;

nativeBuildInputs = [ makeWrapper ];

outputs = [ "out" "dev" "man" ];

buildCommand = ''
mkdir -p "$out/bin"
ln -s "${lib.getDev cctools-port}" "$dev"
ln -s "${lib.getMan cctools-port}" "$man" # FIXME

# Use the clang-integrated assembler instead of using `as` from cctools.
makeWrapper "${lib.getBin llvmPackages.clang-unwrapped}/bin/clang" "$out/bin/${targetPrefix}as" \
--add-flags "-x assembler -integrated-as -c"

ln -s "${lib.getBin llvmPackages.bintools-unwrapped}/bin/llvm-ar" "$out/bin/${targetPrefix}ar"

for tool in ${toString llvm_bins}; do
llvmTool=''${tool/_/-}
ln -s "${lib.getBin llvmPackages.llvm}/bin/llvm-$llvmTool" "$out/bin/${targetPrefix}$tool"
done

# llvm-libtool-darwin is not yet capable of being a drop-in replacement for libtool when used with xcbuild.
# ln -s "${lib.getBin llvmPackages.llvm}/bin/llvm-libtool-darwin" "$out/bin/${targetPrefix}libtool"

# Don’t use `install_name_tool` from LLVM for now because it causes the build of darwin.CF to fail.
# ln -s "${lib.getBin llvmPackages.llvm}/bin/llvm-objcopy" "$out/bin/${targetPrefix}install_name_tool"

for tool in ${toString cctools_bins}; do
ln -s "${lib.getBin cctools-port}/bin/${targetPrefix}$tool" "$out/bin/${targetPrefix}$tool"
done

ln -s "${ld_path}" "$out/bin/${targetPrefix}ld"
'';

passthru = { inherit targetPrefix; };
}
13 changes: 11 additions & 2 deletions pkgs/os-specific/darwin/rewrite-tbd/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ stdenv, lib, fetchFromGitHub, cmake, pkg-config, libyaml }:
{ stdenv, lib, fetchFromGitHub, gnumake, libyaml }:

stdenv.mkDerivation {
pname = "rewrite-tbd";
Expand All @@ -11,9 +11,18 @@ stdenv.mkDerivation {
sha256 = "08sk91zwj6n9x2ymwid2k7y0rwv5b7p6h1b25ipx1dv0i43p6v1a";
};

nativeBuildInputs = [ cmake pkg-config ];
# Nix takes care of these paths. Avoiding the use of `pkg-config` prevents an infinite recursion.
postPatch = ''
substituteInPlace Makefile.boot \
--replace '$(shell pkg-config --cflags yaml-0.1)' "" \
--replace '$(shell pkg-config --libs yaml-0.1)' "-lyaml"
'';

nativeBuildInputs = [ gnumake ];
buildInputs = [ libyaml ];

makeFlags = [ "-f" "Makefile.boot" "PREFIX=${placeholder "out"}"];

meta = with lib; {
homepage = "https://github.com/thefloweringash/rewrite-tbd/";
description = "Rewrite filepath in .tbd to Nix applicable format";
Expand Down
4 changes: 3 additions & 1 deletion pkgs/os-specific/darwin/swift-corelibs/corefoundation.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ lib, stdenv, fetchFromGitHub, fetchurl, ninja, python3, curl, libxml2, objc4, ICU }:
{ lib, stdenv, fetchFromGitHub, fetchurl, makeSetupHook, ninja, python3, curl, libxml2, objc4, ICU }:

let
# 10.12 adds a new sysdir.h that our version of CF in the main derivation depends on, but
Expand Down Expand Up @@ -104,4 +104,6 @@ stdenv.mkDerivation {
ln -s Versions/Current/$i $base/$i
done
'';

darwinEnvHook = makeSetupHook { name = "darwin-env-hook"; } ./pure-corefoundation-hook.sh;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
usePureCoreFoundation() {
# Avoid overriding value set by the impure CF
if [ -z "${NIX_COREFOUNDATION_RPATH:-}" ]; then
export NIX_COREFOUNDATION_RPATH=@out@/Library/Frameworks
fi
}
addEnvHooks "$hostOffset" usePureCoreFoundation
Loading