summaryrefslogtreecommitdiff
path: root/modules/templates/rustBevy/flake.nix
diff options
context:
space:
mode:
Diffstat (limited to 'modules/templates/rustBevy/flake.nix')
-rw-r--r--modules/templates/rustBevy/flake.nix83
1 files changed, 83 insertions, 0 deletions
diff --git a/modules/templates/rustBevy/flake.nix b/modules/templates/rustBevy/flake.nix
new file mode 100644
index 0000000..1d7d862
--- /dev/null
+++ b/modules/templates/rustBevy/flake.nix
@@ -0,0 +1,83 @@
+{
+ description = "Rust dev env flake for Bevy development";
+ inputs = {
+ nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
+ crane.url = "github:ipetkov/crane";
+ fenix = {
+ url = "github:nix-community/fenix";
+ inputs.nixpkgs.follows = "nixpkgs";
+ };
+ flake-utils.url = "github:numtide/flake-utils";
+ };
+ outputs = {
+ self,
+ nixpkgs,
+ crane,
+ fenix,
+ flake-utils,
+ ...
+ }:
+ flake-utils.lib.eachDefaultSystem (system: let
+ pkgs = nixpkgs.legacyPackages.${system};
+
+ rs-toolchain = with fenix.packages.${system};
+ combine [
+ default.toolchain
+ rust-analyzer
+ ];
+
+ craneLib = (crane.mkLib pkgs).overrideToolchain rs-toolchain;
+
+ my-crate = craneLib.buildPackage {
+ src = craneLib.cleanCargoSource (craneLib.path ./.);
+ strictDeps = true;
+ buildInputs = with pkgs;
+ [
+ udev
+ alsa-lib
+ vulkan-loader
+ libX11
+ libXcursor
+ libXi
+ libXrandr
+ libxkbcommon
+ wayland
+ ]
+ ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
+ pkgs.libiconv
+ ];
+ nativeBuildInputs = with pkgs; [
+ pkg-config
+ mold
+ clang
+ ];
+ CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER = "clang";
+ RUSTFLAGS = "-C link-arg=-fuse-ld=mold";
+ };
+ in {
+ packages.default = my-crate;
+ apps.default = flake-utils.lib.mkApp {
+ drv = my-crate;
+ };
+ devShells.default = pkgs.mkShell rec {
+ buildInputs = with pkgs; [
+ rs-toolchain
+ pkg-config
+ udev
+ alsa-lib
+ vulkan-loader
+ libX11
+ libXcursor
+ libXi
+ libXrandr
+ libxkbcommon
+ wayland
+ mold
+ clang
+ ];
+ LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;
+ CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER = "clang";
+ RUSTFLAGS = "-C link-arg=-fuse-ld=mold";
+ };
+ });
+}