| 27 Apr 2025 |
Ilan Joselevich (Kranzes) | In reply to @adam_neverwas:matrix.org
{
description = "Rust development environment with latest Bevy";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
};
outputs = { self, nixpkgs, flake-utils, rust-overlay }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};
rustToolchain = pkgs.rust-bin.stable.latest.default.override {
extensions = [ "rust-src" "rust-analyzer" "clippy" "rustfmt" ];
targets = [ "wasm32-unknown-unknown" ];
};
graphicsLibs = with pkgs; [
vulkan-loader
xorg.libX11
xorg.libXcursor
xorg.libXrandr
xorg.libXi
libxkbcommon
wayland
libGL
libGLU
xorg.libXext
];
audioLibs = with pkgs; [
alsa-lib
libjack2
libpulseaudio
];
systemLibs = with pkgs; [
udev
systemd
openssl
pkg-config
];
buildLibs = with pkgs; [
cmake
clang
gcc
binutils
lld
];
devTools = with pkgs; [
rustToolchain
rustup
cargo-watch
cargo-expand
cargo-audit
cargo-outdated
cargo-geiger
wasm-pack
];
allLibs = graphicsLibs ++ audioLibs ++ systemLibs;
wrapperScript = pkgs.writeScriptBin "create-wrappers" (builtins.readFile ./wrapper/generate_wrappers.sh);
devEnv = pkgs.mkShell {
buildInputs = devTools ++ buildLibs ++ allLibs ++ [ wrapperScript ];
shellHook = ''
echo "🦀 Rust + Bevy dev environment loading..."
# Find libudev.pc file in the Nix store
LIBUDEV_PC=$(find /nix/store -path "*/lib/pkgconfig/libudev.pc" | head -n 1)
if [ ! -z "$LIBUDEV_PC" ]; then
echo "✅ Found libudev.pc at: $LIBUDEV_PC"
export PKG_CONFIG_PATH=$(dirname "$LIBUDEV_PC"):$PKG_CONFIG_PATH
else
echo "❌ Could not find libudev.pc in Nix store"
fi
export LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath allLibs}:$LD_LIBRARY_PATH
export PKG_CONFIG_PATH=$(IFS=:; echo ${pkgs.lib.concatStringsSep ":" (builtins.map (pkg: "${pkg}/lib/pkgconfig") allLibs)}):$PKG_CONFIG_PATH
# Ensure Rust can find the standard library
export RUST_SRC_PATH=${rustToolchain}/lib/rustlib/src/rust/library
export RUSTFLAGS="-C link-arg=-fuse-ld=lld"
export BEVY_ASSET_ROOT="$(pwd)/assets"
export CC=gcc
export CXX=g++
create-wrappers
PATH="$(echo "$PATH" | sed -e "s#:$HOME/.local/bin##g" -e "s#$HOME/.local/bin:##g" -e "s#$HOME/.local/bin##g")"
# LAST ROW
export PATH="$HOME/.local/bin:$PATH"
echo "✅ Rust + Bevy development environment ready!"
'';
};
in
{
devShells.default = devEnv;
}
);
} I wanna frame this | 18:43:12 |
Ilan Joselevich (Kranzes) | Piece of abstract art | 18:43:25 |
Ilan Joselevich (Kranzes) | Hahaha | 18:43:48 |
Adam Neverwas | theres nothing wrong with this | 18:43:53 |
Ilan Joselevich (Kranzes) | The more i look into it the crazier it is | 18:44:07 |
Adam Neverwas | u sure? | 18:44:16 |
Ilan Joselevich (Kranzes) | Yes | 18:44:45 |
Ilan Joselevich (Kranzes) | Nothing about it makes sense | 18:45:22 |
Adam Neverwas | It's a flake | 18:45:40 |
Ilan Joselevich (Kranzes) | Pure vibe coded hallucination | 18:45:46 |
Adam Neverwas | if you say so | 18:50:50 |
vaw | That find statement is wild. | 18:51:21 |
Adam Neverwas | It can do wild stuff, i tried to find the libudev.pc and place it into the path, this whole nix and flake stuff is new to me, i have to change a bit my thinking | 18:54:27 |
Adam Neverwas | like whats happpening | 18:54:49 |
Adam Neverwas | but i have a lot to do | 18:56:10 |
K900 | Literally none of that is necessary | 18:57:02 |
K900 | Most of it doesn't make any sense | 18:57:27 |
Ilan Joselevich (Kranzes) | just start with something like this | 18:57:56 |
Ilan Joselevich (Kranzes) | {
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
outputs =
inputs:
let
system = "x86_64-linux";
pkgs = inputs.nixpkgs.legacyPackages.${system};
in
{
devShells.${system}.default = pkgs.mkShell {
packages = with pkgs; [
rustc
cargo
];
};
};
}
| 18:57:59 |
K900 | Start with the example shell bevy gives you | 18:58:10 |
K900 | That was linked here earlier | 18:58:13 |
Ilan Joselevich (Kranzes) | understand the fundumentals first | 18:58:18 |
Ilan Joselevich (Kranzes) | no magic | 18:58:21 |
Adam Neverwas | its working now | 18:58:22 |
Adam Neverwas | I mean i have rust-analyzer, finally | 18:58:37 |
@curid:matrix.org | how would one learn the fundamentals? | 18:59:20 |
Ilan Joselevich (Kranzes) | start from scratch | 18:59:44 |
Ilan Joselevich (Kranzes) | write it yourself | 18:59:46 |
Ilan Joselevich (Kranzes) | make sure you understand what each function is | 18:59:54 |
Adam Neverwas | fundumentals first | 18:59:56 |