system: Add auto-offload wrapper command
This command will *always* exist when OpenGL is enabled. If graphical offload is enabled, it will make sure the GPU is actually enabled using glxinfo (there's probably a better way to do this) and fallback to executing normally, otherwise it will just exec the passed command.
This commit is contained in:
parent
0fd3f6455b
commit
34fd3a91ad
@ -5,6 +5,20 @@ in
|
||||
{
|
||||
options.nixfiles.hardware.opengl.enable = lib.mkEnableOption "OpenGL configuration";
|
||||
config = lib.mkIf cfg.enable {
|
||||
environment.systemPackages = let
|
||||
offload-enabled = config.hardware.nvidia.prime.offload.enableOffloadCmd;
|
||||
glxinfo = lib.getExe' pkgs.glxinfo "glxinfo";
|
||||
auto-offload = pkgs.writeShellScriptBin "auto-offload" (
|
||||
(if offload-enabled then ''
|
||||
if nvidia-offload ${glxinfo} > /dev/null 2>&1 ; then
|
||||
exec nvidia-offload "$@"
|
||||
fi
|
||||
'' else "")
|
||||
+
|
||||
''
|
||||
exec "$@"
|
||||
'');
|
||||
in [ auto-offload ];
|
||||
# Enable OpenGL
|
||||
hardware.opengl = {
|
||||
enable = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user