7 inherit (lib) mkDefault mkEnableOption mkIf mkOption mkPackageOption types;
9 cfg = config.services.monado;
13 options.services.monado = {
14 enable = mkEnableOption "Monado user service";
16 package = mkPackageOption pkgs "monado" { };
18 defaultRuntime = mkOption {
21 Whether to enable Monado as the default OpenXR runtime on the system.
23 Note that applications can bypass this option by setting an active
24 runtime in a writable XDG_CONFIG_DIRS location like `~/.config`.
30 highPriority = mkEnableOption "high priority capability for monado-service"
31 // mkOption { default = true; };
34 config = mkIf cfg.enable {
35 security.wrappers."monado-service" = mkIf cfg.highPriority {
39 # cap_sys_nice needed for asynchronous reprojection
40 capabilities = "cap_sys_nice+eip";
41 source = lib.getExe' cfg.package "monado-service";
44 services.udev.packages = with pkgs; [ xr-hardware ];
48 description = "Monado XR runtime service module";
49 requires = [ "monado.socket" ];
50 conflicts = [ "monado-dev.service" ];
52 unitConfig.ConditionUser = "!root";
56 # https://gitlab.freedesktop.org/monado/monado/-/blob/4548e1738591d0904f8db4df8ede652ece889a76/src/xrt/targets/service/monado.in.service#L12
57 XRT_COMPOSITOR_LOG = mkDefault "debug";
58 XRT_PRINT_OPTIONS = mkDefault "on";
59 IPC_EXIT_ON_DISCONNECT = mkDefault "off";
65 then "${config.security.wrapperDir}/monado-service"
66 else lib.getExe' cfg.package "monado-service";
70 restartTriggers = [ cfg.package ];
74 description = "Monado XR service module connection socket";
75 conflicts = [ "monado-dev.service" ];
77 unitConfig.ConditionUser = "!root";
80 ListenStream = "%t/monado_comp_ipc";
83 # If Monado crashes while starting up, we want to close incoming OpenXR connections
87 restartTriggers = [ cfg.package ];
89 wantedBy = [ "sockets.target" ];
93 environment.systemPackages = [ cfg.package ];
94 environment.pathsToLink = [ "/share/openxr" ];
96 environment.etc."xdg/openxr/1/active_runtime.json" = mkIf cfg.defaultRuntime {
97 source = "${cfg.package}/share/openxr/1/openxr_monado.json";
101 meta.maintainers = with lib.maintainers; [ Scrumplex ];