linnnus
November 17, 2024, 7:23pm
1
I am working on porting the honggfuzz
derivation to Darwin. As part of the build a tool called mig
is used to generate RPC code.
I am not very familiar with how Darwin tooling is packaged in Nix. I know nixpkgs contains an xcode
derivation and darwinTools
is a thing, but neither seem to contain a mig
executable. Is there a package that contains mig
for Darwin?
mig
is available in the darwin.bootstrap_cmds package. The stdenv documentstion (especially for 24.11) has information on packaging applications for Darwin.
# Platform Notes {#chap-platform-notes}
## Darwin (macOS) {#sec-darwin}
The Darwin `stdenv` differs from most other ones in Nixpkgs in a few key ways.
These differences reflect the default assumptions for building software on that platform.
In many cases, you can ignore these differences because the software you are packaging is already written with them in mind.
When you do that, write your derivation as normal. You don’t have to include any Darwin-specific special cases.
The easiest way to know whether your derivation requires special handling for Darwin is to write it as if it doesn’t and see if it works.
If it does, you’re done; skip the rest of this.
- Darwin uses Clang by default instead of GCC. Packages that refer to `$CC` or `cc` should just work in most cases.
Some packages may hardcode `gcc` or `g++`. You can usually fix that by setting `makeFlags = [ "CC=cc" "CXX=C++" ]`.
If that does not work, you will have to patch the build scripts yourself to use the correct compiler for Darwin.
- Darwin needs an SDK to build software.
The SDK provides a default set of frameworks and libraries to build software, most of which are specific to Darwin.
There are multiple versions of the SDK packages in Nixpkgs, but one is included by default in the `stdenv`.
Usually, you don’t have to change or pick a different SDK. When in doubt, use the default.
- The SDK used by your build can be found using the `DEVELOPER_DIR` environment variable.
There are also versions of this variable available when cross-compiling depending on the SDK’s role.
This file has been truncated. show original
linnnus
November 22, 2024, 4:07pm
3
Thanks so much! Especially for the pointer to the 24.11 documentation. Its wayy better than the currently stable documentation.
Sidenote in case someone finds this post in the future: I gave up on the patch since it turns out that upstream’s Darwin support is pretty bad .
1 Like