Add scripts to run headless Wayland sessions

This commit is contained in:
Mikael 2024-08-23 09:18:16 +02:00
parent 1605e312d0
commit 8e3f467b3a
Signed by: mikael
SSH key fingerprint: SHA256:21QyD2Meiot7jOUVitIR5YkGB/XuXdCvLW1hE6dsri0
3 changed files with 59 additions and 0 deletions

View file

@ -0,0 +1,36 @@
{ ... }: { stdenvNoCC, lib, shellcheck-minimal, runtimeShell, cage }:
stdenvNoCC.mkDerivation {
name = "wayland-headless";
nativeInstallCheckInputs = [ shellcheck-minimal ];
dontUnpack = true;
dontConfigure = true;
dontBuild = true;
doInstallCheck = true;
installPhase = ''
mkdir -p "$out/bin"
substitute ${./wl-run.sh} "$out/bin/wl-run" \
--subst-var-by runtimeShell ${lib.escapeShellArg runtimeShell} \
--subst-var-by cage ${lib.escapeShellArg cage}
substitute ${./xvfb-run.sh} "$out/bin/xvfb-run" \
--subst-var-by runtimeShell ${lib.escapeShellArg runtimeShell} \
--subst-var out
chmod +x "$out/bin/"{wl-run,xvfb-run}
'';
installCheckPhase = ''
runHook preInstallCheck
shellcheck "$out/bin/"{wl-run,xvfb-run}
runHook postInstallCheck
'';
meta = {
inherit (cage.meta) platforms;
};
}

View file

@ -0,0 +1,11 @@
#!@runtimeShell@
set -o errexit
set -o nounset
set -o pipefail
WLR_BACKENDS=headless \
WLR_LIBINPUT_NO_DEVICES=1 \
WLR_RENDERER=pixman \
XDG_RUNTIME_DIR="$(mktemp -d)" \
exec '@cage@/bin/cage' -- "$@"

View file

@ -0,0 +1,12 @@
#!@runtimeShell@
set -o errexit
set -o nounset
set -o pipefail
# Discard all options
while [[ "$1" =~ ^- ]]; do
shift
done
exec '@out@/bin/wl-run' "$@"