diff --git a/package/wayland-headless/package.nix b/package/wayland-headless/package.nix new file mode 100644 index 0000000..7c42ef6 --- /dev/null +++ b/package/wayland-headless/package.nix @@ -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; + }; +} diff --git a/package/wayland-headless/wl-run.sh b/package/wayland-headless/wl-run.sh new file mode 100644 index 0000000..6ae0182 --- /dev/null +++ b/package/wayland-headless/wl-run.sh @@ -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' -- "$@" diff --git a/package/wayland-headless/xvfb-run.sh b/package/wayland-headless/xvfb-run.sh new file mode 100644 index 0000000..a5a71e7 --- /dev/null +++ b/package/wayland-headless/xvfb-run.sh @@ -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' "$@"