From d5a59de447de67d2ca09f3aab45a146af9352a29 Mon Sep 17 00:00:00 2001 From: hkalbasi Date: Wed, 29 Nov 2023 20:13:49 +0330 Subject: [PATCH] Fix nix build --- c2rust-ast-exporter/build.rs | 10 ++++++++-- shell.nix => default.nix | 7 +++++-- 2 files changed, 13 insertions(+), 4 deletions(-) rename shell.nix => default.nix (53%) diff --git a/c2rust-ast-exporter/build.rs b/c2rust-ast-exporter/build.rs index 39743b083b..bc29a7be2f 100644 --- a/c2rust-ast-exporter/build.rs +++ b/c2rust-ast-exporter/build.rs @@ -127,8 +127,14 @@ fn build_native(llvm_info: &LLVMInfo) { // Build libclangAstExporter.a with cmake let dst = Config::new("src") // Where to find LLVM/Clang CMake files - .define("LLVM_DIR", &format!("{}/cmake/llvm", llvm_lib_dir)) - .define("Clang_DIR", &format!("{}/cmake/clang", llvm_lib_dir)) + .define( + "LLVM_DIR", + &env::var("CMAKE_LLVM_DIR").unwrap_or(format!("{}/cmake/llvm", llvm_lib_dir)), + ) + .define( + "Clang_DIR", + &env::var("CMAKE_CLANG_DIR").unwrap_or(format!("{}/cmake/clang", llvm_lib_dir)), + ) // What to build .build_target("clangAstExporter") .build(); diff --git a/shell.nix b/default.nix similarity index 53% rename from shell.nix rename to default.nix index 4b52603e75..cf6bbada8e 100644 --- a/shell.nix +++ b/default.nix @@ -1,5 +1,5 @@ let - nixpkgs = import {}; + nixpkgs = import { }; inherit (nixpkgs) pkgs llvmPackages; stdenv = pkgs.clangStdenv; in @@ -9,11 +9,14 @@ stdenv.mkDerivation { pkgs.clang pkgs.cmake pkgs.llvm + pkgs.libllvm pkgs.openssl pkgs.pkgconfig pkgs.python3 pkgs.rustup pkgs.zlib ]; - LIBCLANG_PATH="${llvmPackages.libclang}/lib"; + LIBCLANG_PATH = "${pkgs.libclang.lib}/lib"; + CMAKE_LLVM_DIR = "${llvmPackages.libllvm.dev}/lib/cmake/llvm"; + CMAKE_CLANG_DIR = "${llvmPackages.libclang.dev}/lib/cmake/clang"; }