hardware/gpu: add gpu module

This commit is contained in:
Infinidoge 2021-11-22 00:49:51 -05:00
parent c634a13ac3
commit d71ee4073c
9 changed files with 59 additions and 52 deletions

View file

@ -41,6 +41,11 @@ in
})
(mkIf cfg.portable {
modules.hardware = {
gpu = {
nvidia = mkDefault true;
intel = mkDefault true;
amdgpu = mkDefault true;
};
wireless.enable = mkDefault true;
};
})

View file

@ -0,0 +1,48 @@
{ config, lib, ... }:
with lib;
with lib.hlissner;
let
cfg = config.modules.hardware.gpu;
in
{
options.modules.hardware.gpu = {
amdgpu = mkBoolOpt false;
nvidia = mkBoolOpt false;
intel = mkBoolOpt false;
};
config = mkMerge [
(mkIf (any (with cfg; [ amdgpu nvidia intel ])) {
hardware.opengl = {
enable = true;
driSupport = true;
driSupport32Bit = true;
extraPackages = with pkgs; [
vaapiVdpau
libvdpau-va-gl
];
};
})
(mkIf cfg.amdgpu {
boot.initrd.kernelModules = [ "amdgpu" ];
services.xserver.videoDrivers = [ "amdgpu" ];
})
(mkIf cfg.nvidia {
services.xserver.videoDrivers = [ "nvidia" ];
hardware.nvidia = {
modesetting.enable = true;
powerManagement.enable = true;
};
virtualisation.docker.enableNvidia = true;
})
(mkIf cfg.intel {
hardware.opengl.extraPackages = with pkgs; [ intel-media-driver vaapiIntel ];
})
];
}