[PATCH v3 6/6] vm/app: add hello-wayland demo VM

Alyssa Ross
2023-07-21T18:01:18Z

From: Alyssa Ross <alyssa.ross@unikie.com>

hello-wayland is the simplest possible Wayland client. This VM is
used to demonstrate Spectrum's new Wayland capabilities.

Signed-off-by: Alyssa Ross <alyssa.ross@unikie.com>
Signed-off-by: Alyssa Ross <hi@alyssa.is>
---
host/initramfs/extfs.nix | 4 +++-
vm/app/hello-wayland.nix | 29 +++++++++++++++++++++++++++++
2 files changed, 32 insertions(+), 1 deletion(-)
create mode 100644 vm/app/hello-wayland.nix

diff --git a/host/initramfs/extfs.nix b/host/initramfs/extfs.nix
index 6f32bca..174fc81 100644
--- a/host/initramfs/extfs.nix
+++ b/host/initramfs/extfs.nix
@@ -10,6 +10,7 @@ let
};

appvm-catgirl = import ../../vm/app/catgirl.nix { inherit config; };
+ appvm-hello-wayland = import ../../vm/app/hello-wayland.nix { inherit config; };
appvm-lynx = import ../../vm/app/lynx.nix { inherit config; };
appvm-mg = import ../../vm/app/mg.nix { inherit config; };
in
@@ -17,13 +18,14 @@ in
runCommand "ext.ext4" {
nativeBuildInputs = [ e2fsprogs ];
} ''
- mkdir -p root/svc/data/appvm-{catgirl,lynx,mg}
+ mkdir -p root/svc/data/appvm-{catgirl,hello-wayland,lynx,mg}
cd root

tar -C ${netvm} -c data | tar -C svc -x
chmod +w svc/data

tar -C ${appvm-catgirl} -c . | tar -C svc/data/appvm-catgirl -x
+ tar -C ${appvm-hello-wayland} -c . | tar -C svc/data/appvm-hello-wayland -x
tar -C ${appvm-lynx} -c . | tar -C svc/data/appvm-lynx -x
tar -C ${appvm-mg} -c . | tar -C svc/data/appvm-mg -x

diff --git a/vm/app/hello-wayland.nix b/vm/app/hello-wayland.nix
new file mode 100644
index 0000000..e10f05e
--- /dev/null
+++ b/vm/app/hello-wayland.nix
@@ -0,0 +1,29 @@
+# SPDX-License-Identifier: MIT
+# SPDX-FileCopyrightText: 2022 Unikie
+# SPDX-FileCopyrightText: 2023 Alyssa Ross <hi@alyssa.is>
+
+import ../../lib/eval-config.nix ({ config, ... }:
+
+import ../make-vm.nix { inherit config; } {
+ wayland = true;
+ run = config.pkgs.pkgsStatic.callPackage (
+ { writeScript, hello-wayland }:
+ writeScript "run-hello-wayland" ''
+ #!/bin/execlineb -P
+ foreground { ln -ns /run/ext /run/opengl-driver }
+ foreground { mkdir /run/user }
+ foreground {
+ umask 077
+ mkdir /run/user/0
+ }
+ if { /etc/mdev/wait card0 }
+ export XDG_RUNTIME_DIR /run/user/0
+
+ # No pkgsStatic.wayland-proxy-virtwl:
+ # https://github.com/nix-ocaml/nix-overlays/issues/698
+ ${config.pkgs.pkgsMusl.wayland-proxy-virtwl}/bin/wayland-proxy-virtwl --virtio-gpu
+
+ ${hello-wayland}/bin/hello-wayland
+ ''
+ ) { };
+})
--
2.40.1