From 2d7aef9654fff6f8e2cfe4b33643a50d2da353de Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Fri, 10 May 2024 00:35:23 +0200 Subject: [PATCH] nixos/ultraleap: init Signed-off-by: Sefa Eyeoglu --- .../manual/release-notes/rl-2411.section.md | 2 + nixos/modules/module-list.nix | 1 + nixos/modules/services/hardware/ultraleap.nix | 62 +++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 nixos/modules/services/hardware/ultraleap.nix diff --git a/nixos/doc/manual/release-notes/rl-2411.section.md b/nixos/doc/manual/release-notes/rl-2411.section.md index 1874a3b336f479..19f917e35101b1 100644 --- a/nixos/doc/manual/release-notes/rl-2411.section.md +++ b/nixos/doc/manual/release-notes/rl-2411.section.md @@ -194,6 +194,8 @@ - [tiny-dfr](https://github.com/WhatAmISupposedToPutHere/tiny-dfr), a dynamic function row daemon for the Touch Bar found on some Apple laptops. Available as [hardware.apple.touchBar.enable](options.html#opt-hardware.apple.touchBar.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) + ## Backward Incompatibilities {#sec-release-24.11-incompatibilities} - The `sound` options have been removed or renamed, as they had a lot of unintended side effects. See [below](#sec-release-24.11-migration-sound) for details. diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 98340036f7b64d..3b6cabcc7d3256 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -625,6 +625,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 00000000000000..61912cecfe6367 --- /dev/null +++ b/nixos/modules/services/hardware/ultraleap.nix @@ -0,0 +1,62 @@ +{ 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 ]; +}