diff options
author | Julian Stecklina <julian.stecklina@cyberus-technology.de> | 2024-10-24 15:25:19 +0200 |
---|---|---|
committer | Julian Stecklina <julian.stecklina@cyberus-technology.de> | 2024-10-24 15:25:29 +0200 |
commit | e7f823a612927a0adb8de688095d19e35d9c1ddc (patch) | |
tree | 201c1b59963d299a67ae4f1b263909326e57289e | |
parent | e3f1a09f0cfc1d2a792516fb52d061e15b2fedb6 (diff) |
Match bindgen with clang version
Otherwise, Linux complains:
*** libclang (used by the Rust bindings generator 'bindgen')
*** version does not match Clang's. This may be a problem.
*** libclang version: 18.1.8
*** Clang version: 19.1.1
-rw-r--r-- | flake.nix | 49 |
1 files changed, 28 insertions, 21 deletions
@@ -67,7 +67,7 @@ rust-analyzer = fenix.packages."${system}".rust-analyzer; - linuxRustDependencies = rustVersion: + linuxRustDependencies = { clang, rustVersion }: let rustc = rust-overlay.packages."${system}"."${rustVersion}".override { extensions = [ @@ -83,7 +83,7 @@ }; bindgenUnwrapped = pkgs.callPackage ./bindgen/0.65.1.nix { - inherit rustPlatform; + inherit rustPlatform clang; }; bindgen = pkgs.rust-bindgen.override { @@ -106,25 +106,32 @@ NIX_HARDENING_ENABLE = ""; }; - mkClangShell = { clangVersion, rustcVersion }: pkgs.mkShell { - packages = - (with pkgs."llvmPackages_${clangVersion}"; - [ - bintools - llvm - clang - ]) - ++ (linuxRustDependencies "rust_${rustcVersion}") - ++ linuxCommonDependencies; - - # To force LLVM build mode. This should create less problems - # with Rust interop. - LLVM = "1"; - - # Disable all automatically applied hardening. The Linux - # kernel will take care of itself. - NIX_HARDENING_ENABLE = ""; - }; + mkClangShell = { clangVersion, rustcVersion }: + let + llvmPackages = pkgs."llvmPackages_${clangVersion}"; + in + pkgs.mkShell { + packages = + (with llvmPackages; + [ + bintools + llvm + clang + ]) + ++ (linuxRustDependencies { + inherit (llvmPackages) clang; + rustVersion = "rust_${rustcVersion}"; + }) + ++ linuxCommonDependencies; + + # To force LLVM build mode. This should create less problems + # with Rust interop. + LLVM = "1"; + + # Disable all automatically applied hardening. The Linux + # kernel will take care of itself. + NIX_HARDENING_ENABLE = ""; + }; in { packages = { |