Skip to content

Commit

Permalink
Fix nix build issues on aarch64-darwin (#482)
Browse files Browse the repository at this point in the history
  • Loading branch information
Trevor Bernard authored Feb 20, 2024
1 parent eb38d5e commit 81dcbe8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 33 deletions.
14 changes: 7 additions & 7 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 10 additions & 26 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
rust-overlay.url = "github:oxalica/rust-overlay";
flake-utils.url = "github:numtide/flake-utils";
flake-compat = {
Expand Down Expand Up @@ -37,45 +37,30 @@

frameworks = pkgs.darwin.apple_sdk.frameworks;

llvm = pkgs.llvmPackages_14;
clang = llvm.clang;
libclang = llvm.libclang;

buildDependencies = with pkgs;
[
libclang
buildDependencies = with pkgs; [
libclang.lib
clang
pkg-config
]
rustPlatform.bindgenHook]
++ runtimeDependencies
++ lib.optionals stdenv.isDarwin
[
++ lib.optionals stdenv.isDarwin [
frameworks.Security
frameworks.CoreServices
];

developmentDependencies = with pkgs;
[
rust
rnix-lsp
alejandra
cargo-nextest
cargo-audit
cargo-machete
bacon
google-cloud-sdk
just
jq # Used in testing.
git # Needed but not declared by Nix's 'stdenv' build.
]
++ buildDependencies;

LIBCLANG_PATH = "${libclang.lib}/lib";
BINDGEN_EXTRA_CLANG_ARGS =
if pkgs.stdenv.isDarwin
then "-isystem ${pkgs.stdenv.cc.cc}/lib/clang/${pkgs.lib.getVersion pkgs.stdenv.cc.cc}/include"
else "-isystem ${libclang.lib}/lib/clang/${pkgs.lib.getVersion clang}/include";

cargo-toml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
in
with pkgs; {
Expand All @@ -92,23 +77,22 @@
nativeBuildInputs = buildDependencies;
buildInputs = runtimeDependencies;

preBuild = ''
export LIBCLANG_PATH="${LIBCLANG_PATH}"
export BINDGEN_EXTRA_CLANG_ARGS="${BINDGEN_EXTRA_CLANG_ARGS}"
env = { LIBCLANG_PATH = "${libclang.lib}/lib"; } //
(lib.optionalAttrs (stdenv.cc.isClang && stdenv.isDarwin) { NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}"; });

'';
doCheck = false;
};

default = mina-indexer;
};

devShells.default = mkShell {
env = { LIBCLANG_PATH = "${libclang.lib}/lib"; } //
(lib.optionalAttrs (stdenv.cc.isClang && stdenv.isDarwin) { NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}"; });

buildInputs = developmentDependencies;
shellHook = ''
git submodule update --init --recursive
export LIBCLANG_PATH="${LIBCLANG_PATH}"
export BINDGEN_EXTRA_CLANG_ARGS="${BINDGEN_EXTRA_CLANG_ARGS}"
export TMPDIR=/var/tmp
'';
};
Expand Down

0 comments on commit 81dcbe8

Please sign in to comment.