Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nix build issues on aarch64-darwin #482

Merged
merged 2 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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