summaryrefslogtreecommitdiff
path: root/modules/templates/rustBevy/README.md
blob: 33752ea658e6255781f1f01edc1420949b67a592 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# Rust + Bevy Development Environment

A reproducible Rust development environment for building applications and games with **Bevy**.

This flake provides a complete toolchain, common native dependencies for Bevy on Linux, and a preconfigured development shell.

## Features

* Latest stable Rust toolchain via **Fenix**
* **rust-analyzer** for editor integration
* **Crane** for reproducible package builds
* **Clang + Mold** for significantly faster linking
* Vulkan, Wayland, X11, ALSA, and udev libraries required by most Bevy projects
* Ready to use with `nix develop`

## Included Software

### Rust Toolchain

* Stable Rust
* Cargo
* Rustfmt
* Clippy
* rust-analyzer

### Build Tools

* Clang
* Mold linker
* pkg-config

### Native Libraries

* Vulkan Loader
* Wayland
* libxkbcommon
* X11
* Xcursor
* Xi
* Xrandr
* ALSA
* udev

These libraries cover the requirements for most Bevy applications without additional setup.

## Usage

Enter the development environment:

```bash
nix develop
```

Build the project:

```bash
cargo build
```

Run the project:

```bash
cargo run
```

Run with release optimizations:

```bash
cargo run --release
```

## Building with Nix

Build the project as a Nix package:

```bash
nix build
```

Run the packaged application:

```bash
nix run
```

The flake uses **Crane** to build your crate in a reproducible manner.

## Linker Configuration

The development environment uses:

* **Clang** as the linker driver
* **Mold** as the linker

This is configured automatically through:

```text
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=clang
RUSTFLAGS="-C link-arg=-fuse-ld=mold"
```

Using Mold can dramatically reduce link times, which is especially useful during game development.

## Editor Support

The included `rust-analyzer` integrates automatically with editors such as:

* Neovim
* Helix
* VS Code
* Zed
* Emacs

No additional Rust installation is required.

## Project Layout

This template assumes a standard Cargo project:

```text
.
├── Cargo.toml
├── Cargo.lock
├── flake.nix
└── src/
    └── main.rs
```

## Customization

Depending on your project, you may wish to extend the development shell with additional tools such as:

* `trunk` for WebAssembly targets
* `lldb` or `gdb` for debugging
* `cargo-nextest`
* `cargo-watch`
* `cargo-deny`
* `cargo-flamegraph`

Additional system libraries can also be added to `buildInputs` if your project depends on them.

## Notes

This template is primarily intended for Linux Bevy development. It includes the native dependencies commonly required for windowing, graphics, input, and audio. Basic Darwin support is included where applicable, but additional configuration may be necessary for macOS-specific projects.