summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKjetil Orbekk <kj@orbekk.com>2023-11-19 12:14:40 -0500
committerKjetil Orbekk <kj@orbekk.com>2023-11-19 17:34:59 -0500
commitec985c98d61ec96bebf0ba068cf5e88fa13b2f40 (patch)
treef90724de0875b825cf7d38e46c4c416b4f1da761
parentc15c33dbbe82cd05d2f952bbb98d72b41be7eedf (diff)
bevy
-rw-r--r--bevy/.envrc1
-rw-r--r--bevy/flake.nix71
2 files changed, 72 insertions, 0 deletions
diff --git a/bevy/.envrc b/bevy/.envrc
new file mode 100644
index 0000000..3550a30
--- /dev/null
+++ b/bevy/.envrc
@@ -0,0 +1 @@
+use flake
diff --git a/bevy/flake.nix b/bevy/flake.nix
new file mode 100644
index 0000000..4fb6ce7
--- /dev/null
+++ b/bevy/flake.nix
@@ -0,0 +1,71 @@
+{
+ inputs = {
+ nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
+ rust-overlay.url = "github:oxalica/rust-overlay";
+ };
+
+ outputs = { self, nixpkgs, rust-overlay }:
+ let
+ overlays = [ (import rust-overlay) ];
+ pkgs = import nixpkgs {
+ inherit system overlays;
+ };
+
+ system = "x86_64-linux";
+ app = "game";
+
+ rust = pkgs.rust-bin.nightly.latest.default.override { extensions = [ "rust-src" ]; };
+ rustPlatform = pkgs.makeRustPlatform { cargo = rust; rustc = rust; };
+
+ shellInputs = with pkgs; [
+ rust clang mold
+ ];
+ appNativeBuildInputs = with pkgs; [
+ pkg-config
+ ];
+ appBuildInputs = appRuntimeInputs ++ (with pkgs; [
+ udev alsaLib x11
+ vulkan-tools vulkan-headers vulkan-validation-layers
+ ]);
+ appRuntimeInputs = with pkgs; [
+ vulkan-loader
+ xlibs.libXcursor xlibs.libXi xlibs.libXrandr
+ ];
+ in
+ {
+ devShells.${system}.${app} = pkgs.mkShell {
+ nativeBuildInputs = appNativeBuildInputs;
+ buildInputs = shellInputs ++ appBuildInputs;
+
+ shellHook = ''
+ export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${pkgs.lib.makeLibraryPath appRuntimeInputs}"
+ ln -fsT ${rust} ./.direnv/rust
+ '';
+ };
+ devShell.${system} = self.devShells.${system}.${app};
+
+ packages.${system}.${app} = rustPlatform.buildRustPackage {
+ pname = app;
+ version = "0.1.0";
+
+ src = ./.;
+ cargoSha256 = "sha256-lzs+8qAsBJ/ms/OppxnKfJChV9+xM0W/QRZGPn+9uv4=";
+
+ nativeBuildInputs = appNativeBuildInputs;
+ buildInputs = appBuildInputs;
+
+ postInstall = ''
+ cp -r assets $out/bin/
+ '';
+ };
+ defaultPackage.${system} = self.packages.${system}.${app};
+
+ apps.${system}.${app} = {
+ type = "app";
+ program = "${self.packages.${system}.${app}}/bin/${app}";
+ };
+ defaultApp.${system} = self.apps.${system}.${app};
+
+ checks.${system}.build = self.packages.${system}.${app};
+ };
+}