Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions nixos/tests/all-tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};
Expand Down
173 changes: 173 additions & 0 deletions nixos/tests/stardust-xr-server.nix
Original file line number Diff line number Diff line change
@@ -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)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be flaky when built on a busy machine

machine.screenshot("screen")
'';
}
)
1 change: 1 addition & 0 deletions pkgs/by-name/gn/gnome-shell/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 8 additions & 5 deletions pkgs/by-name/mo/monado/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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
Expand Down Expand Up @@ -124,7 +128,6 @@ stdenv.mkDerivation (finalAttrs: {
pcre2
SDL2
shaderc
tracy
udev
vulkan-headers
vulkan-loader
Expand All @@ -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)
Expand Down
14 changes: 13 additions & 1 deletion pkgs/by-name/st/stardust-xr-server/package.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
lib,
fetchFromGitHub,
stardust-xr-server,
nix-update-script,
rustPlatform,
cmake,
Expand All @@ -12,6 +13,8 @@
openxr-loader,
pkg-config,
xorg,
testers,
nixosTests,
}:

rustPlatform.buildRustPackage rec {
Expand Down Expand Up @@ -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";
Expand Down