add hardware modules

This commit is contained in:
blahai 2025-02-17 20:55:18 +02:00
parent 95f337e5c5
commit 6d14e4fa24
Signed by: blahai
SSH key fingerprint: SHA256:ZfCryi+V64yG+vC1ZIIsqgvBCmA31tTi7RJ6M8CvpRc
8 changed files with 165 additions and 1 deletions

View file

@ -1,6 +1,8 @@
{ {
imports = [ imports = [
./remote-modules.nix
./boot ./boot
./hardware
./remote-modules.nix
]; ];
} }

View file

@ -0,0 +1,17 @@
{
config,
lib,
...
}: let
inherit (config.olympus) device;
inherit (lib.modules) mkIf;
in {
config = mkIf (device.cpu == "amd" || device.cpu == "vm-amd") {
hardware.cpu.amd.updateMicrocode = true;
boot.kernelModules = [
"kvm-amd"
"amd-pstate"
];
};
}

View file

@ -0,0 +1,18 @@
{lib, ...}: let
inherit (lib) mkOption types;
in {
imports = [
./amd.nix
];
options.olympus.device.cpu = mkOption {
type = types.nullOr (
types.enum [
"amd"
"vm-amd"
]
);
default = null;
description = "CPU brand";
};
}

View file

@ -0,0 +1,7 @@
{
imports = [
./cpu
./gpu
./firmware.nix
];
}

View file

@ -0,0 +1,2 @@
# Basically needed for every system here to work
{hardware.enableRedistributableFirmware = true;}

View file

@ -0,0 +1,24 @@
{
lib,
pkgs,
config,
...
}: let
inherit (lib.modules) mkIf;
inherit (config.olympus) device;
in {
config = mkIf (device.gpu == "amd") {
services.xserver.videoDrivers = ["amdgpu"];
boot = {
kernelModules = ["amdgpu"];
initrd.kernelModules = ["amdgpu"];
};
# enables AMDVLK & OpenCL support
hardware.graphics.extraPackages = [
pkgs.rocmPackages.clr
pkgs.rocmPackages.clr.icd
];
};
}

View file

@ -0,0 +1,19 @@
{lib, ...}: let
inherit (lib) mkOption types;
in {
imports = [
./amd.nix
./novideo.nix
];
options.olympus.device.gpu = mkOption {
type = types.nullOr (
types.enum [
"amd"
"nvidia"
]
);
default = null;
description = "GPU brand";
};
}

View file

@ -0,0 +1,75 @@
{
lib,
pkgs,
config,
...
}: let
inherit (config.olympus) device;
inherit (lib.modules) mkIf mkMerge mkDefault;
in {
config = mkIf (device.gpu == "nvidia") {
# nvidia drivers kinda are unfree software
nixpkgs.config.allowUnfree = true;
services.xserver = mkMerge [
{videoDrivers = ["nvidia"];}
];
boot = {
# blacklist nouveau module as otherwise it conflicts with nvidia drm
blacklistedKernelModules = ["nouveau"];
# Enables the Nvidia's experimental framebuffer device
# fix for the imaginary monitor that does not exist
kernelParams = ["nvidia_drm.fbdev=1"];
};
environment = {
sessionVariables = mkMerge [
{
LIBVA_DRIVER_NAME = "nvidia";
WLR_DRM_DEVICES = mkDefault "/dev/dri/card1";
}
];
systemPackages = builtins.attrValues {
inherit (pkgs.nvtopPackages) nvidia;
inherit
(pkgs)
# mesa
mesa
# vulkan
vulkan-tools
vulkan-loader
vulkan-validation-layers
vulkan-extension-layer
# libva
libva
libva-utils
;
};
};
hardware = {
nvidia = {
package = mkDefault config.boot.kernelPackages.nvidiaPackages.beta;
powerManagement = {
enable = mkDefault true;
finegrained = mkDefault false;
};
open = false; # dont use the open drivers by default
nvidiaSettings = false; # adds nvidia-settings to pkgs, so useless on nixos
nvidiaPersistenced = true;
# forceFullCompositionPipeline = true;
};
graphics = {
extraPackages = [pkgs.nvidia-vaapi-driver];
extraPackages32 = [pkgs.pkgsi686Linux.nvidia-vaapi-driver];
};
};
};
}