An open API service indexing awesome lists of open source software.

https://github.com/determinatesystems/apple-sdks.nix

Experimental extraction of Apple SDKs.
https://github.com/determinatesystems/apple-sdks.nix

Last synced: 11 months ago
JSON representation

Experimental extraction of Apple SDKs.

Awesome Lists containing this project

README

          

_Note: the vast majority of this repo is copied directly out of https://github.com/NixOS/nixpkgs/pull/229210._

# apple-sdks

This document describes the different components which go into producing the Apple SDKs (versions later than 11.0) in Nixpkgs.

## Frameworks and Libraries

Generally, Each release of the SDK has a number of libraries and frameworks associated with it.

### Libraries

**TODO(@connorbaker):** further documentation.

### Frameworks

We store the logic and data for each SDK's frameworks `frameworks/sdk-version`, where `sdk-version` is something like `13.3.0`. The `frameworks/default.nix` file contains a function which produces our final framework derivations, combining the information in the files `public.nix`, `private.nix`, and `fixups.nix` in `frameworks/sdk-version`. The `frameworks/default.nix` expression infers the SDK version to build by looking at the `version` attribute of the `MacOSX-SDK` derivation it takes as an argument.

#### Public frameworks

Currently, we use `gen-frameworks.py` to create the `frameworks/sdk-version/public.nix` files we need. Unfortunately, the script doesn't always get all available frameworks, nor capture all necessary dependencies. In particular, private frameworks aren't captured by the script.

The easiest way to run the script is by using its `--from-apple-sdk-releases` option which will cause it to generate a `public.nix` file for each SDK version in `apple-sdk-releases.json`. An example invocation is:

```sh
./gen-frameworks.py --from-apple-sdk-releases ../apple-sdk-releases.json
```

Currently, there is no way to specify the directory to place the generated directories and files in, so be sure to run the script from the `frameworks` directory!

#### Private frameworks

Finding out which private frameworks are exposed in the SDK or used in Nixpkgs is a pain. The best @connorbaker has been able to figure out so far is adding entries to `frameworks/sdk-version/private.nix` as they are encountered. This is tedious and error-prone.

#### Framework fixups

Beyond exposing frameworks, there's typically some amount of "fixing up" needed for them to work properly. For example, because private frameworks aren't picked up by `gen-frameworks.py`, we have to manually add dependencies on private frameworks to the public frameworks. To separate the manual from automatically-generated Nix files, we use `frameworks/sdk-version/fixups.nix` as a place to store this information.

The `frameworks/sdk-version/fixups.nix` file contains three attributes:

- `addToFrameworks`
- `removeFromFrameworks`
- `overrideFrameworks`

The `addToFrameworks` attribute is an attribute set where each key is the name of a framework and each value is an attribute set of dependencies to add to the named framework.

The `removeFromFrameworks` attribute is an attribute set where each key is the name of a framework and each value is an attribute set of dependencies to remove from the named framework.

The `overrideFrameworks` attribute is function which accepts an attribute set of framework derivations and returns an attribute set of framework derivations. This is useful for doing things like modifying the `buildPhase` or `installPhase` of a framework.

# Notes

If you see an error like this:

```
> Running phase: installPhase
> Fixing re-exports in /nix/store/nzb9d81qjsvah2spa540pb1731qi07q7-apple-framework-CoreMIDIServer-13.1.0/Library/Frameworks/CoreMIDIServer.framework/Versions/A/CoreMIDIServer.tbd
> Errors occurred during rewrite of /nix/store/nzb9d81qjsvah2spa540pb1731qi07q7-apple-framework-CoreMIDIServer-13.1.0/Library/Frameworks/CoreMIDIServer.framework/Versions/A/CoreMIDIServer.tbd
> Rewrite config:
> Exact mappings:
> Prefix mappings:
> - /usr/lib/swift/ -> /nix/store/nzb9d81qjsvah2spa540pb1731qi07q7-apple-framework-CoreMIDIServer-13.1.0/lib/swift/
> - /System/Library/Frameworks/CoreMIDIServer.framework/ -> /nix/store/nzb9d81qjsvah2spa540pb1731qi07q7-apple-framework-CoreMIDIServer-13.1.0/Library/Frameworks/CoreMIDIServer.framework/
> Required prefix: /nix/store
> Check existence of resulting paths: yes
>
> The following paths did not match any rewrite rule
> /System/Library/Frameworks/CoreMIDI.framework/Versions/A/CoreMIDI
> libc++abi: terminating due to uncaught exception of type rewrite_errors: Rewriting failed
```

then you need to add a fixup. Note especially:

```
> Errors occurred during rewrite of /nix/store/nzb9d81qjsvah2spa540pb1731qi07q7-apple-framework-CoreMIDIServer-13.1.0/Library/Frameworks/CoreMIDIServer.framework/Versions/A/CoreMIDIServer.tbd
```

and

```
> The following paths did not match any rewrite rule
> /System/Library/Frameworks/CoreMIDI.framework/Versions/A/CoreMIDI
```

like this:

```nix
addToFrameworks = # ...
CoreMIDIServer = { inherit CoreMIDI; };
```