Devops stuff
This commit is contained in:
43
shell.nix
Normal file
43
shell.nix
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
}:
|
||||
|
||||
let
|
||||
# First, select the rust toolchain attribute set from pkgs.
|
||||
# This set contains cargo, rustc, rust-std, rust-src, etc.
|
||||
# Using `pkgs.rust-toolchain` will select the default stable toolchain.
|
||||
rust-toolchain = pkgs.rust-toolchain;
|
||||
in
|
||||
pkgs.mkShell {
|
||||
# nativeBuildInputs are tools you run on your machine during development.
|
||||
nativeBuildInputs = with pkgs; [
|
||||
# 1. Add the main toolchain components (cargo, rustc).
|
||||
rust-toolchain
|
||||
|
||||
# 2. Add the Rust standard library for our specific WebAssembly target.
|
||||
# We get `rust-std` from the `rust-toolchain` set we defined above
|
||||
# to guarantee version consistency.
|
||||
(rust-toolchain.rust-std.override {
|
||||
targets = [ "wasm32-unknown-unknown" ];
|
||||
})
|
||||
|
||||
# 3. Add the other necessary tools.
|
||||
wasm-bindgen-cli
|
||||
bun
|
||||
clang # Recommended linker for wasm on NixOS
|
||||
pkg-config
|
||||
openssl
|
||||
];
|
||||
|
||||
# Environment variables that will be set when you enter the shell.
|
||||
shellHook = ''
|
||||
# Set the linker for the wasm target to avoid potential issues.
|
||||
export CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_LINKER="${pkgs.clang}/bin/clang"
|
||||
|
||||
# Set the path to the Rust standard library source code.
|
||||
# This is used by tools like rust-analyzer for "go to definition", etc.
|
||||
export RUST_SRC_PATH="${rust-toolchain}/lib/rustlib/src/rust/library"
|
||||
|
||||
echo "✅ Nix shell is ready with Rust (wasm target), wasm-bindgen, and Bun."
|
||||
'';
|
||||
}
|
||||
Reference in New Issue
Block a user