️ Improve hardware support and performance through various modifications
Some checks failed
Trufflehog: check for exposed secrets / Run trufflehog (push) Has been cancelled
Nix: check for unused code / Run deadnix (push) Has been cancelled
Nix: validate flake.lock / Check Lockfile (push) Has been cancelled
Nix: validate flake / Validate x86_64-linux (push) Has been cancelled

This commit is contained in:
Jo 2025-09-02 22:05:47 +02:00
parent a95bef51b8
commit a6da14d4cf
7 changed files with 205 additions and 92 deletions

View file

@ -1,7 +1,8 @@
{ config, ... }:
{ ... }:
{
imports = [
./hardware.nix
./hardware-generated.nix
];
# Todo: automate this globally for all workstation and server archetypes!
@ -32,30 +33,25 @@
};
archetypes.laptop.enable = true;
system.kernel.version = "linuxPackages_6_15";
system.kernel.version = "linuxPackages_zen";
};
# Configure 8GB SWAP partition
swapDevices = [
{
device = "/swapfile";
size = 8 * 1024;
}
];
# Configure some last-resort aggressive nix-daemon OOM protection
systemd = {
# Create a separate slice for nix-daemon that is
# memory-managed by the userspace systemd-oomd killer
slices."nix-daemon".sliceConfig = {
ManagedOOMMemoryPressure = "kill";
ManagedOOMMemoryPressureLimit = "50%";
};
services."nix-daemon".serviceConfig.Slice = "nix-daemon.slice";
# If a kernel-level OOM event does occur anyway,
# strongly prefer killing nix-daemon child processes
services."nix-daemon".serviceConfig.OOMScoreAdjust = 1000;
};
boot = {
kernelModules = [ "8821ce" ];
# Configure additional kernel modules.
extraModulePackages = with config.boot.kernelPackages; [
rtl8821ce
];
blacklistedKernelModules = [
"rtw88_8821ce" # Block the default network-card driver.
];
# Grub configuration
loader.grub = {
# Minecraft bootloader theme

View file

@ -0,0 +1,67 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{
config,
lib,
modulesPath,
...
}:
{
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
];
boot.initrd.availableKernelModules = [
"xhci_pci"
"vmd"
"nvme"
"usbhid"
"rtsx_pci_sdmmc"
];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
fileSystems."/" = {
device = "/dev/disk/by-uuid/864b1287-89fd-4cc0-98a5-40a3caf804c6";
fsType = "btrfs";
options = [ "subvol=@" ];
};
boot.initrd.luks.devices."luks-5fd4fc76-d5c5-46c3-b952-1a7a7ff3a1fc".device =
"/dev/disk/by-uuid/5fd4fc76-d5c5-46c3-b952-1a7a7ff3a1fc";
fileSystems."/boot" = {
device = "/dev/disk/by-uuid/2429-4141";
fsType = "vfat";
options = [
"fmask=0022"
"dmask=0022"
];
};
swapDevices = [ ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.br-01571e4eda2f.useDHCP = lib.mkDefault true;
# networking.interfaces.br-20785fae249b.useDHCP = lib.mkDefault true;
# networking.interfaces.br-64a49a5722c1.useDHCP = lib.mkDefault true;
# networking.interfaces.br-71e5fc5962fc.useDHCP = lib.mkDefault true;
# networking.interfaces.br-7df9905783da.useDHCP = lib.mkDefault true;
# networking.interfaces.br-9b746f4e7e2f.useDHCP = lib.mkDefault true;
# networking.interfaces.br-e2f470a56dfe.useDHCP = lib.mkDefault true;
# networking.interfaces.docker0.useDHCP = lib.mkDefault true;
# networking.interfaces.enp0s13f0u4u4.useDHCP = lib.mkDefault true;
# networking.interfaces.veth4e96b46.useDHCP = lib.mkDefault true;
# networking.interfaces.veth96a5ccd.useDHCP = lib.mkDefault true;
# networking.interfaces.wlo1.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkForce "x86_64-linux";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

View file

@ -1,67 +1,92 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{
pkgs,
inputs,
config,
lib,
modulesPath,
...
}:
{
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
inputs.nixos-hardware.nixosModules.common-pc-laptop-ssd
inputs.nixos-hardware.nixosModules.common-pc-laptop
inputs.nixos-hardware.nixosModules.common-cpu-intel
];
boot.initrd.availableKernelModules = [
"xhci_pci"
"vmd"
"nvme"
"usbhid"
"rtsx_pci_sdmmc"
];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
# Some boot settings for intel CPU's
boot = {
initrd.kernelModules = [ "i915" ];
kernelModules = [
"kvm-intel"
"8821ce"
];
fileSystems."/" = {
device = "/dev/disk/by-uuid/864b1287-89fd-4cc0-98a5-40a3caf804c6";
fsType = "btrfs";
options = [ "subvol=@" ];
};
extraModulePackages = with config.boot.kernelPackages; [
rtl8821ce # Install community maintained network driver
];
boot.initrd.luks.devices."luks-5fd4fc76-d5c5-46c3-b952-1a7a7ff3a1fc".device =
"/dev/disk/by-uuid/5fd4fc76-d5c5-46c3-b952-1a7a7ff3a1fc";
fileSystems."/boot" = {
device = "/dev/disk/by-uuid/2429-4141";
fsType = "vfat";
options = [
"fmask=0022"
"dmask=0022"
blacklistedKernelModules = [
"rtw88_8821ce" # Block the default network-card driver.
];
};
# Enable OpenGL and install additional drivers for intel video acceleration
hardware = {
graphics = {
enable = true;
extraPackages = with pkgs; [
intel-ocl
intel-media-driver
vaapiVdpau
libvdpau-va-gl
];
};
# Broader firmware and hardware support
enableAllFirmware = true;
enableAllHardware = true;
};
environment.sessionVariables = {
LIBVA_DRIVER_NAME = "iHD";
};
# Enable ZRAM and disable standard SWAP
zramSwap.enable = true;
swapDevices = [ ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.br-01571e4eda2f.useDHCP = lib.mkDefault true;
# networking.interfaces.br-20785fae249b.useDHCP = lib.mkDefault true;
# networking.interfaces.br-64a49a5722c1.useDHCP = lib.mkDefault true;
# networking.interfaces.br-71e5fc5962fc.useDHCP = lib.mkDefault true;
# networking.interfaces.br-7df9905783da.useDHCP = lib.mkDefault true;
# networking.interfaces.br-9b746f4e7e2f.useDHCP = lib.mkDefault true;
# networking.interfaces.br-e2f470a56dfe.useDHCP = lib.mkDefault true;
# networking.interfaces.docker0.useDHCP = lib.mkDefault true;
# networking.interfaces.enp0s13f0u4u4.useDHCP = lib.mkDefault true;
# networking.interfaces.veth4e96b46.useDHCP = lib.mkDefault true;
# networking.interfaces.veth96a5ccd.useDHCP = lib.mkDefault true;
# networking.interfaces.wlo1.useDHCP = lib.mkDefault true;
services = {
# Enable TLP for power management profiles on AC and Battery
tlp = {
enable = true;
settings = {
CPU_SCALING_GOVERNOR_ON_AC = "performance";
CPU_SCALING_GOVERNOR_ON_BAT = "powersave";
nixpkgs.hostPlatform = lib.mkForce "x86_64-linux";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
CPU_ENERGY_PERF_POLICY_ON_AC = "performance";
CPU_ENERGY_PERF_POLICY_ON_BAT = "power";
CPU_MIN_PERF_ON_AC = 0;
CPU_MAX_PERF_ON_AC = 100;
CPU_MIN_PERF_ON_BAT = 0;
CPU_MAX_PERF_ON_BAT = 30;
};
};
# Disable power-profiles-daemon in favor of TLP :3
power-profiles-daemon.enable = false;
# Kill processes before they can cause an OOM exception
earlyoom = {
enable = true;
enableNotifications = true;
};
# Enable Thermald for improved overheating protection
thermald.enable = true;
# Instruct XServer to use the correct video drivers
xserver.videoDrivers = [
"i915"
"intel"
];
};
}