2 Commits

Author SHA1 Message Date
nervyalloy5
08c7a5efea fix(nix): wrap executable to include correct XKB_CONFIG_ROOT variable 2025-05-22 17:02:15 -04:00
nervyalloy5
b5dcffd7c0 fix(nix): fix nix build
- Update flake.lock
- Switch to correct version of sk_gpu.zip in /nix/sk_gpu.nix
- Add xkeyboard_config and libgbm to dependencies in
  /nix/stardust-xr-server.nix
- Add openxr-loader to github fetches and add it to CPM local packages
2025-05-22 15:21:14 -04:00
8 changed files with 82 additions and 71 deletions

6
Cargo.lock generated
View File

@@ -2620,7 +2620,7 @@ checksum = "2f2b15926089e5526bb2dd738a2eb0e59034356e06eb71e1cd912358c0e62c4d"
[[package]] [[package]]
name = "stardust-xr" name = "stardust-xr"
version = "0.45.0" version = "0.45.0"
source = "git+https://github.com/StardustXR/core.git?branch=dev#bce6ec660f026c577156b3cff41f9312c1caa1d3" source = "git+https://github.com/StardustXR/core.git?branch=dev#d2964d8db079afaadb7faa4987e34814e62d6279"
dependencies = [ dependencies = [
"cluFlock", "cluFlock",
"color-eyre", "color-eyre",
@@ -2641,7 +2641,7 @@ dependencies = [
[[package]] [[package]]
name = "stardust-xr-schemas" name = "stardust-xr-schemas"
version = "1.5.3" version = "1.5.3"
source = "git+https://github.com/StardustXR/core.git?branch=dev#bce6ec660f026c577156b3cff41f9312c1caa1d3" source = "git+https://github.com/StardustXR/core.git?branch=dev#d2964d8db079afaadb7faa4987e34814e62d6279"
dependencies = [ dependencies = [
"flatbuffers", "flatbuffers",
"flexbuffers", "flexbuffers",
@@ -3359,7 +3359,7 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
dependencies = [ dependencies = [
"windows-sys 0.59.0", "windows-sys 0.52.0",
] ]
[[package]] [[package]]

51
flake.lock generated
View File

@@ -26,11 +26,11 @@
"nixpkgs-lib": "nixpkgs-lib" "nixpkgs-lib": "nixpkgs-lib"
}, },
"locked": { "locked": {
"lastModified": 1722555600, "lastModified": 1743550720,
"narHash": "sha256-XOQkdLafnb/p9ij77byFQjDf5m5QYl9b2REiVClC+x4=", "narHash": "sha256-hIshGgKZCgWh6AYJpJmRgFdR3WUbkY04o82X05xqQiY=",
"owner": "hercules-ci", "owner": "hercules-ci",
"repo": "flake-parts", "repo": "flake-parts",
"rev": "8471fe90ad337a8074e957b69ca4d0089218391d", "rev": "c621e8422220273271f52058f618c94e405bb0f5",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -47,11 +47,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1712014858, "lastModified": 1743550720,
"narHash": "sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm+GpZNw=", "narHash": "sha256-hIshGgKZCgWh6AYJpJmRgFdR3WUbkY04o82X05xqQiY=",
"owner": "hercules-ci", "owner": "hercules-ci",
"repo": "flake-parts", "repo": "flake-parts",
"rev": "9126214d0a59633752a136528f5f3b9aa8565b7d", "rev": "c621e8422220273271f52058f618c94e405bb0f5",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -65,11 +65,11 @@
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
}, },
"locked": { "locked": {
"lastModified": 1713050562, "lastModified": 1725868201,
"narHash": "sha256-m7c6XpmpTM1URuqMG2KqtaWbL2Vt8vJFJtmvq123BmY=", "narHash": "sha256-rDBQ9tXQCCA7emikSYH59ADJELE2IpzB7eoLrpHYzU4=",
"owner": "StardustXR", "owner": "StardustXR",
"repo": "flatland", "repo": "flatland",
"rev": "b3b0f29c4ea1b82c96cf9de507837bf15a5e4c0e", "rev": "0914dd3df54a5e6258dfc0a02d65af1c0fc0fc90",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -84,11 +84,11 @@
"nixpkgs": "nixpkgs_2" "nixpkgs": "nixpkgs_2"
}, },
"locked": { "locked": {
"lastModified": 1719226092, "lastModified": 1747284884,
"narHash": "sha256-YNkUMcCUCpnULp40g+svYsaH1RbSEj6s4WdZY/SHe38=", "narHash": "sha256-lTSKhRrassMcJ1ZsuUVunyl/F04vvCKY80HB/4rvvm4=",
"owner": "hercules-ci", "owner": "hercules-ci",
"repo": "hercules-ci-effects", "repo": "hercules-ci-effects",
"rev": "11e4b8dc112e2f485d7c97e1cee77f9958f498f5", "rev": "7168f6002a6b48a9b6151e1e97e974a0722ecfdc",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -115,23 +115,26 @@
}, },
"nixpkgs-lib": { "nixpkgs-lib": {
"locked": { "locked": {
"lastModified": 1722555339, "lastModified": 1743296961,
"narHash": "sha256-uFf2QeW7eAHlYXuDktm9c25OxOyCoUOQmh5SZ9amE5Q=", "narHash": "sha256-b1EdN3cULCqtorQ4QeWgLMrd5ZGOjLSLemfa00heasc=",
"type": "tarball", "owner": "nix-community",
"url": "https://github.com/NixOS/nixpkgs/archive/a5d394176e64ab29c852d03346c1fc9b0b7d33eb.tar.gz" "repo": "nixpkgs.lib",
"rev": "e4822aea2a6d1cdd36653c134cacfd64c97ff4fa",
"type": "github"
}, },
"original": { "original": {
"type": "tarball", "owner": "nix-community",
"url": "https://github.com/NixOS/nixpkgs/archive/a5d394176e64ab29c852d03346c1fc9b0b7d33eb.tar.gz" "repo": "nixpkgs.lib",
"type": "github"
} }
}, },
"nixpkgs_2": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1713714899, "lastModified": 1747179050,
"narHash": "sha256-+z/XjO3QJs5rLE5UOf015gdVauVRQd2vZtsFkaXBq2Y=", "narHash": "sha256-qhFMmDkeJX9KJwr5H32f1r7Prs7XbQWtO0h3V0a0rFY=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "6143fc5eeb9c4f00163267708e26191d1e918932", "rev": "adaa24fbf46737f3f1b5497bf64bae750f82942e",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -143,11 +146,11 @@
}, },
"nixpkgs_3": { "nixpkgs_3": {
"locked": { "locked": {
"lastModified": 1723991338, "lastModified": 1747542820,
"narHash": "sha256-Grh5PF0+gootJfOJFenTTxDTYPidA3V28dqJ/WV7iis=", "narHash": "sha256-GaOZntlJ6gPPbbkTLjbd8BMWaDYafhuuYRNrxCGnPJw=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "8a3354191c0d7144db9756a74755672387b702ba", "rev": "292fa7d4f6519c074f0a50394dbbe69859bb6043",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@@ -3,8 +3,8 @@
let let
sk_gpu_zip = fetchurl { sk_gpu_zip = fetchurl {
url = url =
"https://github.com/StereoKit/sk_gpu/releases/download/v2024.8.16/sk_gpu.v2024.8.16.zip"; "https://github.com/StereoKit/sk_gpu/releases/download/v2024.9.26/sk_gpu.v2024.9.26.zip";
sha256 = "sha256-Wk3PZFlWqhrsQ8xG0sQaV2xSasdg2D7TMiPvl/CgtGU="; sha256 = "sha256-W32RveeCszioWGtbCsvAqB28YHvOsw2xJ15MosYLFXk=";
}; };
in stdenv.mkDerivation rec { in stdenv.mkDerivation rec {
name = "sk_gpu"; name = "sk_gpu";

View File

@@ -6,6 +6,7 @@
, xorg , xorg
, fontconfig , fontconfig
, libxkbcommon , libxkbcommon
, xkeyboard_config
, libclang , libclang
, cmake , cmake
@@ -15,11 +16,13 @@
, fetchFromGitHub , fetchFromGitHub
, sk_gpu , sk_gpu
, libXau , libXau
, libgbm
, libXdmcp , libXdmcp
, stdenv , stdenv
, lib , lib
, openxr-loader , openxr-loader
, makeWrapper
}: }:
rustPlatform.buildRustPackage rec { rustPlatform.buildRustPackage rec {
@@ -47,10 +50,17 @@ rustPlatform.buildRustPackage rec {
rev = "900e40fb5d2502927360fe2f31762bdbb624455f"; rev = "900e40fb5d2502927360fe2f31762bdbb624455f";
sha256 = "sha256-zBRAXgG5Fi6+5uPQCI/RCGatY6O4ELuYBoKrPNn4K+8="; sha256 = "sha256-zBRAXgG5Fi6+5uPQCI/RCGatY6O4ELuYBoKrPNn4K+8=";
}; };
openxr_loader = fetchFromGitHub {
owner = "KhronosGroup";
repo = "OpenXR-SDK";
rev = "288d3a7ebc1ad959f62d51da75baa3d27438c499";
sha256 = "sha256-RdmnBe26hqPmqwCHIJolF6bSmZRmIKVlGF+TXAY35ig=";
};
DEP_MESHOPTIMIZER_SOURCE = "${meshoptimizer}"; DEP_MESHOPTIMIZER_SOURCE = "${meshoptimizer}";
DEP_BASIS_UNIVERSAL_SOURCE = "${basis_universal}"; DEP_BASIS_UNIVERSAL_SOURCE = "${basis_universal}";
DEP_SK_GPU_SOURCE = "${sk_gpu}"; DEP_SK_GPU_SOURCE = "${sk_gpu}";
DEP_OPENXR_LOADER_SOURCE = "${openxr_loader}";
postPatch = let libPath = lib.makeLibraryPath [ stdenv.cc.cc.lib ]; postPatch = let libPath = lib.makeLibraryPath [ stdenv.cc.cc.lib ];
in '' in ''
@@ -69,7 +79,8 @@ rustPlatform.buildRustPackage rec {
--set-rpath "${libPath}" \ --set-rpath "${libPath}" \
$sk/sk_gpu/tools/linux_x64/skshaderc $sk/sk_gpu/tools/linux_x64/skshaderc
''; '';
nativeBuildInputs = [ cmake pkg-config llvmPackages.libcxxClang ];
nativeBuildInputs = [ cmake pkg-config llvmPackages.libcxxClang makeWrapper ];
buildInputs = [ buildInputs = [
libGL libGL
mesa mesa
@@ -78,9 +89,16 @@ rustPlatform.buildRustPackage rec {
xorg.libXfixes xorg.libXfixes
fontconfig fontconfig
libxkbcommon libxkbcommon
xkeyboard_config
libXau libXau
libXdmcp libXdmcp
openxr-loader openxr-loader
libgbm
]; ];
LIBCLANG_PATH = "${libclang.lib}/lib"; LIBCLANG_PATH = "${libclang.lib}/lib";
postFixup = ''
wrapProgram $out/bin/stardust-xr-server \
--set XKB_CONFIG_ROOT "${xkeyboard_config}/share/X11/xkb"
'';
} }

View File

@@ -4,11 +4,7 @@ use super::{
input_method_client, input_method_client,
}; };
use crate::{ use crate::{
core::{ core::{client::Client, error::Result, registry::Registry},
client::Client,
error::{Result, ServerError},
registry::Registry,
},
nodes::{ nodes::{
Node, Node,
alias::{Alias, AliasList}, alias::{Alias, AliasList},
@@ -16,7 +12,6 @@ use crate::{
spatial::Spatial, spatial::Spatial,
}, },
}; };
use color_eyre::eyre::eyre;
use parking_lot::Mutex; use parking_lot::Mutex;
use stardust_xr::values::Datamap; use stardust_xr::values::Datamap;
use std::sync::{Arc, Weak}; use std::sync::{Arc, Weak};
@@ -247,16 +242,7 @@ impl InputMethodRefAspect for InputMethodRef {
let input_handler = handler.get_aspect::<InputHandler>()?; let input_handler = handler.get_aspect::<InputHandler>()?;
input_method.capture_attempts.add_raw(&input_handler); input_method.capture_attempts.add_raw(&input_handler);
Ok(())
let Some(handler_alias) = input_method
.handler_aliases
.get_from_aspect(&*input_handler)
else {
return Err(ServerError::Report(eyre!(
"Internal: Couldn't get handler alias somehow?"
)));
};
input_method_client::request_capture_handler(&node, handler_alias.get_id())
} }
#[doc = "If captured by this handler, release it (e.g. the object is let go of after grabbing)."] #[doc = "If captured by this handler, release it (e.g. the object is let go of after grabbing)."]
@@ -265,15 +251,6 @@ impl InputMethodRefAspect for InputMethodRef {
let input_handler = handler.get_aspect::<InputHandler>()?; let input_handler = handler.get_aspect::<InputHandler>()?;
input_method.capture_attempts.remove(&input_handler); input_method.capture_attempts.remove(&input_handler);
Ok(())
let Some(handler_alias) = input_method
.handler_aliases
.get_from_aspect(&*input_handler)
else {
return Err(ServerError::Report(eyre!(
"Internal: Couldn't get handler alias somehow?"
)));
};
input_method_client::release_handler(&node, handler_alias.get_id())
} }
} }

View File

@@ -47,7 +47,7 @@ impl Root {
pub fn set_transform(&self, transform: Mat4) { pub fn set_transform(&self, transform: Mat4) {
let spatial = self.node.get_aspect::<Spatial>().unwrap(); let spatial = self.node.get_aspect::<Spatial>().unwrap();
// spatial.set_spatial_parent(None).unwrap(); spatial.set_spatial_parent(None).unwrap();
spatial.set_local_transform(transform); spatial.set_local_transform(transform);
} }
pub async fn save_state(&self) -> Result<ClientState> { pub async fn save_state(&self) -> Result<ClientState> {

View File

@@ -192,29 +192,45 @@ impl Spatial {
fn get_parent(&self) -> Option<Arc<Spatial>> { fn get_parent(&self) -> Option<Arc<Spatial>> {
self.parent.lock().clone() self.parent.lock().clone()
} }
fn set_parent(self: &Arc<Self>, new_parent: &Arc<Spatial>) { fn set_parent(self: &Arc<Self>, new_parent: Option<&Arc<Spatial>>) {
if let Some(parent) = self.get_parent() { if let Some(parent) = self.get_parent() {
parent.children.remove(self); parent.children.remove(self);
} }
new_parent.children.add_raw(self); if let Some(new_parent) = &new_parent {
new_parent.children.add_raw(self);
}
*self.parent.lock() = Some(new_parent.clone()); *self.parent.lock() = new_parent.cloned();
} }
pub fn set_spatial_parent(self: &Arc<Self>, parent: &Arc<Spatial>) -> Result<()> { pub fn set_spatial_parent(self: &Arc<Self>, parent: Option<&Arc<Spatial>>) -> Result<()> {
if self.is_ancestor_of(parent.clone()) { let is_ancestor = parent
.as_ref()
.map(|parent| self.is_ancestor_of((*parent).clone()))
.unwrap_or(false);
if is_ancestor {
bail!("Setting spatial parent would cause a loop"); bail!("Setting spatial parent would cause a loop");
} }
self.set_parent(parent); self.set_parent(parent);
Ok(()) Ok(())
} }
pub fn set_spatial_parent_in_place(self: &Arc<Self>, parent: &Arc<Spatial>) -> Result<()> { pub fn set_spatial_parent_in_place(
if self.is_ancestor_of(parent.clone()) { self: &Arc<Self>,
parent: Option<&Arc<Spatial>>,
) -> Result<()> {
let is_ancestor = parent
.as_ref()
.map(|parent| self.is_ancestor_of((*parent).clone()))
.unwrap_or(false);
if is_ancestor {
bail!("Setting spatial parent would cause a loop"); bail!("Setting spatial parent would cause a loop");
} }
self.set_local_transform(Spatial::space_to_space_matrix(Some(self), Some(parent))); self.set_local_transform(Spatial::space_to_space_matrix(
Some(self),
parent.map(AsRef::as_ref),
));
self.set_parent(parent); self.set_parent(parent);
Ok(()) Ok(())
@@ -266,7 +282,7 @@ impl SpatialAspect for Spatial {
let this_spatial = node.get_aspect::<Spatial>()?; let this_spatial = node.get_aspect::<Spatial>()?;
let parent = parent.get_aspect::<Spatial>()?; let parent = parent.get_aspect::<Spatial>()?;
this_spatial.set_spatial_parent(&parent)?; this_spatial.set_spatial_parent(Some(&parent))?;
Ok(()) Ok(())
} }
@@ -278,7 +294,7 @@ impl SpatialAspect for Spatial {
let this_spatial = node.get_aspect::<Spatial>()?; let this_spatial = node.get_aspect::<Spatial>()?;
let parent = parent.get_aspect::<Spatial>()?; let parent = parent.get_aspect::<Spatial>()?;
this_spatial.set_spatial_parent_in_place(&parent)?; this_spatial.set_spatial_parent_in_place(Some(&parent))?;
Ok(()) Ok(())
} }

View File

@@ -45,10 +45,7 @@ pub fn release(spatial: &Spatial) {
}; };
let spatial = spatial_node.get_aspect::<Spatial>().unwrap(); let spatial = spatial_node.get_aspect::<Spatial>().unwrap();
let Some(old_parent) = spatial.old_parent.lock().take() else { let _ = spatial.set_spatial_parent_in_place(spatial.old_parent.lock().take().as_ref());
return;
};
let _ = spatial.set_spatial_parent_in_place(&old_parent);
let mut spatial_zone = spatial.zone.lock(); let mut spatial_zone = spatial.zone.lock();
if let Some(spatial_zone) = spatial_zone.upgrade() { if let Some(spatial_zone) = spatial_zone.upgrade() {