commit 2aa50995b6c72933eef424fe35a104e562682e83
parent 1602e7d9e824ad0362b7a69666326245a5537d7f
Author: Vineet Kumar <git@vineetk.net>
Date: Sun, 22 Nov 2026 16:25:17 +0100
add vibe slop steam wrapper and vulkan layer for my bigscreen beyond 2e and hmd gpu selection
Diffstat:
1 file changed, 149 insertions(+), 0 deletions(-)
diff --git a/epistemia/packages/steam.scm b/epistemia/packages/steam.scm
@@ -0,0 +1,149 @@
+(define-module (epistemia packages steam)
+ #:use-module (guix packages)
+ #:use-module (guix gexp)
+ #:use-module (guix git-download)
+ #:use-module (guix build-system trivial)
+ #:use-module (guix build-system gnu)
+ #:use-module (gnu packages compression)
+ #:use-module (gnu packages vulkan)
+ #:use-module (gnu packages xorg)
+ #:use-module (gnu packages bash)
+ #:use-module (gnu packages gl)
+ #:use-module (nongnu packages game-client)
+ #:use-module (nonguix multiarch-container)
+ #:export (steam-beyond steam-beyond-layer))
+
+;;;; WARNING: BAD AI SLOP BELOW
+;; it was done because steamvr by default uses all gpus. this causes corruption: https://github.com/ValveSoftware/SteamVR-for-Linux/issues/888
+;; existing solutions didn't work, but having an llm create a custom vulkan layer that exposes only a single gpu did work
+;; then, steamvr doesn't do 90Hz in linux for the bigscreen beyond 2e while it did in monado: https://vronlinux.org/docs/hardware/bigscreen-beyond/
+;; but monado can't share its mode setting with steamvr, so llm made a library stub
+;; but that needed changes to vrcompositor-launch script in steamvr, so below packages were created instead so I don't need extra non-package wrapper scripts
+
+;; Sources are plain files embedded in this module; no mutable checkout or
+;; sandbox-local library is needed at runtime.
+(define-public steam-beyond-layer
+ (package
+ (name "steam-beyond-layer")
+ (version "fbc144250aadc405b0d5b3837446dace9f828794")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "ssh://anongit@vineetk.net/bigscreen-beyond-vulkan-90hz")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "1hzcdk48f7lvccwws0rk2cdczdp4by55pawjh1lx0x2v7xpf4r4s"))))
+ (build-system gnu-build-system)
+ (arguments
+ (list
+ #:tests? #f ; Hardware-dependent; verified against the Beyond on demiurge.
+ #:phases
+ #~(modify-phases %standard-phases
+ (delete 'configure)
+ (replace 'build
+ (lambda _
+ (invoke "gcc" "-D_GNU_SOURCE" "-shared" "-fPIC" "-O2"
+ "-Wall" "-Wextra" "headset-gpu-90hz.c"
+ "beyond-90hz-config.c"
+ "-Wl,--version-script=headset-gpu-90hz.exports"
+ "-o" "libheadset_gpu_c.so" "-ldl")))
+ (replace 'install
+ (lambda _
+ (install-file "libheadset_gpu_c.so"
+ (string-append #$output "/lib"))
+ (let ((manifest (string-append #$output
+ "/share/vulkan/implicit_layer.d/steamvr-headset-gpu.json")))
+ (mkdir-p (dirname manifest))
+ (call-with-output-file manifest
+ (lambda (port)
+ (format port "{\"file_format_version\":\"1.0.0\",\"layer\":{\"name\":\"VK_LAYER_CUSTOM_headset_gpu\",\"type\":\"GLOBAL\",\"library_path\":\"~a/lib/libheadset_gpu_c.so\",\"api_version\":\"1.1.0\",\"implementation_version\":\"3\",\"description\":\"Beyond GPU selection and matched 90 Hz geometry\",\"enable_environment\":{\"STEAMVR_HEADSET_GPU\":\"1\"},\"disable_environment\":{\"DISABLE_VK_LAYER_CUSTOM_headset_gpu\":\"1\"}}}\n" #$output)))))))))
+ (native-inputs (list vulkan-headers))
+ (inputs (list zlib libxcb))
+ (home-page "https://github.com/ValveSoftware/SteamVR-for-Linux")
+ (synopsis "Beyond 90 Hz geometry and headset GPU selection for SteamVR")
+ (description "Local Vulkan-layer and preload workaround for the Bigscreen
+Beyond on demiurge. Selects PCI 0000:07:00.0 and keeps 1920-per-eye geometry
+consistent with the actual 90 Hz display mode, without modifying SteamVR.")
+ (license #f)))
+
+;; Set LD_PRELOAD AFTER entering the FHS sandbox but BEFORE Steam starts its
+;; alongside-steam launcher service. No SteamVR depot files need modification.
+(define steam-client-original
+ (@@ (nongnu packages game-client) steam-client))
+
+(define steam-client-beyond
+ (package
+ (inherit steam-client-original)
+ (name "steam-client-beyond")
+ (source #f)
+ (build-system trivial-build-system)
+ (arguments
+ (list
+ #:modules '((guix build utils))
+ #:builder
+ #~(begin
+ (use-modules (guix build utils) (ice-9 ftw))
+ (mkdir-p (string-append #$output "/bin"))
+ (for-each
+ (lambda (name)
+ (unless (member name '("." ".." "bin"))
+ (symlink (string-append #$steam-client-original "/" name)
+ (string-append #$output "/" name))))
+ (scandir #$steam-client-original))
+ (let ((wrapper (string-append #$output "/bin/steam")))
+ (call-with-output-file wrapper
+ (lambda (port)
+ (format port "#!~a/bin/sh\n" #$bash-minimal)
+ (display "\
+export G_SLICE=always-malloc
+export DRI_PRIME=pci-0000_07_00_0
+export STEAMVR_HEADSET_GPU=1\n" port)
+ (format port "layer=\"~a/lib/libheadset_gpu_c.so\"\n" #$steam-beyond-layer)
+ (display "if [ ! -r \"$layer\" ]; then echo \"Missing Beyond layer: $layer\" >&2; exit 1; fi\n" port)
+ (display "export LD_PRELOAD=\"$layer${LD_PRELOAD:+:$LD_PRELOAD}\"\n" port)
+ (format port "exec ~a/bin/steam \"$@\"\n" #$steam-client-original)))
+ (chmod wrapper #o755)))))
+ (inputs (list steam-client-original bash-minimal))
+ (native-inputs '())
+ (propagated-inputs '())))
+
+(define steam-beyond-container
+ (nonguix-container->package
+ (nonguix-container
+ (inherit (steam-container-for mesa
+ #:extra-packages `(("steam-beyond-layer" ,steam-beyond-layer))))
+ (wrap-package steam-client-beyond))))
+
+;; Machine/session setup belongs to the package entry point, before the
+;; container is entered. The inner client wrapper above handles variables
+;; that Nonguix deliberately does not preserve across the sandbox boundary.
+(define-public steam-beyond
+ (package
+ (inherit steam-beyond-container)
+ (build-system trivial-build-system)
+ (arguments
+ (list
+ #:modules '((guix build utils))
+ #:builder
+ #~(begin
+ (use-modules (guix build utils) (ice-9 ftw))
+ (mkdir-p (string-append #$output "/bin"))
+ (for-each
+ (lambda (name)
+ (unless (member name '("." ".." "bin"))
+ (symlink (string-append #$steam-beyond-container "/" name)
+ (string-append #$output "/" name))))
+ (scandir #$steam-beyond-container))
+ (let ((wrapper (string-append #$output "/bin/steam")))
+ (call-with-output-file wrapper
+ (lambda (port)
+ (format port "#!~a/bin/sh\n" #$bash-minimal)
+ (display "export DISPLAY=\"${DISPLAY:-:0}\"\n" port)
+ (display "export XDG_RUNTIME_DIR=\"${XDG_RUNTIME_DIR:-/tmp/runtime-1000}\"\n" port)
+ (display "export DRI_PRIME=pci-0000_07_00_0\n" port)
+ (display "export GUIX_SANDBOX_EXTRA_SHARES=\"${GUIX_SANDBOX_EXTRA_SHARES:+$GUIX_SANDBOX_EXTRA_SHARES:}/data_hdd/games\"\n" port)
+ (format port "exec ~a/bin/steam \"$@\"\n" #$steam-beyond-container)))
+ (chmod wrapper #o755)))))
+ (inputs (list steam-beyond-container bash-minimal))))