aboutsummaryrefslogtreecommitdiff
path: root/hardware/thinkpad-e14/default.nix
blob: a8f5329fc7f818a5e9d8a9a44f3079608acb091c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
{ config, lib, pkgs, modulesPath, ... }:
{
  imports = [
    (modulesPath + "/installer/scan/not-detected.nix")
  ];

  services.fwupd.enable = true;

  # boot.kernelPackages = pkgs.linuxPackages_6_9;
  boot.kernelPackages = pkgs.linuxPackages_xanmod_stable;
  boot.initrd = {
    availableKernelModules = [
      "xhci_pci"
      "ahci"
      "nvme"
      "usb_storage"
      "thunderbolt"
      "sd_mod"
    ];
    kernelModules = [ "i915" ];
  };
  boot.kernelModules = [
    "kvm-intel"
    "rtw88_8822ce"
    "sd_mod"
    "snd-seq"
    "snd-rawmidi"
    "uinput"
    "v4l2loopback"
    "acpi_call"
    "thinkpad_acpi"
    "coretemp"
  ];
  boot.extraModulePackages = with config.boot.kernelPackages; [
    acpi_call
    v4l2loopback
  ];
  boot.kernelParams = [
    "i8042.nopnp=1"
    "pci=nocrs"
    "acpi_osi=linux"
    "acpi_backlight=native"
    "i915.enable_dpcd_backlight=0"
    "i915.enable_guc=2"
    # "acpi_backlight=vendor"
    # "acpi_backlight=intel_backlight"
    # "i915.force_probe=46a8"
  ];
  boot.extraModprobeConfig = ''
    options snd slots=snd-hda-intel
    options v4l2loopback exclusive_caps=1 card_label="Virtual Camera"
    options thinkpad_acpi experimental=1 fan_control=1
  '';
  boot.supportedFilesystems = [ "ntfs" ];
  # boot.binfmt.emulatedSystems = [ "aarch64-linux" ];

  services.throttled.enable = true;
  services.thermald = {
    enable = true;
    ignoreCpuidCheck = true;
  };

  services.udev = {
    packages = with pkgs; [
      alsa-utils
      android-udev-rules
      platformio-core.udev
      openocd
    ];
  };

  environment.systemPackages = with pkgs; [
    mesa
    xorg.xf86inputlibinput
    xorg.xf86videointel
  ];
  # services.xserver.videoDrivers = [ "intel" ];

  hardware = {
    enableAllFirmware = true;
    cpu.intel.updateMicrocode = true;
  };

  nixpkgs.config.packageOverrides = pkgs: {
    vaapiIntel = pkgs.vaapiIntel.override { enableHybridCodec = true; };
  };
  hardware.graphics = {
    enable = true;
    # enable32Bit = true;
    # driSupport = true;
    # driSupport32Bit = true;
    extraPackages = with pkgs; [
      intel-media-driver
      # intel-vaapi-driver
      vaapiIntel
      vaapiVdpau
      libvdpau-va-gl
      intel-gmmlib
      vulkan-tools
      mesa.drivers
    ];
  };
  environment.variables = {
    VDPAU_DRIVER = "va_gl";
    LIBVA_DRIVER_NAME = "iHD";
  };
  # services.xserver.videoDrivers = [ "intel" ];

  # Bootloader
  boot.loader = {
    systemd-boot = {
      enable = true;
      configurationLimit = 30;
    };
    timeout = 1;
    efi.canTouchEfiVariables = true;
  };

  # File system
  boot.initrd.luks.devices."crypted".device = "/dev/disk/by-uuid/17ac9757-d710-4456-9a94-7b6086a35638";
  fileSystems = {
    "/" = {
      device = "/dev/mapper/crypted";
      fsType = "ext4";
    };
    "/boot" = {
      device = "/dev/disk/by-label/boot";
      fsType = "vfat";
    };
  };
  swapDevices = [{ device = "/dev/disk/by-label/swap"; }];

  nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
  networking.useDHCP = lib.mkDefault true;
  powerManagement = {
    enable = false;
    cpuFreqGovernor = "powersave";
  };

  services.tlp.enable = lib.mkDefault false;
}