grimm-nixos-laptop/common/graphics/opengl.nix
2024-08-15 14:59:23 +02:00

84 lines
1.9 KiB
Nix

{
pkgs,
config,
lib,
...
}:
let
inherit (config.grimmShared) enable graphical screens;
inherit (lib) types mkOption mkIf;
screen = types.submodule {
options = {
fps = mkOption {
type = types.either types.int (types.nonEmptyListOf types.int);
default = 60;
description = "max framerate of screen";
};
mode = mkOption {
type = types.nonEmptyStr;
default = "1920x1080";
description = "pixel format of the screen";
};
id = mkOption {
type = types.nonEmptyStr;
description = "ID of the screen";
};
pos = mkOption {
type = types.nullOr types.nonEmptyStr;
default = null;
example = "0,0";
description = "position where to place the screen";
};
};
};
in
{
config = mkIf (enable && graphical) {
# Enable OpenGL
hardware.graphics = {
enable = true;
#driSupport = true;
#driSupport32Bit = true;
extraPackages = [ ];
};
chaotic.mesa-git.enable = true;
boot.kernelParams = [ "nouveau.config=NvGspRm=1" ];
environment.sessionVariables = {
__GL_LOG_MAX_ANISO = "0";
__GL_SHADER_DISK_CACHE = "1";
__GL_SYNC_TO_VBLANK = "0";
__GL_THREADED_OPTIMIZATIONS = "1";
__GL_VRR_ALLOWED = "1";
# MESA_LOADER_DRIVER_OVERRIDE="zink";
# FLATPAK_GL_DRIVERS="mesa-git";
};
environment.systemPackages = with pkgs; [
glfw
glxinfo
vulkan-tools
mangohud
];
};
options.grimmShared = {
graphical = mkOption {
type = types.bool;
default = screens != { };
description = "whether to force enable graphical components";
};
screens = mkOption {
type = types.attrsOf screen;
default = { };
description = "Screens to initialize, will activate graphical components";
};
};
}