about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSefa Eyeoglu <contact@scrumplex.net>2023-12-18 17:48:48 +0100
committerSefa Eyeoglu <contact@scrumplex.net>2024-02-23 14:25:16 +0100
commit8fc2690b73a3c0376f69c34a37dc716c5d6bd6bd (patch)
tree506fc0c25cf054c57654161e40ce0e784413c2b8
parent2d2493b23dc35f552e13f6022b0ec4b2a4cdc7b1 (diff)
nixos/monado: add test
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
-rw-r--r--nixos/tests/all-tests.nix1
-rw-r--r--nixos/tests/monado.nix39
-rw-r--r--pkgs/applications/graphics/monado/default.nix5
3 files changed, 45 insertions, 0 deletions
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index 1144a5611dcf8..1387531316545 100644
--- a/nixos/tests/all-tests.nix
+++ b/nixos/tests/all-tests.nix
@@ -535,6 +535,7 @@ in {
   mobilizon = handleTest ./mobilizon.nix {};
   mod_perl = handleTest ./mod_perl.nix {};
   molly-brown = handleTest ./molly-brown.nix {};
+  monado = handleTest ./monado.nix {};
   monica = handleTest ./web-apps/monica.nix {};
   mongodb = handleTest ./mongodb.nix {};
   moodle = handleTest ./moodle.nix {};
diff --git a/nixos/tests/monado.nix b/nixos/tests/monado.nix
new file mode 100644
index 0000000000000..8368950951e73
--- /dev/null
+++ b/nixos/tests/monado.nix
@@ -0,0 +1,39 @@
+import ./make-test-python.nix ({ pkgs, ... }: {
+  name = "monado";
+
+  nodes.machine =
+    { pkgs, ... }:
+
+    {
+      hardware.opengl.enable = true;
+      users.users.alice = {
+        isNormalUser = true;
+        uid = 1000;
+      };
+
+      services.monado = {
+        enable = true;
+        defaultRuntime = true;
+      };
+      # Stop Monado from probing for any hardware
+      systemd.user.services.monado.environment.SIMULATED_ENABLE = "1";
+
+      environment.systemPackages = with pkgs; [ openxr-loader ];
+    };
+
+  testScript = { nodes, ... }:
+    let
+      userId = toString nodes.machine.users.users.alice.uid;
+      runtimePath = "/run/user/${userId}";
+    in
+    ''
+      machine.succeed("loginctl enable-linger alice")
+      machine.wait_for_unit("user@${userId}.service")
+
+      machine.wait_for_unit("monado.socket", "alice")
+      machine.systemctl("start monado.service", "alice")
+      machine.wait_for_unit("monado.service", "alice")
+
+      machine.succeed("su -- alice -c env XDG_RUNTIME_DIR=${runtimePath} openxr_runtime_list")
+    '';
+})
diff --git a/pkgs/applications/graphics/monado/default.nix b/pkgs/applications/graphics/monado/default.nix
index 40e5f916f3f3d..7442f192fe24d 100644
--- a/pkgs/applications/graphics/monado/default.nix
+++ b/pkgs/applications/graphics/monado/default.nix
@@ -41,6 +41,7 @@
 , wayland-scanner
 , libdrm
 , zlib
+, nixosTests
 # Set as 'false' to build monado without service support, i.e. allow VR
 # applications linking against libopenxr_monado.so to use OpenXR standalone
 # instead of via the monado-service program. For more information see:
@@ -137,6 +138,10 @@ stdenv.mkDerivation {
     ./force-enable-steamvr_lh.patch
   ];
 
+  passthru.tests = {
+    basic-service = nixosTests.monado;
+  };
+
   meta = with lib; {
     description = "Open source XR runtime";
     homepage = "https://monado.freedesktop.org/";