summary refs log tree commit diff
path: root/host/rootfs
diff options
context:
space:
mode:
Diffstat (limited to 'host/rootfs')
-rw-r--r--host/rootfs/Makefile4
-rw-r--r--host/rootfs/default.nix6
-rw-r--r--host/rootfs/etc/s6-rc/ext-rc-init/up7
-rwxr-xr-xhost/rootfs/etc/template/gpu/data/check5
-rw-r--r--host/rootfs/etc/template/gpu/notification-fd1
-rw-r--r--host/rootfs/etc/template/gpu/notification-fd.license2
-rwxr-xr-xhost/rootfs/etc/template/gpu/run9
-rw-r--r--host/rootfs/etc/template/gpu/type1
-rw-r--r--host/rootfs/etc/template/gpu/type.license2
9 files changed, 34 insertions, 3 deletions
diff --git a/host/rootfs/Makefile b/host/rootfs/Makefile
index be31fc3..64decbc 100644
--- a/host/rootfs/Makefile
+++ b/host/rootfs/Makefile
@@ -27,6 +27,10 @@ FILES = \
 	etc/template/fs/notification-fd \
 	etc/template/fs/run \
 	etc/template/fs/type \
+	etc/template/gpu/data/check \
+	etc/template/gpu/notification-fd \
+	etc/template/gpu/run \
+	etc/template/gpu/type \
 	etc/xdg/weston/autolaunch \
 	etc/xdg/weston/weston.ini \
 	usr/bin/lsvm \
diff --git a/host/rootfs/default.nix b/host/rootfs/default.nix
index 85a1331..16477f4 100644
--- a/host/rootfs/default.nix
+++ b/host/rootfs/default.nix
@@ -46,8 +46,8 @@ let
   foot = pkgsGui.foot.override { allowPgo = false; };
 
   packages = [
-    cloud-hypervisor e2fsprogs execline jq kmod mdevd s6 s6-linux-init s6-rc
-    socat start-vm virtiofsd
+    cloud-hypervisor e2fsprogs execline jq kmod mdevd
+    s6 s6-linux-init s6-rc socat start-vm virtiofsd
 
     (cryptsetup.override {
       programs = {
@@ -73,7 +73,7 @@ let
         CONFIG_RMMOD n
       '';
     })
-  ] ++ (with pkgsGui; [ foot westonLite ]);
+  ] ++ (with pkgsGui; [ crosvm foot westonLite ]);
 
   nixosAllHardware = nixos ({ modulesPath, ... }: {
     imports = [ (modulesPath + "/profiles/all-hardware.nix") ];
diff --git a/host/rootfs/etc/s6-rc/ext-rc-init/up b/host/rootfs/etc/s6-rc/ext-rc-init/up
index 8b5c29e..cd5d2d0 100644
--- a/host/rootfs/etc/s6-rc/ext-rc-init/up
+++ b/host/rootfs/etc/s6-rc/ext-rc-init/up
@@ -26,6 +26,13 @@ if {
     touch -- ${name}/dependencies.d/${name}-fs-${fsname}
   }
 
+  if {
+    if -t { test -e ${dir}/wayland }
+    if { cp -R -- /etc/template/gpu ${name}-gpu }
+    if { mkdir -- ${name}-gpu/env }
+    touch -- ${name}/dependencies.d/${name}-gpu
+  }
+
   elglob -0 paths /ext/svc/data/${name}/providers/net/*
   forx -po0 -E path { $paths }
   backtick -E dep { basename -- $path }
diff --git a/host/rootfs/etc/template/gpu/data/check b/host/rootfs/etc/template/gpu/data/check
new file mode 100755
index 0000000..113dcf0
--- /dev/null
+++ b/host/rootfs/etc/template/gpu/data/check
@@ -0,0 +1,5 @@
+#!/bin/execlineb -P
+# SPDX-License-Identifier: EUPL-1.2+
+# SPDX-FileCopyrightText: 2022 Unikie
+
+test -S env/crosvm.sock
diff --git a/host/rootfs/etc/template/gpu/notification-fd b/host/rootfs/etc/template/gpu/notification-fd
new file mode 100644
index 0000000..00750ed
--- /dev/null
+++ b/host/rootfs/etc/template/gpu/notification-fd
@@ -0,0 +1 @@
+3
diff --git a/host/rootfs/etc/template/gpu/notification-fd.license b/host/rootfs/etc/template/gpu/notification-fd.license
new file mode 100644
index 0000000..2241beb
--- /dev/null
+++ b/host/rootfs/etc/template/gpu/notification-fd.license
@@ -0,0 +1,2 @@
+SPDX-License-Identifier: CC0-1.0
+SPDX-FileCopyrightText: 2022 Unikie
diff --git a/host/rootfs/etc/template/gpu/run b/host/rootfs/etc/template/gpu/run
new file mode 100755
index 0000000..eaac8d6
--- /dev/null
+++ b/host/rootfs/etc/template/gpu/run
@@ -0,0 +1,9 @@
+#!/bin/execlineb -P
+# SPDX-License-Identifier: EUPL-1.2+
+# SPDX-FileCopyrightText: 2022 Unikie
+
+s6-notifyoncheck -d
+crosvm --no-syslog device gpu
+  --socket env/crosvm.sock
+  --wayland-sock /run/user/0/wayland-1
+  --params "{\"context-types\":\"cross-domain\"}"
diff --git a/host/rootfs/etc/template/gpu/type b/host/rootfs/etc/template/gpu/type
new file mode 100644
index 0000000..5883cff
--- /dev/null
+++ b/host/rootfs/etc/template/gpu/type
@@ -0,0 +1 @@
+longrun
diff --git a/host/rootfs/etc/template/gpu/type.license b/host/rootfs/etc/template/gpu/type.license
new file mode 100644
index 0000000..2241beb
--- /dev/null
+++ b/host/rootfs/etc/template/gpu/type.license
@@ -0,0 +1,2 @@
+SPDX-License-Identifier: CC0-1.0
+SPDX-FileCopyrightText: 2022 Unikie