Has stdenvNoCC changed on Darwin?

I’m trying to use stdenvNoCC.mkDerivation to build Mac software that relies on Apple frameworks. It definitely used to work (maybe before I upgraded to Nix 2.4?), i.e., Carbon and other framework headers were picked up in the derivation build. Now that doesn’t seem to be the case. Has something changed?

For various reasons, I’m reluctant to use stdenv.mkDerivation and add darwin.apple_sdk.frameworks.Carbon to buildInputs.

Not using flakes (at least not yet).

I don’t know Apple stuff, but if I choose not to get a compiler, I would not expect Frameworks. stdenvNoCC is meant for trivial tasks like composing configs and shuffling with files.

The only way stdenvNoCC would pick up Apple frameworks is if the derivation is impure and Xcode or the command-line tools are installed. You can see an example of this in the MoltenVK derivation in nixpkgs.

1 Like

Yes, thank you. Turns out that my problem occurred because sometimes installing Xcode command-line tools with xcode-select --install does not do the trick, and that I additionally have to go and install the package manually from Apple’s developer site. That made the Carbon headers visible to the stdenvNoCC compiler.

Impure derivations definitely leave something to be desired.

1 Like

Can you elaborate on “the right way” to install Xcode?

I’m writing a guide and dodging this pitfall or noting it might be a good inclusion.

I don’t know if it can be called “the right way”, but I ran into a problem where the recommended xcode-select --install command-line incantation doesn’t fully install everything needed. I then downloaded “Command Line Tools for Xcode” of the appropriate version (link here, Apple Developer login required), and ran the installer. After that, the built-in compiler mysteriously started recognizing frameworks (like Carbon) again.

Hosted by Flying Circus.