summary refs log tree commit diff
path: root/pkgs/stdenv
diff options
context:
space:
mode:
authorRandy Eckenrode <randy@largeandhighquality.com>2023-10-27 20:19:11 -0400
committerRandy Eckenrode <randy@largeandhighquality.com>2023-11-01 09:06:44 -0400
commit50d046c32a1924066b87392d8b2ebb14e509e65c (patch)
tree76ff7047208831011866ccc76d10d59772f7801e /pkgs/stdenv
parent6e4f3b7d86106f8696b083992ddd22eba530ce8e (diff)
downloadnixpkgs-50d046c32a1924066b87392d8b2ebb14e509e65c.tar
nixpkgs-50d046c32a1924066b87392d8b2ebb14e509e65c.tar.gz
nixpkgs-50d046c32a1924066b87392d8b2ebb14e509e65c.tar.bz2
nixpkgs-50d046c32a1924066b87392d8b2ebb14e509e65c.tar.lz
nixpkgs-50d046c32a1924066b87392d8b2ebb14e509e65c.tar.xz
nixpkgs-50d046c32a1924066b87392d8b2ebb14e509e65c.tar.zst
nixpkgs-50d046c32a1924066b87392d8b2ebb14e509e65c.zip
stdenvAdapters.overrideSDK: update the SDK version recursively
Update all propagated build inputs recursively, so that propagated
inputs with propagated inputs use the correct SDK.
Diffstat (limited to 'pkgs/stdenv')
-rw-r--r--pkgs/stdenv/adapters.nix27
1 files changed, 15 insertions, 12 deletions
diff --git a/pkgs/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix
index dd3dcfd6f3a..9230ce071c3 100644
--- a/pkgs/stdenv/adapters.nix
+++ b/pkgs/stdenv/adapters.nix
@@ -263,21 +263,24 @@ rec {
 
       sdk = pkgs.darwin."apple_sdk_${lib.replaceStrings [ "." ] [ "_" ] darwinSdkVersion}";
 
-      isSDKFramework = pkg: lib.hasPrefix "apple-framework-" (lib.getName pkg);
-
       replacePropagatedFrameworks = pkg:
         let
-          propagatedFrameworks = lib.filter isSDKFramework pkg.propagatedBuildInputs;
+          propagatedInputs = pkg.propagatedBuildInputs;
+          mappedInputs = map mapPackageToSDK propagatedInputs;
+
           env = {
             inherit (pkg) outputs;
-            # Map the old frameworks to new and the package’s outputs to their original outPaths.
-            # The mappings are rendered into tab-separated files to be read back with `read`.
-            frameworks = lib.concatMapStrings (pkg: "${pkg}\t${mapPackageToSDK pkg}\n") propagatedFrameworks;
+            # Map old frameworks to new ones and the package’s outputs to their original outPaths.
+            # Also map any packages that have propagated frameworks to their proxy packages using
+            # the requested SDK version. These mappings are rendered into tab-separated files to be
+            # parsed and read back with `read`.
+            dependencies = lib.concatMapStrings (pair: "${pair.fst}\t${pair.snd}\n") (lib.zipLists propagatedInputs mappedInputs);
             pkgOutputs = lib.concatMapStrings (output: "${output}\t${(lib.getOutput output pkg).outPath}\n") pkg.outputs;
-            passAsFile = [ "frameworks" "pkgOutputs" ];
+            passAsFile = [ "dependencies" "pkgOutputs" ];
           };
         in
-        if lib.length propagatedFrameworks > 0
+        # Only remap the package’s propagated inputs if there are any and if any of them were themselves remapped.
+        if lib.length propagatedInputs > 0 && propagatedInputs != mappedInputs
           then pkgs.runCommand pkg.name env ''
             # Iterate over the outputs in the package being replaced to make sure the proxy is
             # a fully functional replacement. This is like `symlinkJoin` except for outputs and
@@ -302,7 +305,7 @@ rec {
                       while IFS=$'\t\n' read -r oldFramework newFramework; do
                         substituteInPlace "''${!outputName}/nix-support/$fileName" \
                           --replace "$oldFramework" "$newFramework"
-                      done < "$frameworksPath"
+                      done < "$dependenciesPath"
                     fi
                   done
                 else
@@ -319,9 +322,9 @@ rec {
           name = lib.getName pkg;
           framework = lib.removePrefix "apple-framework-" name;
         in
-        if isSDKFramework pkg
-          then sdk.frameworks."${framework}"
-          else replacePropagatedFrameworks pkg;
+        /**/ if pkg == null then pkg
+        else if name != framework then sdk.frameworks."${framework}"
+        else replacePropagatedFrameworks pkg;
 
       mapRuntimeToSDK = pkg:
         # Only remap xcbuild for now, which exports the SDK used to build it.