NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.05k stars 14.09k forks source link

Tracking: New Darwin SDK pattern migration #354146

Open getchoo opened 2 hours ago

getchoo commented 2 hours ago

Issue description

As introduced in https://github.com/NixOS/nixpkgs/pull/346043 and explained fully in https://discourse.nixos.org/t/the-darwin-sdks-have-been-updated/55295, nixpkgs has a new way of handling the Darwin SDK.

As a TL;DR:

  • Instead of providing separate SDK frameworks and libraries, they are bundled together in an SDK that can be used with xcrun and the xcbuild package.
  • The SDK includes everything you need to build applications. It also propagates certain packages automatically (libiconv, libresolv, and libsbuf). It is no longer necessary to include these conditionally on Darwin.
  • The stdenv provides a default SDK (the unversioned apple-sdk package). A different SDK can be used to change the SDK in use by adding it to your buildInputs (see the stdenv documentation for more details).

Some examples of the migration are:

{
  buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [
    darwin.apple_sdk.frameworks.Security
  ];
}
{
  buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [
    darwin.apple_sdk_11_0.frameworks.Security
  ];
}
{
  buildInputs = lib.optional stdenv.hostPlatformIsDarwin apple-sdk_11;
}

Steps to reproduce

You can grep for usages of the SDK and it's components tree-wide:

For example, to find files using it in pkgs/by-name:

$ grep -Rl 'darwin.apple_sdk' pkgs/by-name

You may also want to search for specific components, i.e.:

$ grep -Rl 'Security' pkgs/tools/audio

Technical details

Some caution should be taken during the migration:

getchoo commented 2 hours ago

Some recent PRs that made good progress on this: