From 1a720b362b176857de364b817f48e95068c8c5fe Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Wed, 8 May 2024 17:05:00 +0200 Subject: [PATCH 1/6] ultraleap-hand-tracking-control-panel: init at 3.4.1 Signed-off-by: Sefa Eyeoglu --- .../package.nix | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 pkgs/by-name/ul/ultraleap-hand-tracking-control-panel/package.nix diff --git a/pkgs/by-name/ul/ultraleap-hand-tracking-control-panel/package.nix b/pkgs/by-name/ul/ultraleap-hand-tracking-control-panel/package.nix new file mode 100644 index 0000000000000..2262612b7efc3 --- /dev/null +++ b/pkgs/by-name/ul/ultraleap-hand-tracking-control-panel/package.nix @@ -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"; + }; +} From 450780cb341ac386ea28ef257a92b9cf39c17b73 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Wed, 8 May 2024 17:36:27 +0200 Subject: [PATCH 2/6] ultraleap-hand-tracking-service: init at 5.17.1.0 Signed-off-by: Sefa Eyeoglu --- .../fix-cmake-paths.patch | 42 +++++++++ .../package.nix | 85 +++++++++++++++++++ 2 files changed, 127 insertions(+) create mode 100644 pkgs/by-name/ul/ultraleap-hand-tracking-service/fix-cmake-paths.patch create mode 100644 pkgs/by-name/ul/ultraleap-hand-tracking-service/package.nix diff --git a/pkgs/by-name/ul/ultraleap-hand-tracking-service/fix-cmake-paths.patch b/pkgs/by-name/ul/ultraleap-hand-tracking-service/fix-cmake-paths.patch new file mode 100644 index 0000000000000..8f7ce95811c5d --- /dev/null +++ b/pkgs/by-name/ul/ultraleap-hand-tracking-service/fix-cmake-paths.patch @@ -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) diff --git a/pkgs/by-name/ul/ultraleap-hand-tracking-service/package.nix b/pkgs/by-name/ul/ultraleap-hand-tracking-service/package.nix new file mode 100644 index 0000000000000..8bb4526554080 --- /dev/null +++ b/pkgs/by-name/ul/ultraleap-hand-tracking-service/package.nix @@ -0,0 +1,85 @@ +{ + autoPatchelfHook, + dpkg, + fetchurl, + lib, + stdenv, + udev, +}: +stdenv.mkDerivation { + pname = "ultraleap-hand-tracking-service"; + version = "5.17.1.0"; + + src = fetchurl { + url = "https://repo.ultraleap.com/apt/pool/main/u/ultraleap-hand-tracking-service/ultraleap-hand-tracking-service_5.17.1.0-a9f25232-1.0_amd64.deb"; + hash = "sha256-nZFi5NEzrPf0MMDoEnzDPILaLLtwDx7gTt7/X6uY4OQ="; + }; + + nativeBuildInputs = [ + autoPatchelfHook + dpkg + ]; + + buildInputs = [ + stdenv.cc.cc + udev + ]; + + strictDeps = true; + + patches = [ + ./fix-cmake-paths.patch + ]; + + dontBuild = true; + + outputs = [ + "out" + "dev" + ]; + + installPhase = '' + runHook preInstall + + install -d $out/bin + cp -Tr usr/bin $out/bin + + install -d $out/lib + cp -Tr lib $out/lib + cp -Tr usr/lib/ultraleap-hand-tracking-service $out/lib + rm -r $out/lib/cmake + + install -d $out/share + cp -Tr usr/share $out/share + + install -d $dev/include + cp -Tr usr/include $dev/include + + install -d $dev/lib/cmake + cp -Tr usr/lib/x86_64-linux-gnu/cmake $dev/lib/cmake + cp -Tr usr/lib/ultraleap-hand-tracking-service/cmake $dev/lib/cmake + + substituteInPlace $out/lib/systemd/system/ultraleap-hand-tracking-service.service \ + --replace-fail "/usr/bin/leapd" "$out/bin/leapd" + + substituteInPlace $dev/lib/cmake/LeapCTargets.cmake \ + --subst-var "dev" + substituteInPlace $dev/lib/cmake/LeapCTargets-release.cmake \ + --subst-var "out" + substituteInPlace $dev/lib/cmake/LeapSDK/leapsdk-config.cmake \ + --subst-var "dev" + + runHook postInstall + ''; + + meta = { + description = "Ultraleap Hand Tracking service"; + license = lib.licenses.unfree; + platforms = [ "x86_64-linux" ]; + maintainers = with lib.maintainers; [ + Scrumplex + pandapip1 + ]; + mainProgram = "leapd"; + }; +} From cffcb2db799588b9572aa22996678b1c49196dc7 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Fri, 10 May 2024 00:18:57 +0200 Subject: [PATCH 3/6] openxr-ultraleap-layer: init Signed-off-by: Sefa Eyeoglu --- .../op/openxr-ultraleap-layer/package.nix | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 pkgs/by-name/op/openxr-ultraleap-layer/package.nix diff --git a/pkgs/by-name/op/openxr-ultraleap-layer/package.nix b/pkgs/by-name/op/openxr-ultraleap-layer/package.nix new file mode 100644 index 0000000000000..e3b411e08efdd --- /dev/null +++ b/pkgs/by-name/op/openxr-ultraleap-layer/package.nix @@ -0,0 +1,62 @@ +{ + autoPatchelfHook, + dpkg, + fetchurl, + lib, + stdenv, + systemdLibs, + ultraleap-hand-tracking-service, +}: +stdenv.mkDerivation (finalAttrs: { + 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 + ]; + }; +}) From 58b365d9e04d2b9a281cd090af66e1f622276e63 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Fri, 10 May 2024 01:16:40 +0200 Subject: [PATCH 4/6] monado: add Ultraleap support Signed-off-by: Sefa Eyeoglu --- pkgs/by-name/mo/monado/package.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/by-name/mo/monado/package.nix b/pkgs/by-name/mo/monado/package.nix index 9930e8fca5666..3df390eb7ac35 100644 --- a/pkgs/by-name/mo/monado/package.nix +++ b/pkgs/by-name/mo/monado/package.nix @@ -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 @@ -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: { @@ -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 = [ @@ -136,6 +137,9 @@ stdenv.mkDerivation (finalAttrs: { ] ++ lib.optionals tracingSupport [ tracy + ] + ++ lib.optionals ultraleapSupport [ + ultraleap-hand-tracking-service ]; patches = [ From 1e01152e416beae0db82c4e58301a0fc04e2d4b8 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Fri, 10 May 2024 00:35:23 +0200 Subject: [PATCH 5/6] nixos/ultraleap: init Signed-off-by: Sefa Eyeoglu --- .../manual/release-notes/rl-2505.section.md | 2 + nixos/modules/module-list.nix | 1 + nixos/modules/services/hardware/ultraleap.nix | 75 +++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 nixos/modules/services/hardware/ultraleap.nix diff --git a/nixos/doc/manual/release-notes/rl-2505.section.md b/nixos/doc/manual/release-notes/rl-2505.section.md index fca105e284f4f..f73c1f663f040 100644 --- a/nixos/doc/manual/release-notes/rl-2505.section.md +++ b/nixos/doc/manual/release-notes/rl-2505.section.md @@ -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). diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 856f209a443d7..b4694ee17e951 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -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 diff --git a/nixos/modules/services/hardware/ultraleap.nix b/nixos/modules/services/hardware/ultraleap.nix new file mode 100644 index 0000000000000..ec41397cf7cc3 --- /dev/null +++ b/nixos/modules/services/hardware/ultraleap.nix @@ -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 + ]; +} From 7a7d1288181bc47a1461a71c22f79d780f30e9f1 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Fri, 10 May 2024 01:18:58 +0200 Subject: [PATCH 6/6] nixos/monado: add enableUltraleap option Signed-off-by: Sefa Eyeoglu --- nixos/modules/services/hardware/monado.nix | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/hardware/monado.nix b/nixos/modules/services/hardware/monado.nix index 137b63c774200..619da063c7dee 100644 --- a/nixos/modules/services/hardware/monado.nix +++ b/nixos/modules/services/hardware/monado.nix @@ -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; @@ -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 { @@ -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";