patches and low-level development discussion
 help / color / mirror / code / Atom feed
blob e768d3d198b576d7f40b009cd3d3ff2ad6430a52 4362 bytes (raw)
name: release/checks/wayland/default.nix 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
 
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2023-2024 Alyssa Ross <hi@alyssa.is>

import ../../../lib/call-package.nix (
{ callSpectrumPackage, rootfs, testers }:

let
  inherit (rootfs) appvm;
  run = callSpectrumPackage ../../../vm/app/foot.nix {};
  surface-notify = callSpectrumPackage ./surface-notify {};
in

testers.nixosTest ({ lib, pkgs, ... }: {
  name = "spectrum-wayland";

  nodes.machine = { ... }: {
    hardware.graphics.enable = true;

    services.udev.extraRules = ''
      KERNEL=="card0", TAG+="systemd"
    '';

    systemd.mounts = [
      {
        name = "shared-config.mount";
        options = "bind";
        what = "${run}/fs";
        where = "/shared/config";
      }
    ];

    systemd.services.cloud-hypervisor = {
      after = [ "weston.service" ];
      requires = [ "weston.service" ];
      serviceConfig.ExecStart = "${lib.getExe pkgs.cloud-hypervisor} --memory shared=on --disk path=${appvm}/lib/spectrum/img/appvm/blk/root.img,readonly=on --cmdline \"console=ttyS0 root=PARTLABEL=root\" --fs socket=/run/virtiofsd.sock,tag=host --generic-vhost-user virtio_id=gpu,socket=/run/crosvm-gpu.sock,queue_sizes=[16,256] --vsock cid=3,socket=/run/vsock.sock --serial tty --console null --kernel ${appvm}/lib/spectrum/img/appvm/vmlinux";
    };

    systemd.services.crosvm = {
      after = [ "weston.service" ];
      requires = [ "weston.service" ];
      serviceConfig.ExecStart = "${lib.getExe pkgs.crosvm} run -s /run/crosvm -b path=${appvm}/lib/spectrum/img/appvm/blk/root.img,ro=true -p \"console=ttyS0 root=PARTLABEL=root\" --vhost-user fs,socket=/run/virtiofsd.sock --vhost-user gpu,socket=/run/crosvm-gpu.sock --vsock cid=3 --serial type=stdout,hardware=virtio-console,stdin=true ${appvm}/lib/spectrum/img/appvm/vmlinux";
      serviceConfig.ExecStop = "${lib.getExe pkgs.crosvm} stop /run/crosvm";
    };

    systemd.services."crosvm-gpu@" = {
      requires = [ "weston.service" ];
      serviceConfig.ExecStart = "${lib.getExe pkgs.crosvm} device gpu --fd 3 --wayland-sock /run/wayland-1 --params '{\"context-types\":\"cross-domain\"}'";
      serviceConfig.NotifyAccess = "all";
      serviceConfig.Type = "exec";
    };

    systemd.sockets.crosvm-gpu = {
      listenStreams = [ "/run/crosvm-gpu.sock" ];
      wantedBy = [ "sockets.target" ];
      socketConfig.Accept = true;
    };

    systemd.services.surface-notify-socket = {
      serviceConfig.ExecStart = "${pkgs.coreutils}/bin/mkfifo /run/surface-notify";
      serviceConfig.ExecStop = "${pkgs.coreutils}/bin/rm -f /run/surface-notify";
      serviceConfig.RemainAfterExit = true;
      serviceConfig.Type = "oneshot";
    };

    systemd.services.weston = {
      after = [ "dev-dri-card0.device" "surface-notify-socket.service" ];
      wants = [ "dev-dri-card0.device" "surface-notify-socket.service" ];
      environment.XDG_RUNTIME_DIR = "/run";
      environment.WAYLAND_DEBUG = "server";
      serviceConfig.ExecStart = "${lib.getExe pkgs.westonLite} --modules ${surface-notify}/lib/weston/surface-notify.so,systemd-notify.so";
      serviceConfig.TTYPath = "/dev/tty7";
      serviceConfig.Type = "notify";
    };

    systemd.services.virtiofsd = {
      serviceConfig.ExecStart = "${lib.getExe pkgs.virtiofsd} --fd 3 --shared-dir /shared --tag host";
      serviceConfig.Restart = "on-success";
      requires = [ "shared-config.mount" ];
      after = [ "shared-config.mount" ];
    };

    systemd.sockets.virtiofsd = {
      listenStreams = [ "/run/virtiofsd.sock" ];
      wantedBy = [ "sockets.target" ];
    };

    virtualisation.qemu.options =
      lib.optionals (!pkgs.stdenv.hostPlatform.isx86)
        [ "-machine" "accel=tcg,virtualization=on" ];
  };

  testScript = { ... }: ''
    machine.wait_for_unit('multi-user.target')

    machine.start_job('crosvm.service')
    machine.wait_for_unit('surface-notify-socket.service');
    machine.succeed('test "$(wc -c /run/surface-notify)" = "1 /run/surface-notify"', timeout=360)
    machine.screenshot('crosvm')
    machine.stop_job('crosvm.service')

    machine.systemctl('restart surface-notify-socket')
    machine.wait_for_unit('surface-notify-socket')
    machine.start_job('cloud-hypervisor.service')
    machine.succeed('test "$(wc -c /run/surface-notify)" = "1 /run/surface-notify"', timeout=360)
    machine.screenshot('cloud-hypervisor')
  '';
})) (_: {})

debug log:

solving e768d3d ...
found e768d3d in https://inbox.spectrum-os.org/spectrum-devel/20260708154315.678807-2-hi@alyssa.is/
found 40f9619 in https://spectrum-os.org/git/spectrum
preparing index
index prepared:
100644 40f9619928f5d951254fa58af81184e15a5cfd2e	release/checks/wayland/default.nix

applying [1/1] https://inbox.spectrum-os.org/spectrum-devel/20260708154315.678807-2-hi@alyssa.is/
diff --git a/release/checks/wayland/default.nix b/release/checks/wayland/default.nix
index 40f9619..e768d3d 100644

Checking patch release/checks/wayland/default.nix...
Applied patch release/checks/wayland/default.nix cleanly.

index at:
100644 e768d3d198b576d7f40b009cd3d3ff2ad6430a52	release/checks/wayland/default.nix

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://spectrum-os.org/git/doc
	https://spectrum-os.org/git/mktuntap
	https://spectrum-os.org/git/spectrum
	https://spectrum-os.org/git/ucspi-vsock

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).