feat: add templates for bevy

This commit is contained in:
Ryan Yin
2024-09-18 20:25:35 +08:00
parent 7438aa04ea
commit aa9c1a4829
2 changed files with 71 additions and 0 deletions

17
templates/bevy/Justfile Normal file
View File

@@ -0,0 +1,17 @@
default:
@just --list
# Auto-format the source tree
fmt:
treefmt
# Run 'cargo run' on the project
drun *ARGS:
nix develop --command cargo run {{ARGS}}
dbuild:
nix develop --command cargo build
# Run 'cargo watch' to run the project (auto-recompiles)
watch *ARGS:
cargo watch -x "run -- {{ARGS}}"

54
templates/bevy/flake.nix Normal file
View File

@@ -0,0 +1,54 @@
# https://github.com/bevyengine/bevy/blob/v0.14.2/docs/linux_dependencies.md#nix
{
description = "Bevy Game Engine - Rust Lang";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
nixpkgs,
rust-overlay,
...
}: let
systems = [
"x86_64-linux"
"aarch64-linux"
];
# Helper function to generate a set of attributes for each system
forAllSystems = func: (nixpkgs.lib.genAttrs systems func);
in {
devShells = forAllSystems (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [(import rust-overlay)];
};
lib = pkgs.lib;
in {
default = pkgs.mkShell rec {
nativeBuildInputs = with pkgs; [
pkg-config
];
buildInputs = with pkgs; [
udev
alsa-lib
vulkan-loader
xorg.libX11
xorg.libXcursor
xorg.libXi
xorg.libXrandr # To use the x11 feature
libxkbcommon
wayland # To use the wayland feature
# rust toolchain
rust-analyzer
];
LD_LIBRARY_PATH = lib.makeLibraryPath buildInputs;
};
});
};
}