add hardware modules
This commit is contained in:
parent
95f337e5c5
commit
6d14e4fa24
8 changed files with 165 additions and 1 deletions
|
@ -1,6 +1,8 @@
|
|||
{
|
||||
imports = [
|
||||
./remote-modules.nix
|
||||
./boot
|
||||
./hardware
|
||||
|
||||
./remote-modules.nix
|
||||
];
|
||||
}
|
||||
|
|
17
modules/nixos/hardware/cpu/amd.nix
Normal file
17
modules/nixos/hardware/cpu/amd.nix
Normal 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"
|
||||
];
|
||||
};
|
||||
}
|
18
modules/nixos/hardware/cpu/default.nix
Normal file
18
modules/nixos/hardware/cpu/default.nix
Normal 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";
|
||||
};
|
||||
}
|
7
modules/nixos/hardware/default.nix
Normal file
7
modules/nixos/hardware/default.nix
Normal file
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
imports = [
|
||||
./cpu
|
||||
./gpu
|
||||
./firmware.nix
|
||||
];
|
||||
}
|
2
modules/nixos/hardware/firmware.nix
Normal file
2
modules/nixos/hardware/firmware.nix
Normal file
|
@ -0,0 +1,2 @@
|
|||
# Basically needed for every system here to work
|
||||
{hardware.enableRedistributableFirmware = true;}
|
24
modules/nixos/hardware/gpu/amd.nix
Normal file
24
modules/nixos/hardware/gpu/amd.nix
Normal 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
|
||||
];
|
||||
};
|
||||
}
|
19
modules/nixos/hardware/gpu/default.nix
Normal file
19
modules/nixos/hardware/gpu/default.nix
Normal 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";
|
||||
};
|
||||
}
|
75
modules/nixos/hardware/gpu/novideo.nix
Normal file
75
modules/nixos/hardware/gpu/novideo.nix
Normal 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];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Reference in a new issue