Hardware stuffies

This commit is contained in:
blahai 2025-01-12 19:18:13 +02:00
parent 63eac33d05
commit 5edcb857af
Signed by: blahai
SSH key fingerprint: SHA256:ZfCryi+V64yG+vC1ZIIsqgvBCmA31tTi7RJ6M8CvpRc
9 changed files with 184 additions and 0 deletions

View file

@ -2,6 +2,7 @@
imports = [
./boot
./environment
./hardware
./networking
];
}

View file

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

View file

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

View file

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

View file

@ -0,0 +1 @@
{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,20 @@
{lib, ...}: let
inherit (lib) mkOption types;
in {
imports = [
./amd.nix
./novideo.nix
];
options.olympus.device.gpu = mkOption {
type = types.nullOr (
types.enum [
"amd"
"nvidia"
"hybrid-nv"
]
);
default = null;
description = "GPU brand";
};
}

View file

@ -0,0 +1,93 @@
{
lib,
pkgs,
config,
...
}: let
inherit (config.olympus) device;
inherit
(lib.modules)
mkIf
mkMerge
mkDefault
;
inherit (lib.validators) isWayland;
isHybrid = device.gpu == "hybrid-nv";
in {
config = mkIf (device.gpu == "nvidia" || device.gpu == "hybrid-nv") {
# nvidia drivers kinda are unfree software
nixpkgs.config.allowUnfree = true;
services.xserver = mkMerge [
{videoDrivers = ["nvidia"];}
# xorg settings
];
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";}
(mkIf (isWayland config) {
# GBM_BACKEND = "nvidia-drm"; # breaks firefox apparently
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;
prime.offload = {
enable = isHybrid;
enableOffloadCmd = isHybrid;
};
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];
};
};
};
}

View file

@ -4,6 +4,10 @@
];
olympus = {
device = {
cpu = "amd";
gpu = "amd";
};
system = {
boot = {
loader = "systemd-boot";