#Compiling bevy with nix

6 messages · Page 1 of 1 (latest)

oblique needle
#

I like to setup all my projects with nix from the start to make things like CI/CD and distribution easier in the future, and I'm trying to do that before I start learning bevy.

However there seem to be some issues with compiling the coreaudio-sys crate with nix:

error: failed to run custom build command for `coreaudio-sys v0.2.11`

Caused by:
  process didn't exit successfully: `/private/tmp/nix-build-bevy-proj-0.1.0.drv-0/source/target/release/build/coreaudio-sys-bf8267054c513216/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=COREAUDIO_SDK_PATH
  cargo:rustc-link-lib=framework=AudioUnit
  cargo:rustc-link-lib=framework=CoreAudio
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS

  --- stderr
  /nix/store/y390cqhaxnpzd9fm18l8w7s30rna3603-coreaudio-sys-0.2.11/coreaudio.h:1:10: fatal error: 'AudioUnit/AudioUnit.h' file not found
  /nix/store/y390cqhaxnpzd9fm18l8w7s30rna3603-coreaudio-sys-0.2.11/coreaudio.h:1:10: note: did not find header 'AudioUnit.h' in framework 'AudioUnit' (loaded from '/System/Library/Frameworks')
  thread 'main' panicked at 'unable to generate bindings: ClangDiagnostic("/nix/store/y390cqhaxnpzd9fm18l8w7s30rna3603-coreaudio-sys-0.2.11/coreaudio.h:1:10: fatal error: 'AudioUnit/AudioUnit.h' file not found\n")', /private/tmp/nix-build-bevy-proj-0.1.0.drv-0/cargo-vendor-dir/coreaudio-sys-0.2.11/build.rs:150:39
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I'm on an aarch64-darwin system. The custom build command seems to be trying to query some system audio resources, but I suspect it's failing to do that, due to the nix build environment not having them present. I suspect this is gonna be an issue I can solve by modifying my nix derivation, but as I have no experience with what the crate does nor needs, I would appreciate pointers as to what could be going wrong here.

#

cargo build executes fine however

#

Both in release and debug mode

#

that seems to include a working bevy game derivation

#

the above error seems to be fixed by adding darwin.apple_sdk.frameworks.Cocoa and rustPlatform.bindgenHook to buildInputs of the package