blob: bd57108c6731a190c3161f79bde8eed92c362cb8 (
plain)
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
|
{ config, lib, ... }:
let
cfg = config.traits.nvidia;
in
{
options.traits.nvidia = {
enable = lib.mkEnableOption "NVIDIA drivers";
openModules.enable = lib.mkEnableOption "open kernel modules for the proprietary driver" // {
# unlike nixpkgs, i know all of my nvidia cards should prefer the open modules after 560
default = lib.versionAtLeast config.hardware.nvidia.package.version "560";
};
nvk.enable = lib.mkEnableOption "an NVK specialisation";
};
config = lib.mkIf cfg.enable (
lib.mkMerge [
{
services.xserver.videoDrivers = [ "nvidia" ];
hardware.nvidia = {
package = lib.mkDefault config.boot.kernelPackages.nvidiaPackages.latest;
open = cfg.openModules.enable;
};
}
(lib.mkIf cfg.nvk.enable {
specialisation = {
nvk.configuration = {
boot = {
# required for GSP firmware
kernelParams = [ "nouveau.config=NvGspRm=1" ];
# we want early KMS
# https://wiki.archlinux.org/title/Kernel_mode_setting#Early_KMS_start
initrd.kernelModules = [ "nouveau" ];
};
# TODO: make sure we don't need this anymore
environment.sessionVariables = {
MESA_VK_VERSION_OVERRIDE = "1.3";
};
hardware.graphics.extraPackages = lib.mkForce [ ];
services.xserver.videoDrivers = lib.mkForce [ "modesetting" ];
system.nixos.tags = [ "with-nvk" ];
};
};
})
(lib.mkIf config.traits.containers.enable {
hardware.nvidia-container-toolkit.enable = true;
})
]
);
}
|