Skip to content
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

ultraleap-hand-tracking: init #310138

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions nixos/doc/manual/release-notes/rl-2505.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@

- [duckdns](https://www.duckdns.org), free dynamic DNS. Available with [services.duckdns](options.html#opt-services.duckdns.enable)

- [Ultraleap Hand Tracking](https://docs.ultraleap.com/), a userspace driver for Ultraleap Motion Controller hardware. Available as [services.ultraleap](#opt-services.ultraleap.enable) and integrates into Monado as [services.monado.enableUltraleap](#opt-services.monado.enableUltraleap)

- [nostr-rs-relay](https://git.sr.ht/~gheartsfield/nostr-rs-relay/), This is a nostr relay, written in Rust. Available as [services.nostr-rs-relay](options.html#opt-services.nostr-rs-relay.enable).

- [Actual Budget](https://actualbudget.org/), a local-first personal finance app. Available as [services.actual](#opt-services.actual.enable).
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/module-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@
./services/hardware/tuxedo-rs.nix
./services/hardware/udev.nix
./services/hardware/udisks2.nix
./services/hardware/ultraleap.nix
./services/hardware/undervolt.nix
./services/hardware/upower.nix
./services/hardware/usbmuxd.nix
Expand Down
12 changes: 11 additions & 1 deletion nixos/modules/services/hardware/monado.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ in
options.services.monado = {
enable = mkEnableOption "Monado user service";

package = mkPackageOption pkgs "monado" { };
package =
mkPackageOption pkgs "monado" { }
// mkOption {
apply = pkg: pkg.override { ultraleapSupport = cfg.enableUltraleap; };
};

defaultRuntime = mkOption {
type = types.bool;
Expand Down Expand Up @@ -52,6 +56,8 @@ in
highPriority =
mkEnableOption "high priority capability for monado-service"
// mkOption { default = true; };

enableUltraleap = mkEnableOption "Ultraleap hand tracking Monado driver and system service";
};

config = mkIf cfg.enable {
Expand All @@ -66,6 +72,10 @@ in

services.udev.packages = with pkgs; [ xr-hardware ];

services.ultraleap = mkIf cfg.enableUltraleap {
enable = mkDefault true;
};

systemd.user = {
services.monado = {
description = "Monado XR runtime service module";
Expand Down
75 changes: 75 additions & 0 deletions nixos/modules/services/hardware/ultraleap.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
config,
lib,
pkgs,
...
}:
let
inherit (lib)
getExe'
mkDefault
mkEnableOption
mkIf
mkPackageOption
;

cfg = config.services.ultraleap;
in
{
options.services.ultraleap = {
enable = mkEnableOption "Ultraleap hand tracking service";

servicePackage = mkPackageOption pkgs "ultraleap-hand-tracking-service" { };
layerPackage = mkPackageOption pkgs "openxr-ultraleap-layer" { };
};

config = mkIf cfg.enable {
services.udev.packages = [ cfg.servicePackage ];

systemd.tmpfiles.settings."10-ultraleap"."/etc/ultraleap".d = {
user = "leap";
group = "leap";
mode = "0755";
};

systemd.services."ultraleap-hand-tracking-service" = {
description = "Ultraleap Tracking Service";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];

environment = {
"LIBTRACK_IS_SERVICE" = mkDefault "1";
};

serviceConfig = {
Type = "exec";
ExecStart = getExe' cfg.servicePackage "leapd";
User = "leap";
Group = "leap";
KillMode = "process";
KillSignal = "SIGINT";
Restart = "on-failure";
LogsDirectory = "leap";
};
};

environment.systemPackages = [
cfg.servicePackage
cfg.layerPackage
];
environment.pathsToLink = [ "/share/openxr" ];

users.users.leap = {
isSystemUser = true;
group = "leap";
# udev rules from -service grant access to plugdev
extraGroups = [ "plugdev" ];
};
users.groups.leap = { };
};

meta.maintainers = with lib.maintainers; [
Scrumplex
pandapip1
];
}
6 changes: 5 additions & 1 deletion pkgs/by-name/mo/monado/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
zlib,
zstd,
nixosTests,
ultraleap-hand-tracking-service,
cudaPackages,
enableCuda ? config.cudaSupport,
# Set as 'false' to build monado without service support, i.e. allow VR
Expand All @@ -62,6 +63,7 @@
# https://gitlab.freedesktop.org/monado/monado/-/blob/master/doc/targets.md#xrt_feature_service-disabled
serviceSupport ? true,
tracingSupport ? false,
ultraleapSupport ? false,
}:

stdenv.mkDerivation (finalAttrs: {
Expand All @@ -88,7 +90,6 @@ stdenv.mkDerivation (finalAttrs: {
# - DRIVER_DEPTHAI - Needs depthai-core https://github.com/luxonis/depthai-core (See https://github.com/NixOS/nixpkgs/issues/292618)
# - DRIVER_ILLIXR - needs ILLIXR headers https://github.com/ILLIXR/ILLIXR (See https://github.com/NixOS/nixpkgs/issues/292661)
# - DRIVER_ULV2 - Needs proprietary Leapmotion SDK https://api.leapmotion.com/documentation/v2/unity/devguide/Leap_SDK_Overview.html (See https://github.com/NixOS/nixpkgs/issues/292624)
# - DRIVER_ULV5 - Needs proprietary Leapmotion SDK https://api.leapmotion.com/documentation/v2/unity/devguide/Leap_SDK_Overview.html (See https://github.com/NixOS/nixpkgs/issues/292624)

buildInputs =
[
Expand Down Expand Up @@ -136,6 +137,9 @@ stdenv.mkDerivation (finalAttrs: {
]
++ lib.optionals tracingSupport [
tracy
]
++ lib.optionals ultraleapSupport [
ultraleap-hand-tracking-service
];

patches = [
Expand Down
62 changes: 62 additions & 0 deletions pkgs/by-name/op/openxr-ultraleap-layer/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
autoPatchelfHook,
dpkg,
fetchurl,
lib,
stdenv,
systemdLibs,
ultraleap-hand-tracking-service,
}:
stdenv.mkDerivation (finalAttrs: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might make sense to use stdenvNoCC here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are already pulling in stdenv.cc.cc in buildInputs, so we wouldn't really gain anything from using stdenvNoCC here.

pname = "openxr-layer-ultraleap";
version = "1.6.5+2486adf9.CI1130164";

src = fetchurl {
url = "https://repo.ultraleap.com/apt/pool/main/o/openxr-layer-ultraleap/openxr-layer-ultraleap_1.6.5%2B2486adf9.CI1130164_amd64.deb";
hash = "sha256-OWPJCk55DNnuA8kUmzqG0FIChSnbwBQhWRBUripM7Yo=";
};

nativeBuildInputs = [
autoPatchelfHook
dpkg
];

buildInputs = [
stdenv.cc.cc
systemdLibs
ultraleap-hand-tracking-service
];

strictDeps = true;

dontBuild = true;

installPhase = ''
runHook preInstall

install -d "$out/lib"
cp -Tr "usr/lib/openxr-layer-ultraleap" "$out/lib"

install -d "$out/share/doc"
cp -Tr "usr/share/doc" "$out/share/doc"

local layer_path="share/openxr/1/api_layers/implicit.d/XrApiLayer_Ultraleap.json"
install -Dm644 "usr/$layer_path" "$out/$layer_path"
substituteInPlace "$out/$layer_path" \
--replace-fail \
"/usr/lib/openxr-layer-ultraleap/libUltraleapHandTracking.so.1.6.5.0" \
"$out/lib/libUltraleapHandTracking.so.1.6.5.0"

runHook postInstall
'';

meta = {
description = "Ultraleap Hand Tracking OpenXR layer";
license = lib.licenses.unfree;
platforms = [ "x86_64-linux" ];
maintainers = with lib.maintainers; [
Scrumplex
pandapip1
];
};
})
101 changes: 101 additions & 0 deletions pkgs/by-name/ul/ultraleap-hand-tracking-control-panel/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
addDriverRunpath,
autoPatchelfHook,
dbus,
dpkg,
fetchurl,
lib,
libGL,
libxkbcommon,
makeBinaryWrapper,
stdenv,
udev,
ultraleap-hand-tracking-service,
vulkan-loader,
wayland,
xorg,
zlib,
}:
stdenv.mkDerivation {
pname = "ultraleap-hand-tracking-control-panel";
version = "3.4.1";

src = fetchurl {
url = "https://repo.ultraleap.com/apt/pool/main/u/ultraleap-hand-tracking-control-panel/ultraleap-hand-tracking-control-panel_1125862.deb";
hash = "sha256-Pli0ENEtzBQGvfo2nIf09b62Xt3gzML/QYXMwtrD+7Y=";
};

nativeBuildInputs = [
autoPatchelfHook
dpkg
makeBinaryWrapper
];

buildInputs = [
dbus
libGL
libxkbcommon
stdenv.cc.cc
udev
ultraleap-hand-tracking-service
vulkan-loader
wayland
xorg.libX11
xorg.libXScrnSaver
xorg.libXcursor
xorg.libXext
xorg.libXi
xorg.libXinerama
xorg.libXrandr
xorg.libXxf86vm
zlib
];

strictDeps = true;

dontBuild = true;

runtimeDependencies = [
"libGL.so.1"
"libLeapC.so"
"libX11.so.6"
"libXcursor.so.1"
"libXext.so.6"
"libXi.so.6"
"libXinerama.so.1"
"libXrandr.so.2"
"libXss.so.1"
"libXxf86vm.so.1"
"libdbus-1.so.3"
"libudev.so.1"
"libvulkan.so.1"
"libwayland-client.so.0"
"libwayland-cursor.so.0"
"libwayland-egl.so.1"
"libxkbcommon.so.0"
];

installPhase = ''
runHook preInstall

mkdir -p $out/bin $out/share $out/opt
cp -Tr usr/share $out/share
cp -Tr opt $out/opt

makeWrapper $out/opt/ultraleap-hand-tracking-control-panel/ultraleap-hand-tracking-control-panel $out/bin/ultraleap-hand-tracking-control-panel \
--prefix LD_LIBRARY_PATH : "${addDriverRunpath.driverLink}/lib"

runHook postInstall
'';

meta = {
description = "Ultraleap Hand Tracking control panel";
license = lib.licenses.unfree;
platforms = [ "x86_64-linux" ];
maintainers = with lib.maintainers; [
Scrumplex
pandapip1
];
mainProgram = "ultraleap-hand-tracking-control-panel";
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
diff --git a/usr/lib/ultraleap-hand-tracking-service/cmake/LeapCTargets-release.cmake b/usr/lib/ultraleap-hand-tracking-service/cmake/LeapCTargets-release.cmake
index be4fe4e..f3f5bba 100644
--- a/usr/lib/ultraleap-hand-tracking-service/cmake/LeapCTargets-release.cmake
+++ b/usr/lib/ultraleap-hand-tracking-service/cmake/LeapCTargets-release.cmake
@@ -8,12 +8,12 @@ set(CMAKE_IMPORT_FILE_VERSION 1)
# Import target "LeapSDK::LeapC" for configuration "release"
set_property(TARGET LeapSDK::LeapC APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(LeapSDK::LeapC PROPERTIES
- IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/ultraleap-hand-tracking-service/libLeapC.so.5"
+ IMPORTED_LOCATION_RELEASE "@out@/lib/libLeapC.so.5"
IMPORTED_SONAME_RELEASE "libLeapC.so.5"
)

list(APPEND _IMPORT_CHECK_TARGETS LeapSDK::LeapC )
-list(APPEND _IMPORT_CHECK_FILES_FOR_LeapSDK::LeapC "${_IMPORT_PREFIX}/lib/ultraleap-hand-tracking-service/libLeapC.so.5" )
+list(APPEND _IMPORT_CHECK_FILES_FOR_LeapSDK::LeapC "@out@/lib/libLeapC.so.5" )

# Commands beyond this point should not need to know the version.
set(CMAKE_IMPORT_FILE_VERSION)
diff --git a/usr/lib/ultraleap-hand-tracking-service/cmake/LeapCTargets.cmake b/usr/lib/ultraleap-hand-tracking-service/cmake/LeapCTargets.cmake
index 7a30c2e..38e335c 100644
--- a/usr/lib/ultraleap-hand-tracking-service/cmake/LeapCTargets.cmake
+++ b/usr/lib/ultraleap-hand-tracking-service/cmake/LeapCTargets.cmake
@@ -54,7 +54,7 @@ endif()
add_library(LeapSDK::LeapC SHARED IMPORTED)

set_target_properties(LeapSDK::LeapC PROPERTIES
- INTERFACE_INCLUDE_DIRECTORIES "/usr/include"
+ INTERFACE_INCLUDE_DIRECTORIES "@dev@/include"
INTERFACE_LINK_LIBRARIES "atomic"
)

diff --git a/usr/lib/x86_64-linux-gnu/cmake/LeapSDK/leapsdk-config.cmake b/usr/lib/x86_64-linux-gnu/cmake/LeapSDK/leapsdk-config.cmake
index f74639b..c46805d 100644
--- a/usr/lib/x86_64-linux-gnu/cmake/LeapSDK/leapsdk-config.cmake
+++ b/usr/lib/x86_64-linux-gnu/cmake/LeapSDK/leapsdk-config.cmake
@@ -12,4 +12,4 @@ if(IS_DIRECTORY ${PACKAGE_PREFIX_DIR}/lib/x64 OR
set(_arch_folder x64)
endif()

-include(/usr/lib/ultraleap-hand-tracking-service//${_arch_folder}/cmake/LeapCTargets.cmake)
+include(@dev@/lib/cmake/LeapCTargets.cmake)
Loading