thinkpad-x1g9.nix (3055B)
1 { config, pkgs, ... }: 2 { 3 # NixOS options 4 boot = { 5 blacklistedKernelModules = [ 6 "sierra_net" # sierra wireless modules 7 "cdc_mbim" # modem mobile broadband modules 8 "cdc_ncm" # similar 9 ]; 10 extraModprobeConfig = '' 11 options snd_hda_intel power_save=1 12 ''; 13 initrd = { 14 availableKernelModules = [ 15 "nvme" # required for nvme disks 16 "thunderbolt" # required for thunderbolt (dock, ...) 17 "dm-mod" 18 "cryptd" # required for encryption 19 "ahci" # sata controller, might not be needed 20 "xhci_pci" # usb controller related 21 "usb_storage" # usb storage related 22 "sd_mod" # block device related 23 "sdhci_pci" # block device related as well 24 "aesni-intel" # advanced encryption for intel 25 ]; 26 }; 27 loader.efi.canTouchEfiVariables = true; 28 }; 29 hardware = { 30 enableAllFirmware = true; 31 trackpoint.enable = false; 32 cpu.intel.updateMicrocode = true; 33 opengl.extraPackages = with pkgs; [ vaapiIntel libvdpau-va-gl vaapiVdpau intel-ocl intel-media-driver ]; 34 }; 35 services = { 36 hardware.bolt.enable = true; 37 # throttled.enable = true; # might not be needed 38 tlp = { 39 # FIXME: to disable 40 enable = false; 41 settings = { 42 # Charge threshold 43 # If the battery is used somewhat frequently, 44 # set the start threshold at around 85% and stop at 90%. This 45 # will still give a good lifespan benefit over keeping the 46 # battery charged to 100%. 47 START_CHARGE_THRESH_BAT0 = 75; 48 STOP_CHARGE_THRESH_BAT0 = 80; 49 # CPU optimizations 50 "CPU_SCALING_GOVERNOR_ON_AC" = "performance"; 51 "CPU_SCALING_GOVERNOR_ON_BAT" = "powersave"; 52 "PLATFORM_PROFILE_ON_AC" = "balanced"; # or performance ? 53 "PLATFORM_PROFILE_ON_BAT" = "low-power"; 54 "CPU_MIN_PERF_ON_AC" = 0; 55 "CPU_MAX_PERF_ON_AC" = 100; 56 "CPU_MIN_PERF_ON_BAT" = 0; 57 "CPU_MAX_PERF_ON_BAT" = 75; 58 # DEVICES (wifi, ..) 59 "DEVICES_TO_DISABLE_ON_STARTUP" = ""; 60 "DEVICES_TO_ENABLE_ON_AC" = "bluetooth wifi wwan"; 61 "DEVICES_TO_DISABLE_ON_BAT" = ""; 62 # Network management 63 "DEVICES_TO_DISABLE_ON_LAN_CONNECT" = "wifi"; 64 "DEVICES_TO_DISABLE_ON_WIFI_CONNECT" = ""; 65 "DEVICES_TO_DISABLE_ON_WWAN_CONNECT" = ""; 66 "DEVICES_TO_ENABLE_ON_LAN_DISCONNECT" = "wifi"; 67 "DEVICES_TO_ENABLE_ON_WIFI_DISCONNECT" = ""; 68 "DEVICES_TO_ENABLE_ON_WWAN_DISCONNECT" = ""; 69 # Docking 70 "DEVICES_TO_DISABLE_ON_DOCK" = "wifi"; 71 "DEVICES_TO_ENABLE_ON_UNDOCK" = "wifi"; 72 # Make sure it uses the right hard drive 73 "DISK_DEVICES" = "nvme0n1p1"; 74 }; 75 }; 76 udev.extraRules = '' 77 # Rules for Lenovo Thinkpad WS Dock 78 ACTION=="add", SUBSYSTEM=="thunderbolt", ATTR{authorized}=="0", ATTR{authorized}="1" 79 ACTION=="add", SUBSYSTEM=="backlight", KERNEL=="intel_backlight", MODE="0666", RUN+="${pkgs.coreutils}/bin/chmod a+w /sys/class/backlight/%k/brightness" 80 ''; 81 }; 82 }