From 1b3f400f3f540c2d00c92e1a903ed30e3e9a2a76 Mon Sep 17 00:00:00 2001 From: Dimitris Zervas Date: Sun, 28 Jul 2024 16:24:03 +0300 Subject: [PATCH] Add shell.nix Signed-off-by: Dimitris Zervas --- .vscode/settings.json | 3 ++- shell.nix | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 shell.nix diff --git a/.vscode/settings.json b/.vscode/settings.json index 13323bf..19e638a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,5 @@ { "rust-analyzer.cargo.features": "all", - "rust-analyzer.check.features": "all" + "rust-analyzer.check.features": "all", + "nixEnvSelector.nixFile": "${workspaceFolder}/shell.nix" } diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..a26fe20 --- /dev/null +++ b/shell.nix @@ -0,0 +1,35 @@ +with import {}; +mkShell { + nativeBuildInputs = [ + rustup + cargo-xwin + pkg-config + llvmPackages.libclang + ]; + + # Got from https://discourse.nixos.org/t/setting-up-a-nix-env-that-can-compile-c-libraries/15833 + shellHook = '' + export LIBCLANG_PATH="${llvmPackages.libclang.lib}/lib"; + export BINDGEN_EXTRA_CLANG_ARGS="$(< ${stdenv.cc}/nix-support/libc-crt1-cflags) \ + $(< ${stdenv.cc}/nix-support/libc-cflags) \ + $(< ${stdenv.cc}/nix-support/cc-cflags) \ + $(< ${stdenv.cc}/nix-support/libcxx-cxxflags) \ + ${ + lib.optionalString stdenv.cc.isClang + "-idirafter ${stdenv.cc.cc}/lib/clang/${ + lib.getVersion stdenv.cc.cc + }/include" + } \ + ${ + lib.optionalString stdenv.cc.isGNU + "-isystem ${stdenv.cc.cc}/include/c++/${ + lib.getVersion stdenv.cc.cc + } -isystem ${stdenv.cc.cc}/include/c++/${ + lib.getVersion stdenv.cc.cc + }/${stdenv.hostPlatform.config} -idirafter ${stdenv.cc.cc}/lib/gcc/${stdenv.hostPlatform.config}/${ + lib.getVersion stdenv.cc.cc + }/include" + } \ + " + ''; +}