diff options
| author | Sefa Eyeoglu <contact@scrumplex.net> | 2024-10-15 17:33:11 +0200 |
|---|---|---|
| committer | github-actions[bot] <github-actions[bot]@users.noreply.github.com> | 2024-11-24 12:27:02 +0000 |
| commit | 942f21f944d193209992bbed032d348026f5fd86 (patch) | |
| tree | 5a4e6fd09681d0fc34b01746f7e0b189e3dd06ed | |
| parent | nixos/monado: nixfmt (diff) | |
| download | nixpkgs-origin/backport-348815-to-release-24.11.tar.gz | |
nixos/monado: add forceDefaultRuntime optionorigin/backport-348815-to-release-24.11
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>
(cherry picked from commit 91fee431005a26e238ecc6ed273eb3d413b0add6)
| -rw-r--r-- | nixos/modules/services/hardware/monado.nix | 26 | ||||
| -rw-r--r-- | nixos/tests/monado.nix | 10 |
2 files changed, 34 insertions, 2 deletions
diff --git a/nixos/modules/services/hardware/monado.nix b/nixos/modules/services/hardware/monado.nix index f7fdf421ac17..137b63c77420 100644 --- a/nixos/modules/services/hardware/monado.nix +++ b/nixos/modules/services/hardware/monado.nix @@ -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; }; }; diff --git a/nixos/tests/monado.nix b/nixos/tests/monado.nix index 2fb94468a2bb..9b7e636d1f66 100644 --- a/nixos/tests/monado.nix +++ b/nixos/tests/monado.nix @@ -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") ''; } |
