-
-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NixOS support - Detecting XR Hardware But Not Creating or Modifying Inputs #38
Comments
Wow, this is interesting. I'm not familiar with Nix so this isn't something I would tackle until I've achieved some of my longer term goals and had time to dig into it. A couple things I see:
So your |
Thanks for the rapid response! I appreciate this usecase isn't something you currently support so I'm grateful for the suggestions. I had a little more time tonight to play with this but didn't solve it yet.
I can confirm it's happily idle and not crashing. It seems to be oblivious to the world! Based on your suggestion to poke around
After that, next time I started the service the logs were:
But given this error is from I'll have another think about next steps for debugging |
@wheaney I had a bit of time this morning to have another play with this. It still doesn't create a device for I changed the CMake build type from
At this point, if it's running under
The segfault seems to be from I found if I first If I start the driver before connecting hardware I get:
If I start the driver after connecting hardware it will error and restart a few times with
As far as I know, there isn't any human input and at this point it should Just Work? if you do have a moment to think about where this might be going wrong or what I might look at next that would be appreciated! |
I had a poke around today to get it running on NixOS and since it is set up for an immutable OS it should run on Nix. I would rather avoid doing a "proper" install the Nix way until this project is stable (and I learn more about that since I am a Nix newb) The first issue I had was that the setup script for the shader uses chown and assumes the normal distro setup where a user is in a group named after their username. In Nix the group is called "users". Once I fixed this the driver setup script failed when it checked for systemd using the command: "ps -p 1 -o comm=" which should work but does not with the following output:
I will have another look tomorrow as I have some other things to do right now. I had a few more minutes and tried to manually copy files and run as root but got: Edit: this method will not work as the binary is looking for libraries (glibc) in specific spots, and Nix is not a standard directory tree. Will have to do this properly I guess, lol |
This is the last version I was testing. The only thing this is missing is the new
{ lib
, stdenv
, fetchgit
, cmake
, pkg-config
# deps
, systemd
, json_c
, libevdev
, libusb
, hidapi
}:
stdenv.mkDerivation rec {
pname = "xr-linux-driver";
version = "0.6.1-beta";
src = (fetchgit {
url = "https://github.com/wheaney/XRLinuxDriver";
rev = "0f74025ccee6d9017f07e39db9bcdacfaac7e134";
sha256 = "sha256-fpIxNiMW8IelrNMuHtOPePIxeI1sxUNigZq5f/CqjyA=";
fetchSubmodules = true;
}).overrideAttrs (_: {
GIT_CONFIG_COUNT = 1;
GIT_CONFIG_KEY_0 = "url.https://gitlab.com/.insteadOf";
GIT_CONFIG_VALUE_0 = "[email protected]:";
});
buildInputs = [
systemd
json_c
libevdev
libusb
hidapi
];
nativeBuildInputs = [
pkg-config
cmake
];
dontStrip = true;
outputs = [ "out" ];
patches = [
./install.patch
./unlink-hidapi.patch
];
meta = with lib; {
description = "Custom user-space Linux driver for XR devices";
homepage = "https://github.com/wheaney/XRLinuxDriver";
license = licenses.mit;
platforms = platforms.linux;
maintainers = [ "wheaney" ];
};
}
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9d55cec..dbd8c5b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -55,4 +55,6 @@ target_include_directories(xrealAirLinuxDriver
target_link_libraries(xrealAirLinuxDriver
PRIVATE ${LIBEVDEV_LIBRARIES} nrealAirLibrary Threads::Threads m ${VITURE_LIB_NAME} ${LIBUSB_LIBRARY}
-)
\ No newline at end of file
+)
+
+install(TARGETS xrealAirLinuxDriver DESTINATION bin)
diff --git a/modules/xrealInterfaceLibrary/.gitmodules b/modules/xrealInterfaceLibrary/.gitmodules
index 8696ec6..2b8a1a0 100644
--- a/modules/xrealInterfaceLibrary/.gitmodules
+++ b/modules/xrealInterfaceLibrary/.gitmodules
@@ -1,6 +1,3 @@
[submodule "interface_lib/modules/Fusion"]
path = interface_lib/modules/Fusion
url = https://github.com/xioTechnologies/Fusion.git
-[submodule "interface_lib/modules/hidapi"]
- path = interface_lib/modules/hidapi
- url = https://github.com/libusb/hidapi.git
diff --git a/modules/xrealInterfaceLibrary/interface_lib/CMakeLists.txt b/modules/xrealInterfaceLibrary/interface_lib/CMakeLists.txt
index 1fc3449..e57fdfb 100644
--- a/modules/xrealInterfaceLibrary/interface_lib/CMakeLists.txt
+++ b/modules/xrealInterfaceLibrary/interface_lib/CMakeLists.txt
@@ -5,7 +5,7 @@ set(CMAKE_C_STANDARD 17)
find_package(json-c REQUIRED CONFIG)
-add_subdirectory(modules/hidapi)
+find_package(hidapi REQUIRED)
add_subdirectory(modules/Fusion/Fusion)
add_library(
@@ -25,7 +25,6 @@ target_include_directories(nrealAirLibrary
target_include_directories(nrealAirLibrary
SYSTEM BEFORE PRIVATE
- ${CMAKE_CURRENT_SOURCE_DIR}/modules/hidapi
${CMAKE_CURRENT_SOURCE_DIR}/modules/Fusion
) Build it with: nix-build -E 'let pkgs = import <nixpkgs> { }; in pkgs.callPackage ./default.nix {}' The binary will be available in To create the systemd.services.xr-linux-driver = {
enable = true;
description = "xr-linux-driver";
after = [ "network.target" ];
serviceConfig = {
Type = "simple";
Environment = "HOME=/tmp/xr-linux-driver";
ExecStart = "/nix/store/j3rf49f3b06cni2ynyrz94alqmhp6z3d-xr-linux-driver-0.6.1-beta/bin/xrealAirLinuxDriver";
Restart = "on-failure";
PrivateNetwork = "true";
# PrivateTmp = "true";
};
wantedBy = [ "multi-user.target" ];
};
boot.kernelModules = [ "uinput" ]; You can optionally change the build type to get more noise in logs: diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9d55cec..305d468 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,14 +1,15 @@
cmake_minimum_required(VERSION 3.16)
project(xrealAirLinuxDriver C)
-set(CMAKE_BUILD_TYPE Release)
+#set(CMAKE_BUILD_TYPE Release)
+set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_C_STANDARD 17)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
find_package(LIBEVDEV REQUIRED)
find_package(LIBUSB REQUIRED)
set(VITURE_LIB_NAME viture_sdk) I am unable to get the original binary from releases to work on my SteamDeck since I updated the firmware of my glasses so I'm unable to confirm how well this actually works. My glasses are fine otherwise, and I can read data from them without issue, just this software never does anything after connecting to the glasses. |
First, thanks @xM8WVqaG for the above info and @wheaney for the great work here!. This has been an amazing learning process! I compiled the driver (haven't touched the shader stuff yet) and it works! The only issue I had is just like xM8WVqaG I have to restart the service after plugging in the glasses or it does not work and the logs continue to show:
I will have a look at the shader next (maybe not tonight) and see how that goes Here is a section of the log where things started up:
|
Interesting, can you confirm which window manager or desktop environment you're using? Was it X11 or Wayland? I've never actually managed to get |
I am using Hyprland on Wayland |
@xM8WVqaG In trying to replicate your work the install.patch seems to be malformed. |
it's not surprising the patches no longer cleanly apply, given they were written for 0.6.1-beta which was 95 commits ago. It was building and mostly running on the older version, as @canguy247 managed to reproduce. But it didn't seem to properly handle hardware disconnects or reconnects. Right now I've no interest in picking this work back up as I went back to using Monado. Given the project has matured since my first test and a bunch of the stuff I had to patch in this issue has already been upstreamed (the GitLab auth, the scuffed CMake, the hardcoded directories) you should start without any patches and only apply what's necessary. I intended to upstream those but ran out of time before I managed a complete e2e test. |
Not sure how much this helps the NixOS work, but this driver has recently been added to AUR, which involved cleaning up the install process, put everything into XDG dirs, making it possible to run as a user process (was always root before), etc... Here's the PKGBUILD file that shows everything |
I have a build that seems to start. |
Derived from @only1thor's work for NixOS, but tidied up, rebased, and squashed by @shymega (me). See: only1thor#2 wheaney/XRLinuxDriver#38 Signed-off-by: Dom Rodriguez <[email protected]>
I've got it building based on @only1thor's branch. If someone could test the build from my Nixpkgs fork, that would be useful:
If it's OK with OP and others, I would like to submit the package to Nixpkgs. Then I can submit a package for Breezy too. |
Dang that would be amazing if someone else can confirm and help work out any last kinks. It would be helpful too if you could write up some maintenance details, how to get the latest updates out to Nix, etc... |
@shymega Awesome! 🤩 |
Regarding maintenence. |
Tested your branch @shymega, and it has the same issue i had on mine. I have an Xreal Air 1. Here are the logs annotated what i was doing while things changed:
the run above seemed stable but most attempts have crashed the driver with the following error in the logs:
and running |
Derived from @only1thor's work for NixOS, but tidied up, rebased, and squashed by @shymega (me). See: only1thor#2 wheaney/XRLinuxDriver#38 Signed-off-by: Dom Rodriguez <[email protected]>
@only1thor Can you try again, please? If it doesn't download the new version, try this one:
If this also fails - I don't have a VITURE pair yet - then we may need some output from Valgrind/gdb. If you want to ping/DM me on Discord feel free - same username as here. |
@only1thor In fact, can you try this:
Then, run Thanks :) EDIT: Got the command wrong. |
I received my VITUREs recently, and can confirm there are no longer any segfaults. I am going to test the user systemd service too, but I've opened a PR in the meantime - #80. |
Derived from @only1thor's work for NixOS, but tidied up, rebased, and squashed by @shymega (me). See: only1thor#2 wheaney/XRLinuxDriver#38 Signed-off-by: Dom Rodriguez <[email protected]>
Derived from @only1thor's work for NixOS, but tidied up, rebased, and squashed by @shymega (me). See: only1thor#2 wheaney/XRLinuxDriver#38 Signed-off-by: Dom Rodriguez <[email protected]>
Derived from @only1thor's work for NixOS, but tidied up, rebased, and squashed by @shymega (me). See: only1thor#2 wheaney/XRLinuxDriver#38 Signed-off-by: Dom Rodriguez <[email protected]>
Derived from @only1thor's work for NixOS, but tidied up, rebased, and squashed by @shymega (me). See: only1thor#2 wheaney/XRLinuxDriver#38 Signed-off-by: Dom Rodriguez <[email protected]>
Derived from @only1thor's work for NixOS, but tidied up, rebased, fixed, and squashed by @shymega. See: only1thor#2 wheaney/XRLinuxDriver#38 Co-authored-by: Dom Rodriguez <[email protected]>
Derived from @only1thor's work for NixOS, but tidied up, rebased, fixed, and squashed by @shymega. See: only1thor#2 wheaney/XRLinuxDriver#38 Co-authored-by: Dom Rodriguez <[email protected]>
Derived from @only1thor's work for NixOS, but tidied up, rebased, fixed, and squashed by @shymega. See: only1thor#2 wheaney/XRLinuxDriver#38 Co-authored-by: Dom Rodriguez <[email protected]>
This commit consists of the following changes: - `default.nix`/`shell.nix` This allows for legacy Nix tooling like `nix-build`/`nix-shell` to work. - `flake.nix` This is for the (new) Nix Flake support. - `flake.lock` As above, but for tracking Flake inputs. - `.envrc` This allows for a fully self-contained developer environment to be setup with Nix. - `nix/default.nix` This is the main package derivation. Both this repo & Nixpkgs are derived from the same codebase. Closes: wheaney#38
This commit consists of the following changes: - `default.nix`/`shell.nix` This allows for legacy Nix tooling like `nix-build`/`nix-shell` to work. - `flake.nix` This is for the (new) Nix Flake support. - `flake.lock` As above, but for tracking Flake inputs. - `.envrc` This allows for a fully self-contained developer environment to be setup with Nix. - `nix/default.nix` This is the main package derivation. Both this repo & Nixpkgs are derived from the same codebase. Closes: wheaney#38
Derived from @only1thor's work for NixOS, but tidied up, rebased, fixed, and squashed by @shymega. See: only1thor#2 wheaney/XRLinuxDriver#38 Co-authored-by: Dom Rodriguez <[email protected]>
Derived from @only1thor's work for NixOS, but tidied up, rebased, fixed, and squashed by @shymega. See: only1thor#2 wheaney/XRLinuxDriver#38 Co-authored-by: Dom Rodriguez <[email protected]>
Derived from @only1thor's work for NixOS, but tidied up, rebased, fixed, and squashed by @shymega. See: only1thor#2 wheaney/XRLinuxDriver#38 Co-authored-by: Dom Rodriguez <[email protected]>
Derived from @only1thor's work for NixOS, but tidied up, rebased, fixed, and squashed by @shymega. See: only1thor#2 wheaney/XRLinuxDriver#38 Co-authored-by: Dom Rodriguez <[email protected]>
Derived from @only1thor's work for NixOS, but tidied up, rebased, fixed, and squashed by @shymega. See: only1thor#2 wheaney/XRLinuxDriver#38 Co-authored-by: Dom Rodriguez <[email protected]>
Derived from @only1thor's work for NixOS, but tidied up, rebased, fixed, and squashed by @shymega. See: only1thor#2 wheaney/XRLinuxDriver#38 Co-authored-by: Dom Rodriguez <[email protected]>
This looked like an interesting project so I had a go at building it on NixOS. Seeing as SteamOS added a
/nix
directory in 3.5.5 NixPkg might be an interesting way of deploying this in the future! Because of how Nix works, your existing install and packaging scripts wouldn't work.For this test, I was trying to get XRLinuxDriver running on my laptop using sway 1.8.1, Linux 6.1.69 and with xreal Air 1.
The Nix derivation (build script) is basically just checking out the repo & dependencies and running
cmake
- it looks like:The patch applied is to
CMakeLists.txt
to addinstall
targets to the output:This runs fine as far as I can tell, the compiled binary executes and creates
.xreal_driver_{log,config,lock}
, although it only ever logs:modprobe
was run elsewhere:This is the slightly modified
service
to work around the hardcoded~
and not actually having a writable home:I can see that it's managing to create a device:
But it identifies as a
keyboard
. I've done before and after lists oflibinput
and it can only see one new device being created.I've tried changing the
output_mode=mouse
tooutput_mode=joystick
and the driver can see the change, but that doesn't change the detected device.Any ideas?
EDIT: I've just read this back and it's not super clear what I'm asking. The
Vendor Air
does appear to be from the glasses itself, rather than the user-mode driver. So I guess this is more of a question around the behaviour ofXRLinuxDriver
, and what the correct behaviour is supposed to be at this point. Presumably they should be calledXR virtual {joystick,mouse}
based on:outputs.c
The text was updated successfully, but these errors were encountered: