-
-
Notifications
You must be signed in to change notification settings - Fork 14k
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
nixos/monado: refactor #299841
Closed
+26
−36
Closed
nixos/monado: refactor #299841
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,33 +4,29 @@ | |
, ... | ||
}: | ||
let | ||
inherit (lib) mkDefault mkEnableOption mkIf mkOption mkPackageOption types; | ||
|
||
inherit (lib) mkAliasOptionModule mkDefault mkEnableOption mkIf mkOption mkPackageOption types; | ||
cfg = config.services.monado; | ||
|
||
in | ||
{ | ||
options.services.monado = { | ||
enable = mkEnableOption "Monado user service"; | ||
|
||
package = mkPackageOption pkgs "monado" { }; | ||
|
||
defaultRuntime = mkOption { | ||
type = types.bool; | ||
description = '' | ||
Whether to enable Monado as the default OpenXR runtime on the system. | ||
defaultRuntime = mkEnableOption '' | ||
WiVRn Monado as the default OpenXR runtime on the system. The config can be found at `/etc/xdg/openxr/1/active_runtime.json`. | ||
|
||
Note that applications can bypass this option by setting an active | ||
runtime in a writable XDG_CONFIG_DIRS location like `~/.config`. | ||
''; | ||
default = false; | ||
example = true; | ||
}; | ||
runtime in a writable XDG_CONFIG_DIRS location like `~/.config` | ||
'' // { default = true; }; | ||
|
||
highPriority = mkEnableOption "high priority capability for monado-service" | ||
// mkOption { default = true; }; | ||
highPriority = mkEnableOption "high priority capability for monado-service" // mkOption { default = true; }; | ||
}; | ||
|
||
imports = [ | ||
(mkAliasOptionModule ["services" "monado" "environment"] ["systemd" "user" "services" "monado" "environment"]) | ||
]; | ||
|
||
config = mkIf cfg.enable { | ||
security.wrappers."monado-service" = mkIf cfg.highPriority { | ||
setuid = false; | ||
|
@@ -41,60 +37,54 @@ in | |
source = lib.getExe' cfg.package "monado-service"; | ||
}; | ||
|
||
services.udev.packages = with pkgs; [ xr-hardware ]; | ||
|
||
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 = | ||
if cfg.highPriority | ||
then "${config.security.wrapperDir}/monado-service" | ||
else lib.getExe' cfg.package "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; | ||
|
||
# If Monado crashes while starting up, we want to close incoming OpenXR connections | ||
FlushPending = true; | ||
}; | ||
|
||
restartTriggers = [ cfg.package ]; | ||
|
||
wantedBy = [ "sockets.target" ]; | ||
}; | ||
}; | ||
|
||
environment.systemPackages = [ cfg.package ]; | ||
environment.pathsToLink = [ "/share/openxr" ]; | ||
services = { | ||
monado.environment = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might it make sense to make |
||
# 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"; | ||
}; | ||
udev.packages = with pkgs; [ xr-hardware ]; | ||
}; | ||
|
||
environment.etc."xdg/openxr/1/active_runtime.json" = mkIf cfg.defaultRuntime { | ||
source = "${cfg.package}/share/openxr/1/openxr_monado.json"; | ||
environment = { | ||
systemPackages = [ cfg.package ]; | ||
pathsToLink = [ "/share/openxr" ]; | ||
etc."xdg/openxr/1/active_runtime.json" = mkIf cfg.defaultRuntime { | ||
source = "${cfg.package}/share/openxr/1/openxr_monado.json"; | ||
}; | ||
}; | ||
}; | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this really be
true
by default?