Gcc: command not found

I’m trying to adapt the nixpkgs prover9 package (https://github.com/NixOS/nixpkgs/blob/cba1e5d52acb5251b418d0c95c3dcec7d5dc003b/pkgs/applications/science/logic/prover9/default.nix) to build on my mac (aarch64-darwin, mac os 13.6). Prover9 itself builds fine from source with just “make all”, not involving nix.

I’ve basically taken the mkDerivation from the linked default.nix and stuck it in a flake, just changing meta.platforms to include aarch64-darwin. When I nix build this flake (here), I make it to the build phase but then error out with gcc: command not found.

Probably related: when I just do a “hello world” flake to see where the problem is, I get the same error if I set buildPhase to a command that runs gcc directly, whereas running clang directly in the buildPhase works fine. I guess that because I’m on a mac, nix is providing only clang and not gcc to the builds? But then how can I just do a simple make all?

I believe you’d set CC=clang and CXX=clang. Should in theory be possible to set those just in the mkDerivation attrset.

Edit: Ah, right, nix does that by default on macos: Nixpkgs 23.05 manual | Nix & NixOS

If there’s no serious mistake in your installation, this probably just means the upstream makefile is broken and you’ll have to figure out why it ignores CC. There are suggestions in the manual, if those don’t work you’ll need to dig deeper.

This is likely why the package isn’t available on macos currently. I’d wager their makefile does something silly like detect you’re on Linux from something in the build env, and the package author didn’t want to patch that madness (or didn’t have the hardware to test for it).

Excellent; this was it! The makefile sets CC to gcc; fixing this in postPatch got it to build. I don’t have time to test it fully at the moment, but it certainly looks like it’s working. Thanks very much!

1 Like