furthre config on laptop

This commit is contained in:
2025-07-14 15:12:21 +02:00
parent 5b2b64611e
commit e2f428bc64
54 changed files with 1479 additions and 87 deletions
+6
View File
@@ -0,0 +1,6 @@
{ lib, ... }:
{
imports = [];
services.xserver.videoDrivers = lib.mkDefault [ "modesetting" "nvidia"];
}
+31
View File
@@ -0,0 +1,31 @@
{ ... }:
{
# This runs only intel/amdgpu igpus and nvidia dgpus do not drain power.
##### disable nvidia, very nice battery life.
boot.extraModprobeConfig = ''
blacklist nouveau
options nouveau modeset=0
'';
services.udev.extraRules = ''
# Remove NVIDIA USB xHCI Host Controller devices, if present
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c0330", ATTR{power/control}="auto", ATTR{remove}="1"
# Remove NVIDIA USB Type-C UCSI devices, if present
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c8000", ATTR{power/control}="auto", ATTR{remove}="1"
# Remove NVIDIA Audio devices, if present
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x040300", ATTR{power/control}="auto", ATTR{remove}="1"
# Remove NVIDIA VGA/3D controller devices
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x03[0-9]*", ATTR{power/control}="auto", ATTR{remove}="1"
'';
boot.blacklistedKernelModules = [
"nouveau"
"nvidia"
"nvidia_drm"
"nvidia_modeset"
];
}
+37
View File
@@ -0,0 +1,37 @@
{ lib, config, ... }:
{
imports = [ ./. ];
options = {
hardware.nvidia.primeBatterySaverSpecialisation = lib.mkEnableOption "configure a specialisation which turns on NVIDIA Prime battery saver";
};
config = {
hardware.nvidia.prime = {
offload = {
enable = lib.mkOverride 990 true;
enableOffloadCmd = lib.mkIf config.hardware.nvidia.prime.offload.enable true; # Provides `nvidia-offload` command.
};
# Hardware should specify the bus ID for intel/nvidia devices
};
specialisation = lib.mkIf config.hardware.nvidia.primeBatterySaverSpecialisation {
battery-saver.configuration = {
system.nixos.tags = [ "battery-saver" ];
imports = [
# Leave only the integrated GPU enabled
./disable.nix
];
hardware.nvidia = {
prime.offload.enable = lib.mkForce false;
powerManagement = {
enable = lib.mkForce false;
finegrained = lib.mkForce false;
};
};
};
};
};
}
+10
View File
@@ -0,0 +1,10 @@
{ lib, config, ... }:
let
nvidiaPackage = config.hardware.nvidia.package;
in
{
imports = [ ../. ];
# enable the open source drivers if the package supports it
hardware.nvidia.open = lib.mkOverride 990 (nvidiaPackage ? open && nvidiaPackage ? firmware);
}