summaryrefslogtreecommitdiffstats
path: root/modules/hardware/gpu.nix
blob: d7dfe17ce685a653fa089e7f8fda69713d1f35c2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
{
    config,
    options,
    lib,
    pkgs,
    ...
}: let
    gpuConfig = config.modules.hardware.gpu;
    device = config.modules.device;
in {
    options.modules.hardware.gpu = {
        enable = lib.mkOption {
            type = lib.types.bool;
            default = true;
        };
    };

    config = lib.mkIf (gpuConfig.enable) (lib.mkMerge [
        {
            hardware.opengl = {
                enable = true;
                driSupport = true;
                driSupport32Bit = true;
            };
        }
        (lib.mkIf (device.gpu == "intel") {
            boot.initrd.kernelModules = ["i915"];
            services.xserver.videoDrivers = ["modesetting"];

            hardware.opengl.extraPackages = [
                pkgs.intel-compute-runtime
                pkgs.intel-media-driver
                pkgs.vaapiIntel
                pkgs.vaapiVdpau
                pkgs.libvdpau-va-gl
            ];

            environment.variables.VDPAU_DRIVER = "va_gl";
        })
        (lib.mkIf (device.gpu == "nvidia") {
            services.xserver.videoDrivers = ["nvidia"];
            hardware.nvidia = {
                modesetting.enable = true;
                powerManagement.enable = false;
                powerManagement.finegrained = false;
                open = false;
                nvidiaSettings = true;
                package = config.boot.kernelPackages.nvidiaPackages.beta;
            };
            boot.initrd.kernelModules = [
                "nvidia"
                "nvidia_modeset"
                "nvidia_uvm"
                "nvidia_drm"
            ];
            boot.extraModprobeConfig = ''
                options modeset=1 fbdev=1
            '';
        })
    ]);
}