default.nix
1 { inputs, config, pkgs, lib, ... }: let 2 3 hardware = config.modules.hardware; 4 5 in { 6 options.modules.hardware = { 7 cpu = { 8 amd = { 9 enable = lib.mkEnableOption "Enable AMD specific CPU config"; 10 }; 11 intel = { 12 enable = lib.mkEnableOption "Enable intel specific CPU config"; 13 }; 14 }; 15 16 gpu = { 17 amd = { 18 enable = lib.mkEnableOption "Enable AMD specific GPU config"; 19 busId = lib.mkOption { 20 type = lib.types.nonEmptyStr; 21 default = "PCI:4:0:0"; 22 }; 23 }; 24 nvidia = { 25 enable = lib.mkEnableOption "Enable nvidia specific GPU config"; 26 busId = lib.mkOption { 27 type = lib.types.nonEmptyStr; 28 default = "PCI:1:0:0"; 29 }; 30 }; 31 intel = { 32 enable = lib.mkEnableOption "Enable intel specific GPU config"; 33 busId = lib.mkOption { 34 type = lib.types.nonEmptyStr; 35 default = "PCI:0:2:0"; 36 }; 37 }; 38 }; 39 bluetooth = { 40 enable = lib.mkEnableOption "Enable bluetooth"; 41 }; 42 }; 43 44 config = { 45 hardware = { 46 cpu = { 47 amd = lib.mkIf hardware.cpu.amd.enable { 48 updateMicrocode = true; 49 }; 50 intel = lib.mkIf hardware.cpu.intel.enable { 51 updateMicrocode = true; 52 }; 53 }; 54 display = { 55 56 }; 57 graphics = { 58 enable = true; 59 }; 60 nvidia = lib.mkIf hardware.gpu.nvidia.enable { 61 # Modesetting is required. 62 modesetting.enable = true; 63 64 powerManagement = { 65 # Nvidia power management. Experimental, and can cause sleep/suspend to fail. 66 # Enable this if you have graphical corruption issues or application crashes after waking 67 # up from sleep. This fixes it by saving the entire VRAM memory to /tmp/ instead 68 # of just the bare essentials. 69 enable = true; 70 71 # Fine-grained power management. Turns off GPU when not in use. 72 # Experimental and only works on modern Nvidia GPUs (Turing or newer). 73 finegrained = false; 74 }; 75 # Use the NVidia open source kernel module (not to be confused with the 76 # independent third-party "nouveau" open source driver). 77 # Support is limited to the Turing and later architectures. Full list of 78 # supported GPUs is at: 79 # https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus 80 # Only available from driver 515.43.04+ 81 # Currently "beta quality", so false is currently the recommended setting. 82 open = false; 83 84 # Enable the Nvidia settings menu, 85 # accessible via `nvidia-settings`. 86 nvidiaSettings = false; 87 88 # Optionally, you may need to select the appropriate driver version for your specific GPU. 89 package = config.boot.kernelPackages.nvidiaPackages.beta; 90 91 prime = { 92 offload = { 93 enable = true; 94 enableOffloadCmd = true; 95 }; 96 nvidiaBusId = hardware.gpu.nvidia.busId; 97 intelBusId = hardware.gpu.intel.busId; 98 }; 99 }; 100 #extra devices 101 spacenavd = {}; 102 }; 103 services = { 104 fwupd.enable = true; 105 xserver.videoDrivers = lib.mkIf hardware.gpu.nvidia.enable ["nvidia"]; # Load "nvidia" driver for Xorg and Wayland - from the official wiki 106 }; 107 powerManagement = { 108 enable = true; 109 powertop.enable = true; 110 }; 111 environment = { 112 systemPackages = lib.mkIf hardware.gpu.nvidia.enable [ pkgs.nvtopPackages.nvidia ]; 113 }; 114 }; 115 imports = [ 116 ./bluetooth.nix 117 ./kmscon.nix 118 ./boot 119 ]; 120 }