Files
bevy-template/flake.nix

119 lines
3.1 KiB
Nix

{
description = "Bevy + local AI game dev template for macOS with Nix";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
};
outputs =
{
self,
nixpkgs,
flake-utils,
rust-overlay,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
};
lib = pkgs.lib;
rustToolchain = pkgs.rust-bin.stable."1.95.0".default.override {
extensions = [
"rust-src"
"rustfmt"
"clippy"
"rust-analyzer"
];
targets = [
"wasm32-unknown-unknown"
];
};
linuxLibs = lib.optionals pkgs.stdenv.isLinux (
with pkgs;
[
alsa-lib
libudev-zero
vulkan-loader
wayland
libxkbcommon
xorg.libX11
xorg.libXcursor
xorg.libXi
xorg.libXrandr
]
);
in
{
devShells.default = pkgs.mkShell {
packages =
with pkgs;
[
rustToolchain
pkg-config
clang
cmake
git
just
bacon
cargo-edit
cargo-watch
cargo-nextest
nil
nixd
taplo
imagemagick
pngquant
ffmpeg
jq
fd
ripgrep
tree
python3
nodejs_22
libiconv
]
++ linuxLibs;
shellHook = ''
export RUST_SRC_PATH="${rustToolchain}/lib/rustlib/src/rust/library"
export LIBCLANG_PATH="${pkgs.llvmPackages.libclang.lib}/lib"
export CARGO_INCREMENTAL=1
export RUST_BACKTRACE=1
export BEVY_ASSET_ROOT="$PWD/assets"
if [ "$(uname)" = "Darwin" ]; then
if ! xcode-select -p >/dev/null 2>&1; then
echo 'error: Xcode Command Line Tools missing. Run: xcode-select --install'
else
export SDKROOT="$(xcrun --sdk macosx --show-sdk-path 2>/dev/null || true)"
fi
fi
mkdir -p assets ai/context
echo "Bevy + AI shell ready"
echo "rustc: $(rustc --version)"
echo "cargo: $(cargo --version)"
echo "node: $(node --version)"
# Keep user prompt/plugins by switching interactive sessions to system zsh.
# This does not affect `nix develop -c ...` non-interactive commands.
if [ -n "''${PS1:-}" ] && [ -z "''${ZSH_VERSION:-}" ] && [ -z "''${IN_NIX_DEVELOP_SYSTEM_ZSH:-}" ] && [ -x /bin/zsh ]; then
export IN_NIX_DEVELOP_SYSTEM_ZSH=1
export SHELL=/bin/zsh
exec /bin/zsh -i
fi
'';
};
}
);
}