dorkhub

bevy-flake

A flake for development and distribution of Bevy programs.

swagtop
Nix601 forksMIT-0updated 1 day ago
git clone https://github.com/swagtop/bevy-flake.gitswagtop/bevy-flake

bevy-flake

A flake for development and distribution of Bevy programs.

This flake provides a pre-configured Nix environment for Bevy development, and enables you to cross-compile release-ready portable binaries for platforms like non-Nix Linux, MacOS1, Windows and WASM.

Note

By compiling to the Windows MSVC targets, you are accepting the Microsoft Software License Terms.

Setup

Navigate to your Bevy project root, then pull the template with the toolchain from your favourite provider:

# The one using oxalica's rust-overlay:
nix flake init --template github:swagtop/bevy-flake#rust-overlay
# The one using nix-community's fenix:
nix flake init --template github:swagtop/bevy-flake#fenix
# The one from nixpkgs with no cross-compilation, but no extra inputs:
nix flake init --template github:swagtop/bevy-flake#nixpkgs

The packages this flake provides can also be imported and configured by non-flake users. Read more about this here.

Usage

Add the packages you want from bevy-flake to your environment with nix develop, with nix shell, or any other means.

Then, you can use them like so:

# With 'rust-toolchain', run and compile both for yours and other platforms:
# For your Nix system you can run:
cargo build
cargo run

# For other targets, just use '--target':
cargo build --target wasm32-unknown-unknown
cargo build --target x86_64-pc-windows-msvc
cargo build --target aarch64-apple-darwin # <-- Please read docs/macos.md.
# With `dioxus-cli`, develop Bevy with hot-patching:
BEVY_ASSET_ROOT="." dx serve --hot-patch --features bevy/hotpatching
# With `bevy-cli`, use the alpha CLI tooling:
# For your Nix system you can run:
bevy run

# Like cargo, build for other targets with '--target':
bevy build --target aarch64-pc-windows-msvc

# For web builds, you can also run and bundle them like so:
bevy run web --open
bevy build web --bundle

The packages come with a develop attribute, which are versions of the same package, with only the dependencies needed for developing and compiling for the host system included. It can be accessed with <package>.develop, and is the default version of the packages included in the template flakes.

If you've set the src config attribute to the path of your project, you can build it using Nix:

# Build all targets:
nix build .#targets --max-jobs 1 # Restricting builds to one target at a time.

# Build individual targets:
nix build .#targets.x86_64-unknown-linux-gnu

# Build individual targets, fetching only the dependencies for the specific one:
nix build .#targets.x86_64-unknown-linux-gnu.only

# Build your project from any machine with access to your repo:
nix build github:username/repository/branch#targets --max-jobs 1

You can compile to every target with a targetEnvironments entry. If the target you want isn't in the default configuration, you can add it yourself by setting its environment up. More on that here.

Footnotes

  1. For MacOS builds you need to set up the SDK. This takes no more than 5 minutes. Read the MacOS docs for the guide on how to do this.

more like this

anne-key

Firmware for Anne Pro Keyboard written in Rust

Rust572

TachiSnap

TachiSnap — Pixel Snapper for animation pixel artists. Rust + WebAssembly client-side tool for cleaning up AI-generated…

HTML50

bit_gossip

Pathfinding library for calculating all node pairs' shortest paths in an unweighted undirected graph.

Rust50

search

search projects, people, and tags