From 9869ab4a85d42720ac2d2709ac115dc0b8e0b847 Mon Sep 17 00:00:00 2001 From: Zhaofeng Li Date: Mon, 6 Feb 2023 13:54:21 -0700 Subject: [PATCH] Temporary workaround to fix bindgen on Darwin https://github.com/NixOS/nixpkgs/pull/207352#issuecomment-1418363441 --- crane.nix | 8 +++++++- package.nix | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/crane.nix b/crane.nix index 7fd888a..e53363b 100644 --- a/crane.nix +++ b/crane.nix @@ -8,6 +8,7 @@ { stdenv , lib , craneLib +, llvmPackages , rustPlatform , runCommand , writeReferencesToFile @@ -32,7 +33,6 @@ let }; nativeBuildInputs = [ - rustPlatform.bindgenHook pkg-config installShellFiles ]; @@ -68,6 +68,12 @@ let cargoExtraArgs = "-p attic-client -p attic-server"; + # Temporary workaround for https://github.com/NixOS/nixpkgs/pull/207352#issuecomment-1418363441 + preBuild = '' + export LIBCLANG_PATH="${llvmPackages.libclang.lib}/lib" + export BINDGEN_EXTRA_CLANG_ARGS="$(< ${llvmPackages.clang}/nix-support/cc-cflags) $(< ${llvmPackages.clang}/nix-support/libc-cflags) $(< ${llvmPackages.clang}/nix-support/libcxx-cxxflags) $NIX_CFLAGS_COMPILE" + ''; + postInstall = lib.optionalString (stdenv.hostPlatform == stdenv.buildPlatform) '' if [[ -f $out/bin/attic ]]; then installShellCompletion --cmd attic \ diff --git a/package.nix b/package.nix index bc3c53f..2303449 100644 --- a/package.nix +++ b/package.nix @@ -7,6 +7,7 @@ { lib, stdenv, rustPlatform , pkg-config , installShellFiles +, llvmPackages , nix , boost , darwin @@ -31,7 +32,6 @@ in rustPlatform.buildRustPackage rec { }; nativeBuildInputs = [ - rustPlatform.bindgenHook pkg-config installShellFiles ]; @@ -50,6 +50,12 @@ in rustPlatform.buildRustPackage rec { ATTIC_DISTRIBUTOR = "attic"; + # Temporary workaround for https://github.com/NixOS/nixpkgs/pull/207352#issuecomment-1418363441 + preBuild = '' + export LIBCLANG_PATH="${llvmPackages.libclang.lib}/lib" + export BINDGEN_EXTRA_CLANG_ARGS="$(< ${llvmPackages.clang}/nix-support/cc-cflags) $(< ${llvmPackages.clang}/nix-support/libc-cflags) $(< ${llvmPackages.clang}/nix-support/libcxx-cxxflags) $NIX_CFLAGS_COMPILE" + ''; + # Recursive Nix is not stable yet doCheck = false;