A streamlined template for Bevy game development on NixOS, leveraging direnv and Nix flakes for a seamless setup. Multi-crate structure for better code organization.
- Multi-Crate Structure: Separate
app-bevy
andlib-utils
crates for better organization - Optimized Compilation: Fast linking with LLD
- Nightly Rust: Latest features
- Bevy Enhancements: Dynamic linking and Wayland support
- Nix-Powered: Consistent development environment
git clone https://github.com/drxm1/bevy-project-template-nixos-wayland.git
cd bevy-project-template-nixos-wayland
direnv allow
cargo run -p app-bevy
Cargo.toml
: Workspace configurationapp-bevy/
: Main Bevy application crateCargo.toml
: Bevy app manifestsrc/main.rs
: Main application code
lib-utils/
: Utility crateCargo.toml
: Utils crate manifestsrc/lib.rs
: Utility functions and plugins
.cargo/config.toml
: LLD linker configurationrust-toolchain.toml
: Nightly Rust specificationflake.nix
: Nix development environment definition.envrc
: Direnv configuration for Nix flake
- Nix Flakes: Reproducible development setup
- Direnv: Automatic environment loading
- Rust Nightly: Latest features necessary with our build flags
- Requires Nix and direnv
.direnv
is gitignored- Update
flake.lock
withnix flake update
afterflake.nix
changes
- No WebGPU or web serving capabilities ensured right now, add that yourself
- Designed for local development (well tested in emacs with direnv-mode)
- Clone the repository:
git clone https://github.com/drxm1/bevy-project-template-nixos-wayland.git your-project-name cd your-project-name
- Remove the existing git history:
rm -rf .git
- Initialize a new git repository:
git init
- Update the project name in
Cargo.toml
,app-bevy/Cargo.toml
,lib-utils/Cargo.toml
, andflake.nix
. - Update this README.md with your project details.
- Create your initial commit:
git add . git commit -m "Initial commit: Bevy project setup from template"
- Link to your new GitHub repository:
git remote add origin https://github.com/yourusername/your-project-name.git git branch -M main git push -u origin main
- Start developing your Bevy game!
- For the final release build:
- Refer to the Bevy setup guide for optimal release configurations.
- Note that you'll likely need to build the final version without dynamic linking for better performance and portability.
- Update your
app-bevy/Cargo.toml
to remove thedynamic_linking
feature for release builds:[dependencies] bevy = { version = "0.14.0", features = ["wayland"] } [features] default = ["bevy/wayland"] dev = ["bevy/dynamic_linking"]
- Build your release version with:
cargo build --release --package app-bevy
Remember to customize the flake.nix
if you need additional dependencies for your specific project.
- To run the main application:
cargo run -p app-bevy
or justcargo run
- To run tests for all crates:
cargo test --workspace
- To add a new dependency to the utils crate:
cargo add <dependency> --package lib-utils
- Add more crates to the workspace by updating the root
Cargo.toml
file.