From aa9c1a4829af92ed71118b99381462138816ff2e Mon Sep 17 00:00:00 2001 From: Ryan Yin Date: Wed, 18 Sep 2024 20:25:35 +0800 Subject: [PATCH] feat: add templates for bevy --- templates/bevy/Justfile | 17 +++++++++++++ templates/bevy/flake.nix | 54 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 templates/bevy/Justfile create mode 100644 templates/bevy/flake.nix diff --git a/templates/bevy/Justfile b/templates/bevy/Justfile new file mode 100644 index 00000000..683716f6 --- /dev/null +++ b/templates/bevy/Justfile @@ -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}}" diff --git a/templates/bevy/flake.nix b/templates/bevy/flake.nix new file mode 100644 index 00000000..559d1097 --- /dev/null +++ b/templates/bevy/flake.nix @@ -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; + }; + }); + }; +}