add dbus and dri

This commit is contained in:
2021-08-14 13:48:55 +02:00
parent 0103df5ca9
commit 354ba05faa
5 changed files with 122 additions and 10 deletions
+28 -2
View File
@@ -1,5 +1,8 @@
import os
import strformat
import posix
import bwrap
import args
import os
const APP_NAME = "bwsandbox"
@@ -22,4 +25,27 @@ proc getProfilePath*(args: Args): string =
proc getSandboxPath*(name: string): string =
getDataDir()
.joinPath(APP_NAME)
.joinPath(name)
.joinPath(name)
proc deviceExists(path: string): bool =
var res: Stat
return stat(path, res) >= 0 and S_ISCHR(res.st_mode)
# https://github.com/flatpak/flatpak/blob/1bdbb80ac57df437e46fce2cdd63e4ff7704718b/common/flatpak-run.c#L1496
proc enableDri*(call: var BwrapCall) =
const mounts = [
"/dev/dri", # general
"/dev/mali", "/dev/mali0", "/dev/umplock", # mali
"/dev/nvidiactl", "/dev/nvidia-modeset", # nvidia
"/dev/nvidia-uvm", "/dev/nvidia-uvm-tools" # nvidia OpenCl/CUDA
]
for mount in mounts:
if deviceExists(mount):
call.addMount("--dev-bind", mount)
for i in 0..20:
let device = &"/dev/nvidia{i}"
if deviceExists(device):
call.addMount("--dev-bind", device)