diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 37e005f128a2e..a32ba510fd9a7 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -935,6 +935,7 @@ in { sssd = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./sssd.nix {}; sssd-ldap = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./sssd-ldap.nix {}; stalwart-mail = handleTest ./stalwart-mail.nix {}; + stardust-xr-server = handleTest ./stardust-xr-server.nix {}; stargazer = runTest ./web-servers/stargazer.nix; starship = handleTest ./starship.nix {}; static-web-server = handleTest ./web-servers/static-web-server.nix {}; diff --git a/nixos/tests/stardust-xr-server.nix b/nixos/tests/stardust-xr-server.nix new file mode 100644 index 0000000000000..0b2c19e9774e4 --- /dev/null +++ b/nixos/tests/stardust-xr-server.nix @@ -0,0 +1,173 @@ +import ./make-test-python.nix ( + { + pkgs, + lib ? pkgs.lib, + ... + }: + + let + inherit (pkgs) + writeShellScript + gnome-shell + gnome-backgrounds + stardust-xr-server + stardust-xr-flatland + weston + monado + ; + sleepScript = writeShellScript "sleep" "sleep 3"; + in + { + name = "stardust-xr-server"; + meta = { + maintainers = with lib.maintainers; [ + pandapip1 + technobaboo + matthewcroughan + ]; + }; + nodes.machine = + { ... }: + { + imports = [ ./common/user-account.nix ]; + virtualisation.qemu.options = [ + "-device virtio-gpu-pci" + ]; + environment.systemPackages = [ monado ]; + services = { + xserver = { + enable = true; + desktopManager.gnome = { + enable = true; + debug = true; + # Set a nice desktop background that is pleasing to the eyes + extraGSettingsOverrides = '' + [org.gnome.desktop.background] + picture-uri='file://${gnome-backgrounds}/share/backgrounds/gnome/blobs-l.svg' + picture-uri-dark='file://${gnome-backgrounds}/share/backgrounds/gnome/blobs-l.svg' + ''; + }; + displayManager = { + gdm = { + enable = true; + debug = true; + }; + }; + }; + displayManager = { + autoLogin = { + enable = true; + user = "alice"; + }; + }; + }; + systemd.user.services = { + monado = { + after = [ + "graphical-session.target" + "default.target" + "org.gnome.Shell@wayland.service" + ]; + environment = { + XRT_COMPOSITOR_FORCE_WAYLAND = "1"; + WAYLAND_DISPLAY = "wayland-0"; + }; + serviceConfig = { + ExecStartPre = sleepScript; + # stdin disappears in NixOS test driver ( machine.succeed() ), requiring us to specify < /dev/ttyS0 to fake stdin + ExecStart = "${lib.getExe' pkgs.monado "monado-service"} < /dev/ttyS0"; + }; + }; + stardust-xr-server = { + after = [ "monado.service" ]; + serviceConfig = { + Type = "notify"; + NotifyAccess = "all"; + ExecStartPre = sleepScript; + ExecStart = "${lib.getExe stardust-xr-server} -e ${writeShellScript "notifyReady" "systemd-notify --ready"}"; + }; + }; + weston-cliptest = { + after = [ "flatland.service" ]; + environment.WAYLAND_DISPLAY = "wayland-1"; + serviceConfig = { + ExecStart = lib.getExe' weston "weston-cliptest"; + }; + }; + flatland = { + after = [ "stardust-xr-server.service" ]; + serviceConfig = { + ExecStart = lib.getExe stardust-xr-flatland; + }; + }; + "org.gnome.Shell@wayland" = { + wants = [ + "monado.service" + "stardust-xr-server.service" + "flatland.service" + "weston-cliptest.service" + ]; + serviceConfig = { + ExecStart = [ + # Clear the list before overriding it. + "" + # Eval API is now internal so Shell needs to run in unsafe mode. + # TODO: improve test driver so that it supports openqa-like manipulation + # that would allow us to drop this mess. + "${lib.getExe pkgs.gnome-shell} --unsafe-mode" + ]; + }; + }; + }; + }; + + testScript = + { nodes, ... }: + let + # Keep line widths somewhat managable + user = nodes.machine.users.users.alice; + uid = toString user.uid; + bus = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${uid}/bus"; + gdbus = "${bus} gdbus"; + su = command: "su ${user.name} -c '${command}'"; + + # Call javascript in gnome shell, returns a tuple (success, output), where + # `success` is true if the dbus call was successful and output is what the + # javascript evaluates to. + eval = "call --session -d org.gnome.Shell -o /org/gnome/Shell -m org.gnome.Shell.Eval"; + + # False when startup is done + startingUp = su "${gdbus} ${eval} Main.layoutManager._startingUp"; + in + '' + with subtest("Login to GNOME with GDM"): + # wait for gdm to start + machine.wait_for_unit("display-manager.service") + # wait for the wayland server + machine.wait_for_file("/run/user/${uid}/wayland-0") + # wait for alice to be logged in + machine.wait_for_unit("default.target", "${user.name}") + # check that logging in has given the user ownership of devices + assert "alice" in machine.succeed("getfacl -p /dev/snd/timer") + + with subtest("Wait for GNOME Shell"): + # correct output should be (true, 'false') + machine.wait_until_succeeds( + "${startingUp} | grep -q 'true,..false'" + ) + + # To allow monado-service to use < /dev/ttyS0 + machine.succeed("chown alice /dev/ttyS0") + + with subtest("Open Monado and StardustXR"): + # Close the Activities view so that Shell can correctly track the focused window. + machine.send_key("esc") + machine.wait_for_unit("monado.service", "${user.name}") + machine.wait_for_unit("stardust-xr-server.service", "${user.name}") + machine.wait_for_unit("flatland.service", "${user.name}") + machine.wait_for_unit("weston-cliptest.service", "${user.name}") + machine.sleep(3) + machine.screenshot("screen") + ''; + } +) diff --git a/pkgs/by-name/gn/gnome-shell/package.nix b/pkgs/by-name/gn/gnome-shell/package.nix index fca04ba81d4c6..f1de9c969177b 100644 --- a/pkgs/by-name/gn/gnome-shell/package.nix +++ b/pkgs/by-name/gn/gnome-shell/package.nix @@ -238,6 +238,7 @@ stdenv.mkDerivation (finalAttrs: { description = "Core user interface for the GNOME 3 desktop"; homepage = "https://gitlab.gnome.org/GNOME/gnome-shell"; changelog = "https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/${finalAttrs.version}/NEWS?ref_type=tags"; + mainProgram = "gnome-shell"; license = licenses.gpl2Plus; maintainers = teams.gnome.members; platforms = platforms.linux; diff --git a/pkgs/by-name/mo/monado/package.nix b/pkgs/by-name/mo/monado/package.nix index f65a83c3d6017..f9804ab93557c 100644 --- a/pkgs/by-name/mo/monado/package.nix +++ b/pkgs/by-name/mo/monado/package.nix @@ -59,6 +59,9 @@ # instead of via the monado-service program. For more information see: # https://gitlab.freedesktop.org/monado/monado/-/blob/master/doc/targets.md#xrt_feature_service-disabled , serviceSupport ? true + # Set to 'true' to add support for profiling with Tracy. For more information see: + # https://gitlab.freedesktop.org/monado/monado/-/blob/main/doc/tracing-tracy.md +, enableTracy ? false }: stdenv.mkDerivation (finalAttrs: { @@ -84,11 +87,12 @@ stdenv.mkDerivation (finalAttrs: { cmakeFlags = [ (lib.cmakeBool "XRT_FEATURE_SERVICE" serviceSupport) (lib.cmakeBool "XRT_OPENXR_INSTALL_ABSOLUTE_RUNTIME_PATH" true) - (lib.cmakeBool "XRT_HAVE_TRACY" true) - (lib.cmakeBool "XRT_FEATURE_TRACING" true) (lib.cmakeBool "XRT_HAVE_STEAM" true) (lib.optionals enableCuda "-DCUDA_TOOLKIT_ROOT_DIR=${cudaPackages.cudatoolkit}") - ]; + ] ++ (lib.optionals enableTracy [ + (lib.cmakeBool "XRT_FEATURE_TRACING" true) + (lib.cmakeBool "XRT_HAVE_TRACY" true) + ]); buildInputs = [ bluez @@ -124,7 +128,6 @@ stdenv.mkDerivation (finalAttrs: { pcre2 SDL2 shaderc - tracy udev vulkan-headers vulkan-loader @@ -133,7 +136,7 @@ stdenv.mkDerivation (finalAttrs: { wayland-scanner zlib zstd - ]; + ] ++ (lib.optionals enableTracy [ tracy ]); # known disabled drivers/features: # - DRIVER_DEPTHAI - Needs depthai-core https://github.com/luxonis/depthai-core (See https://github.com/NixOS/nixpkgs/issues/292618) diff --git a/pkgs/by-name/st/stardust-xr-server/package.nix b/pkgs/by-name/st/stardust-xr-server/package.nix index f9567d8c54d7b..35ebdb94830bf 100644 --- a/pkgs/by-name/st/stardust-xr-server/package.nix +++ b/pkgs/by-name/st/stardust-xr-server/package.nix @@ -1,6 +1,7 @@ { lib, fetchFromGitHub, + stardust-xr-server, nix-update-script, rustPlatform, cmake, @@ -12,6 +13,8 @@ openxr-loader, pkg-config, xorg, + testers, + nixosTests, }: rustPlatform.buildRustPackage rec { @@ -55,7 +58,16 @@ rustPlatform.buildRustPackage rec { install -D ${cpm-cmake}/share/cpm/CPM.cmake $(echo $cargoDepsCopy/stereokit-sys-*/StereoKit)/build/cpm/CPM_0.32.2.cmake ''; - passthru.updateScript = nix-update-script { }; + passthru = { + updateScript = nix-update-script { }; + tests = { + inherit (nixosTests) stardust-xr-server; + versionTest = testers.testVersion { + inherit version; + package = stardust-xr-server; + }; + }; + }; meta = { description = "Wayland compositor and display server for 3D applications";