anduril / jetpack-nixos

NixOS module for NVIDIA Jetson devices
MIT License
165 stars 70 forks source link

NixGL-like wrapper for Nix on Ubuntu? #163

Open hacker1024 opened 1 year ago

hacker1024 commented 1 year ago

The packages in this repository are also quite useful on NVIDIA's Ubuntu distribution. OpenGL and Vulkan applications, however, do not work out of the box. Instead, a wrapper like NixGL needs to be made.

I have attempted to make such a wrapper. It works for OpenGL applications, but when testing Vulkan with vkcube, I get a segmentation fault. Has anyone got Vulkan working?

{ lib
, writeShellApplication
, jetpack
, libglvnd
, vulkan-validation-layers
}:

writeShellApplication {
  name = "jetson-gl";
  text = ''
    export LD_LIBRARY_PATH="${lib.makeLibraryPath (with jetpack; [ libglvnd l4t-3d-core vulkan-validation-layers ])}''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
    export __EGL_VENDOR_LIBRARY_DIRS="${jetpack.l4t-3d-core}/share/glvnd/egl_vendor.d''${__EGL_VENDOR_LIBRARY_DIRS:+:$__EGL_VENDOR_LIBRARY_DIRS}"
    export VK_LAYER_PATH='${vulkan-validation-layers}/share/vulkan/explicit_layer.d'
    export VK_ICD_FILENAMES="${jetpack.l4t-3d-core}/share/vulkan/icd.d/nvidia_icd.json''${VK_ICD_FILENAMES:+:$VK_ICD_FILENAMES}"
    exec "$@"
  '';
}
SomeoneSerge commented 11 months ago

Note that NixGL is attempting something pretty complex: it's trying to find in nixpkgs the userspace drivers that are compatible with the currently running kernel. OTOH, https://github.com/numtide/nix-gl-host just locates the host system's userspace drivers.

Note also for certain applications (CUDA) neither is really sufficient and instead/in addition we need something like https://github.com/NixOS/nixpkgs/pull/267247. CC https://github.com/anduril/jetpack-nixos/pull/160