nixos/monado: add forceDefaultRuntime option
This option replaces the active runtime manifest in the user directory. Games running through Steam's Pressure Vessel cannot read /etc so forcefully overriding the file every time the service starts, will allow those games to use Monado. Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
parent
969ad19f9d
commit
91fee43100
@ -16,6 +16,7 @@ let
|
||||
|
||||
cfg = config.services.monado;
|
||||
|
||||
runtimeManifest = "${cfg.package}/share/openxr/1/openxr_monado.json";
|
||||
in
|
||||
{
|
||||
options.services.monado = {
|
||||
@ -35,6 +36,19 @@ in
|
||||
example = true;
|
||||
};
|
||||
|
||||
forceDefaultRuntime = mkOption {
|
||||
type = types.bool;
|
||||
description = ''
|
||||
Whether to ensure that Monado is the active runtime set for the current
|
||||
user.
|
||||
|
||||
This replaces the file `XDG_CONFIG_HOME/openxr/1/active_runtime.json`
|
||||
when starting the service.
|
||||
'';
|
||||
default = false;
|
||||
example = true;
|
||||
};
|
||||
|
||||
highPriority =
|
||||
mkEnableOption "high priority capability for monado-service"
|
||||
// mkOption { default = true; };
|
||||
@ -68,6 +82,16 @@ in
|
||||
IPC_EXIT_ON_DISCONNECT = mkDefault "off";
|
||||
};
|
||||
|
||||
preStart = mkIf cfg.forceDefaultRuntime ''
|
||||
XDG_CONFIG_HOME="''${XDG_CONFIG_HOME:-$HOME/.config}"
|
||||
targetDir="$XDG_CONFIG_HOME/openxr/1"
|
||||
activeRuntimePath="$targetDir/active_runtime.json"
|
||||
|
||||
echo "Note: Replacing active runtime at '$activeRuntimePath'"
|
||||
mkdir --parents "$targetDir"
|
||||
ln --symbolic --force ${runtimeManifest} "$activeRuntimePath"
|
||||
'';
|
||||
|
||||
serviceConfig = {
|
||||
ExecStart =
|
||||
if cfg.highPriority then
|
||||
@ -106,7 +130,7 @@ in
|
||||
hardware.graphics.extraPackages = [ pkgs.monado-vulkan-layers ];
|
||||
|
||||
environment.etc."xdg/openxr/1/active_runtime.json" = mkIf cfg.defaultRuntime {
|
||||
source = "${cfg.package}/share/openxr/1/openxr_monado.json";
|
||||
source = runtimeManifest;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import ./make-test-python.nix (
|
||||
{ pkgs, ... }:
|
||||
{ ... }:
|
||||
{
|
||||
name = "monado";
|
||||
|
||||
@ -16,6 +16,8 @@ import ./make-test-python.nix (
|
||||
services.monado = {
|
||||
enable = true;
|
||||
defaultRuntime = true;
|
||||
|
||||
forceDefaultRuntime = true;
|
||||
};
|
||||
# Stop Monado from probing for any hardware
|
||||
systemd.user.services.monado.environment.SIMULATED_ENABLE = "1";
|
||||
@ -30,6 +32,9 @@ import ./make-test-python.nix (
|
||||
runtimePath = "/run/user/${userId}";
|
||||
in
|
||||
''
|
||||
# for defaultRuntime
|
||||
machine.succeed("stat /etc/xdg/openxr/1/active_runtime.json")
|
||||
|
||||
machine.succeed("loginctl enable-linger alice")
|
||||
machine.wait_for_unit("user@${userId}.service")
|
||||
|
||||
@ -37,6 +42,9 @@ import ./make-test-python.nix (
|
||||
machine.systemctl("start monado.service", "alice")
|
||||
machine.wait_for_unit("monado.service", "alice")
|
||||
|
||||
# for forceDefaultRuntime
|
||||
machine.succeed("stat /home/alice/.config/openxr/1/active_runtime.json")
|
||||
|
||||
machine.succeed("su -- alice -c env XDG_RUNTIME_DIR=${runtimePath} openxr_runtime_list")
|
||||
'';
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user