Skip to content

swagtop/bevy-flake

Repository files navigation

bevy-flake

A flake for painless development and distribution of Bevy programs.

With bevy-flake you can easily configure, compile and run your project on NixOS and MacOS, as well as cross-compile portable binaries for WASM, and non-Nix Linux, Windows, MacOS targets.

Note

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

Quick 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

Switching later is very easy, and you should very easily be able to use any other toolchain provider not listed here. More on this here.

This flake is equipped with flake-compat, should you be a non-flake user.

How to use

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.

About

A flake for painless development and distribution of Bevy programs.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages