summary refs log tree commit diff
diff options
context:
space:
mode:
authorAndrew Childs <lorne@cons.org.nz>2021-01-29 14:39:23 +0900
committerAndrew Childs <lorne@cons.org.nz>2021-05-17 00:27:02 +0900
commitd2c96703397a909fa9108d33a225da87684aea8f (patch)
tree378e1e2b1da6dee90673476a96dee9659b438716
parent3a3df3146e244b6b36a5fa10e2c4890a59fce3b2 (diff)
downloadnixpkgs-d2c96703397a909fa9108d33a225da87684aea8f.tar
nixpkgs-d2c96703397a909fa9108d33a225da87684aea8f.tar.gz
nixpkgs-d2c96703397a909fa9108d33a225da87684aea8f.tar.bz2
nixpkgs-d2c96703397a909fa9108d33a225da87684aea8f.tar.lz
nixpkgs-d2c96703397a909fa9108d33a225da87684aea8f.tar.xz
nixpkgs-d2c96703397a909fa9108d33a225da87684aea8f.tar.zst
nixpkgs-d2c96703397a909fa9108d33a225da87684aea8f.zip
darwin: add CoreFoundation to the build when explicitly required
-rw-r--r--pkgs/os-specific/darwin/apple-sdk-11.0/apple_sdk.nix6
-rw-r--r--pkgs/os-specific/darwin/apple-sdk-11.0/cf-setup-hook.sh6
-rw-r--r--pkgs/top-level/darwin-packages.nix18
3 files changed, 28 insertions, 2 deletions
diff --git a/pkgs/os-specific/darwin/apple-sdk-11.0/apple_sdk.nix b/pkgs/os-specific/darwin/apple-sdk-11.0/apple_sdk.nix
index 8e464b1d4fc..a4242405b41 100644
--- a/pkgs/os-specific/darwin/apple-sdk-11.0/apple_sdk.nix
+++ b/pkgs/os-specific/darwin/apple-sdk-11.0/apple_sdk.nix
@@ -129,7 +129,11 @@ in rec {
     };
   };
 
-  overrides = super: {};
+  overrides = super: {
+    CoreFoundation = lib.overrideDerivation super.CoreFoundation (drv: {
+      setupHook = ./cf-setup-hook.sh;
+    });
+  };
 
   bareFrameworks = (
     lib.mapAttrs framework (import ./frameworks.nix {
diff --git a/pkgs/os-specific/darwin/apple-sdk-11.0/cf-setup-hook.sh b/pkgs/os-specific/darwin/apple-sdk-11.0/cf-setup-hook.sh
new file mode 100644
index 00000000000..3b08c51d196
--- /dev/null
+++ b/pkgs/os-specific/darwin/apple-sdk-11.0/cf-setup-hook.sh
@@ -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)
diff --git a/pkgs/top-level/darwin-packages.nix b/pkgs/top-level/darwin-packages.nix
index 5c49aecd2a5..a43cdc80a9d 100644
--- a/pkgs/top-level/darwin-packages.nix
+++ b/pkgs/top-level/darwin-packages.nix
@@ -162,7 +162,23 @@ impure-cmds // appleSourcePackages // chooseLibs // {
 
   # TODO: make swift-corefoundation build with apple_sdk_11_0.Libsystem
   CF = if useAppleSDKLibs
-    then apple_sdk.frameworks.CoreFoundation
+    then
+      # This attribute (CF) is included in extraBuildInputs in the stdenv. This
+      # is typically the open source project. When a project refers to
+      # "CoreFoundation" it has an extra setup hook to force impure system
+      # CoreFoundation into the link step.
+      #
+      # In this branch, we only have a single "CoreFoundation" to choose from.
+      # To be compatible with the existing convention, we define
+      # CoreFoundation with the setup hook, and CF as the same package but
+      # with the setup hook removed.
+      #
+      # This may seem unimportant, but without it packages (e.g., bacula) will
+      # fail with linker errors referring ___CFConstantStringClassReference.
+      # It's not clear to me why some packages need this extra setup.
+      lib.overrideDerivation apple_sdk.frameworks.CoreFoundation (drv: {
+        setupHook = null;
+      })
     else callPackage ../os-specific/darwin/swift-corelibs/corefoundation.nix { };
 
   # As the name says, this is broken, but I don't want to lose it since it's a direction we want to go in