at 25.11-pre 1.1 kB view raw
1{ config, lib, ... }: 2 3let 4 kernel = config.boot.kernelPackages; 5in 6 7{ 8 9 ###### interface 10 11 options = { 12 13 hardware.nvidiaOptimus.disable = lib.mkOption { 14 default = false; 15 type = lib.types.bool; 16 description = '' 17 Completely disable the NVIDIA graphics card and use the 18 integrated graphics processor instead. 19 ''; 20 }; 21 22 }; 23 24 ###### implementation 25 26 config = lib.mkIf config.hardware.nvidiaOptimus.disable { 27 boot.blacklistedKernelModules = [ 28 "nouveau" 29 "nvidia" 30 "nvidiafb" 31 "nvidia-drm" 32 "nvidia-modeset" 33 ]; 34 boot.kernelModules = [ "bbswitch" ]; 35 boot.extraModulePackages = [ kernel.bbswitch ]; 36 37 systemd.services.bbswitch = { 38 description = "Disable NVIDIA Card"; 39 wantedBy = [ "multi-user.target" ]; 40 serviceConfig = { 41 Type = "oneshot"; 42 RemainAfterExit = true; 43 ExecStart = "${kernel.bbswitch}/bin/discrete_vga_poweroff"; 44 ExecStop = "${kernel.bbswitch}/bin/discrete_vga_poweron"; 45 }; 46 path = [ kernel.bbswitch ]; 47 }; 48 }; 49 50}