added nix flake and started actions

This commit is contained in:
awtterpip
2024-03-22 21:19:43 -05:00
parent 05e7f2a9a8
commit 6f5aa468c8
9 changed files with 243 additions and 51 deletions

1
.envrc.example Normal file
View File

@@ -0,0 +1 @@
use flake

2
.gitignore vendored
View File

@@ -3,3 +3,5 @@
**/runtime_libs/arm64-v8a/* **/runtime_libs/arm64-v8a/*
.vscode .vscode
\.DS_Store \.DS_Store
.envrc
.direnv

View File

View File

@@ -8,6 +8,7 @@ use bevy_xr::camera::XrCameraPlugin;
use init::XrInitPlugin; use init::XrInitPlugin;
use render::XrRenderPlugin; use render::XrRenderPlugin;
pub mod actions;
pub mod camera; pub mod camera;
pub mod error; pub mod error;
pub mod extensions; pub mod extensions;

View File

@@ -93,6 +93,7 @@ pub fn init_views(
)); ));
views.push(default()); views.push(default());
} }
commands.spawn(XrCameraBundle::default());
commands.insert_resource(XrViews(views)); commands.insert_resource(XrViews(views));
} }

View File

@@ -1,53 +1,46 @@
// //! A simple 3D scene with light shining over a cube sitting on a plane. //! A simple 3D scene with light shining over a cube sitting on a plane.
// use bevy::{prelude::*, render::camera::RenderTarget}; use bevy::prelude::*;
// use bevy_oxr::openxr::{render::LEFT_XR_TEXTURE_HANDLE, DefaultXrPlugins};
// fn main() { fn main() {
// App::new() App::new()
// .add_plugins(DefaultXrPlugins) .add_plugins(DefaultPlugins)
// .add_systems(Startup, setup) .add_systems(Startup, setup)
// .run(); .run();
// } }
// /// set up a simple 3D scene /// set up a simple 3D scene
// fn setup( fn setup(
// mut commands: Commands, mut commands: Commands,
// mut meshes: ResMut<Assets<Mesh>>, mut meshes: ResMut<Assets<Mesh>>,
// mut materials: ResMut<Assets<StandardMaterial>>, mut materials: ResMut<Assets<StandardMaterial>>,
// ) { ) {
// // circular base // circular base
// commands.spawn(PbrBundle { commands.spawn(PbrBundle {
// mesh: meshes.add(Circle::new(4.0)), mesh: meshes.add(Circle::new(4.0)),
// material: materials.add(Color::WHITE), material: materials.add(Color::WHITE),
// transform: Transform::from_rotation(Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)), transform: Transform::from_rotation(Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)),
// ..default() ..default()
// }); });
// // cube // cube
// commands.spawn(PbrBundle { commands.spawn(PbrBundle {
// mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)), mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)),
// material: materials.add(Color::rgb_u8(124, 144, 255)), material: materials.add(Color::rgb_u8(124, 144, 255)),
// transform: Transform::from_xyz(0.0, 0.5, 0.0), transform: Transform::from_xyz(0.0, 0.5, 0.0),
// ..default() ..default()
// }); });
// // light // light
// commands.spawn(PointLightBundle { commands.spawn(PointLightBundle {
// point_light: PointLight { point_light: PointLight {
// shadows_enabled: true, shadows_enabled: true,
// ..default() ..default()
// }, },
// transform: Transform::from_xyz(4.0, 8.0, 4.0), transform: Transform::from_xyz(4.0, 8.0, 4.0),
// ..default() ..default()
// }); });
// // camera // camera
// commands.spawn(Camera3dBundle { commands.spawn(Camera3dBundle {
// transform: Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y), transform: Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y),
// camera: Camera { ..default()
// target: RenderTarget::TextureView(LEFT_XR_TEXTURE_HANDLE), });
// ..default() }
// },
// ..default()
// });
// }
fn main() {}

100
flake.lock generated Normal file
View File

@@ -0,0 +1,100 @@
{
"nodes": {
"fenix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1711088506,
"narHash": "sha256-USdlY7Tx2oJWqFBpp10+03+h7eVhpkQ4s9t1ERjeIJE=",
"owner": "nix-community",
"repo": "fenix",
"rev": "85f4139f3c092cf4afd9f9906d7ed218ef262c97",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "fenix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1711001935,
"narHash": "sha256-URtGpHue7HHZK0mrHnSf8wJ6OmMKYSsoLmJybrOLFSQ=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "20f77aa09916374aa3141cbc605c955626762c9a",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"fenix": "fenix",
"nixpkgs": "nixpkgs",
"utils": "utils"
}
},
"rust-analyzer-src": {
"flake": false,
"locked": {
"lastModified": 1711052942,
"narHash": "sha256-lLsAhLgm/Nbin41wdfGKU7Rgd6ONBxYCUAMv53NXPjo=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "7ef7f442fc34b5eadb1c6ad6433bd6d0c51b056b",
"type": "github"
},
"original": {
"owner": "rust-lang",
"ref": "nightly",
"repo": "rust-analyzer",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

90
flake.nix Normal file
View File

@@ -0,0 +1,90 @@
{
description = "bevy xr flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
# eachDefaultSystem and other utility functions
utils.url = "github:numtide/flake-utils";
# Replacement for rustup
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
self,
nixpkgs,
utils,
fenix,
}:
# This helper function abstracts over the host platform.
# See https://github.com/numtide/flake-utils#eachdefaultsystem--system---attrs
utils.lib.eachDefaultSystem (
system: let
pkgs = nixpkgs.legacyPackages.${system};
# Brings in the rust toolchain from the standard file
# that rustup/cargo uses.
rustToolchain = fenix.packages.${system}.fromToolchainFile {
file = ./rust-toolchain.toml;
sha256 = "sha256-+syqAd2kX8KVa8/U2gz3blIQTTsYYt3U63xBWaGOSc8=";
};
rustPlatform = pkgs.makeRustPlatform {
inherit (rustToolchain) cargo rustc;
};
in
# See https://nixos.wiki/wiki/Flakes#Output_schema
{
# `nix develop` pulls all of this in to become your shell.
devShells.default = pkgs.mkShell rec {
nativeBuildInputs = with pkgs; [
rustToolchain
pkg-config
# Common cargo tools we often use
cargo-deny
cargo-expand
cargo-binutils
# cmake for openxr
cmake
];
# see https://github.com/NixOS/nixpkgs/blob/95b81c96f863ca8911dffcda45d1937efcd66a4b/pkgs/games/jumpy/default.nix#L60C5-L60C38
buildInputs =
[
pkgs.zstd
]
++ pkgs.lib.optionals pkgs.stdenv.isLinux (with pkgs; [
# bevy dependencies
udev
alsa-lib
# vulkan
vulkan-loader
vulkan-headers
vulkan-tools
vulkan-validation-layers
# x11
xorg.libX11
xorg.libXcursor
xorg.libXi
xorg.libXrandr
# wayland
libxkbcommon
wayland
])
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
pkgs.darwin.apple_sdk.frameworks.Cocoa
rustPlatform.bindgenHook
# # This is missing on mac m1 nix, for some reason.
# # see https://stackoverflow.com/a/69732679
pkgs.libiconv
];
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;
# this is most likely not needed. for some reason shadows flicker without it.
AMD_VULKAN_ICD = "RADV";
};
# This only formats the nix files.
formatter = pkgs.nixpkgs-fmt;
}
);
}

4
rust-toolchain.toml Normal file
View File

@@ -0,0 +1,4 @@
[toolchain]
channel = "1.77.0"
components = ["rust-src", "rust-analyzer"]
profile = "default"