Home Explore Blog Models CI



nixpkgs

5th chunk of `doc/stdenv/platform-notes.chapter.md`
9dee1a3a4cb0b4021845446553ecc5e6e3e9f502a07de1910000000100000900
When you propagate an SDK, it becomes part of your derivation’s public API, and changing the SDK or removing it can be a breaking change.
That is why propagating it is only recommended for compilers.

When authoring a compiler derivation, propagate the SDK only for the ways you expect users to use your compiler.
Depending on your expected use cases, you may have to do one or all of these.

- Put it in `depsTargetTargetPropagated` when your compiler is expected to be added to `nativeBuildInputs`.
  That will ensure the SDK is effectively part of the target derivation’s `buildInputs`.
- If your compiler uses a hook, put it in the hook’s `depsTargetTargetPropagated` instead.
  The effect should be the same as the above.
- If your package uses the builder pattern, update your builder to add the SDK to the derivation’s `buildInputs`.

If you’re not sure whether to propagate an SDK, don’t.
If your package is a compiler or language, and you’re not sure, ask @NixOS/darwin-maintainers for help deciding.

### Dealing with `darwin.apple_sdk.frameworks` {#sec-darwin-legacy-frameworks}

You may see references to `darwin.apple_sdk.frameworks`.
This is the legacy SDK pattern, and it is being phased out.
All packages in `darwin.apple_sdk`, `darwin.apple_sdk_11_0`, and `darwin.apple_sdk_12_3` have been removed.
If your derivation references them, you should delete those references, as the default SDK should be enough to build your package.

Note: the new SDK pattern uses the name `apple-sdk` to better align with Nixpkgs naming conventions.
The legacy SDK pattern uses `apple_sdk`.
You always know you are using the old SDK pattern if the name is `apple_sdk`.

Some derivations may depend on the location of frameworks in those old packages.
To update your derivation to find them in the new SDK, use `$SDKROOT` instead in `preConfigure`.
For example, if you substitute `${darwin.apple_sdk.frameworks.OpenGL}/Library/Frameworks/OpenGL.framework` in `postPatch`, replace it with `$SDKROOT/System/Library/Frameworks/OpenGL.framework` in `preConfigure`.

Note that if your derivation is changing a system path (such as `/System/Library/Frameworks/OpenGL.framework`), you may be able to remove the path.
Compilers and binutils targeting Darwin look for system paths in the SDK sysroot.

Title: Nixpkgs Darwin: SDK Propagation for Compilers and Legacy Frameworks Migration
Summary
This document explains that propagating an SDK is generally discouraged due to its impact on a derivation's public API, making it suitable only for compilers. It details methods for compiler SDK propagation (e.g., `depsTargetTargetPropagated`, hooks, builder patterns) and advises caution, suggesting to consult `@NixOS/darwin-maintainers` if unsure. Additionally, it addresses the deprecation of the `darwin.apple_sdk.frameworks` legacy pattern, instructing users to remove references to these phased-out packages and update derivations to use `$SDKROOT` for locating frameworks within the new `apple-sdk`.