diff options
author | Sefa Eyeoglu <contact@scrumplex.net> | 2023-07-23 11:36:49 +0200 |
---|---|---|
committer | Sefa Eyeoglu <contact@scrumplex.net> | 2024-02-23 14:25:15 +0100 |
commit | 5d57df8a804b46f9071778e918a2c43f942faf42 (patch) | |
tree | 5df210f919cee980eb7b93d6b8e7a9c0152232dc /nixos/modules/services/hardware | |
parent | 33020597a32dcbd30cde7128336e9312a8104e98 (diff) |
nixos/monado: init
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
Diffstat (limited to 'nixos/modules/services/hardware')
-rw-r--r-- | nixos/modules/services/hardware/monado.nix | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/nixos/modules/services/hardware/monado.nix b/nixos/modules/services/hardware/monado.nix new file mode 100644 index 0000000000000..55ad2c299baee --- /dev/null +++ b/nixos/modules/services/hardware/monado.nix @@ -0,0 +1,73 @@ +{ config +, lib +, pkgs +, ... +}: +let + inherit (lib) mkDefault mkEnableOption mkIf mkPackageOption; + + cfg = config.services.monado; +in +{ + options.services.monado = { + enable = mkEnableOption "Monado wrapper and user service"; + + package = mkPackageOption pkgs "monado" { }; + }; + + config = mkIf cfg.enable { + security.wrappers."monado-service" = { + setuid = false; + owner = "root"; + group = "root"; + # cap_sys_nice needed for asynchronous reprojection + capabilities = "cap_sys_nice+eip"; + source = "${cfg.package}/bin/monado-service"; + }; + + systemd.user = { + services.monado = { + description = "Monado XR runtime service module"; + requires = [ "monado.socket" ]; + conflicts = [ "monado-dev.service" ]; + + unitConfig.ConditionUser = "!root"; + + environment = { + # Default options + # https://gitlab.freedesktop.org/monado/monado/-/blob/4548e1738591d0904f8db4df8ede652ece889a76/src/xrt/targets/service/monado.in.service#L12 + XRT_COMPOSITOR_LOG = mkDefault "debug"; + XRT_PRINT_OPTIONS = mkDefault "on"; + IPC_EXIT_ON_DISCONNECT = mkDefault "off"; + }; + + serviceConfig = { + ExecStart = "${config.security.wrapperDir}/monado-service"; + Restart = "no"; + }; + + restartTriggers = [ cfg.package ]; + }; + + sockets.monado = { + description = "Monado XR service module connection socket"; + conflicts = [ "monado-dev.service" ]; + + unitConfig.ConditionUser = "!root"; + + socketConfig = { + ListenStream = "%t/monado_comp_ipc"; + RemoveOnStop = true; + }; + + restartTriggers = [ cfg.package ]; + + wantedBy = [ "sockets.target" ]; + }; + }; + + environment.systemPackages = [ cfg.package ]; + }; + + meta.maintainers = with lib.maintainers; [ Scrumplex ]; +} |