|
| 1 | +{ lib, pkgs, ... }: |
| 2 | + |
| 3 | +{ |
| 4 | + imports = [ |
| 5 | + ../../../common/cpu/intel/meteor-lake |
| 6 | + ../../../common/pc/laptop |
| 7 | + ../../../common/pc/ssd |
| 8 | + ]; |
| 9 | + |
| 10 | + boot = { |
| 11 | + # Workaround: Out of the box, resuming from hibernation will break sounds. |
| 12 | + # See https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues/766 |
| 13 | + extraModprobeConfig = '' |
| 14 | + options snd-hda-intel model=generic |
| 15 | + options snd-hda-intel snd-intel-dspcfg.dsp_driver=1 |
| 16 | + blacklist snd_soc_skl |
| 17 | + ''; |
| 18 | + |
| 19 | + kernelParams = [ |
| 20 | + # Workaround: i915 0000:00:02.0: [drm] *ERROR* Atomic update failure on pipe A |
| 21 | + # See https://www.dedoimedo.com/computers/intel-microcode-atomic-update.html |
| 22 | + "i915.enable_psr=0" |
| 23 | + |
| 24 | + # Workaround: Seems like guc on VT-d is faulty and may also cause GUC: TLB invalidation response timed out. |
| 25 | + # It will cause random gpu resets under hw video decoding. |
| 26 | + # See https://wiki.archlinux.org/title/Dell_XPS_16_(9640)#Random_freezes |
| 27 | + "iommu.strict=1" |
| 28 | + "iommu.passthrough=1" |
| 29 | + ]; |
| 30 | + }; |
| 31 | + |
| 32 | + environment.variables = { |
| 33 | + # Workaround: GPU HANG: ecode 12:1:85dffdfb, in CanvasRenderer [4408] |
| 34 | + # See https://gitlab.freedesktop.org/mesa/mesa/-/issues/7755 |
| 35 | + INTEL_DEBUG = "no32"; |
| 36 | + }; |
| 37 | + |
| 38 | + systemd = { |
| 39 | + # Workaround: Sometimes xhci driver will become malfunctional after resuming from hibernate / suspend. |
| 40 | + # This will cause (almost) all external devices stop working. |
| 41 | + # A simple reset is enough to bring external devices alive :) |
| 42 | + # |
| 43 | + # Note: to avoid unnecessary resets, we firstly check if integrated camera is presented |
| 44 | + # (Should always be there as it was built into machine!). |
| 45 | + # If not, just do the reset. |
| 46 | + services.workaround-reset-xhci-driver-after-resume-if-needed = { |
| 47 | + script = '' |
| 48 | + result=$(${pkgs.usbutils}/bin/lsusb | ${pkgs.gnugrep}/bin/grep Chicony) |
| 49 | + if [[ -z $result ]]; then |
| 50 | + ${pkgs.kmod}/bin/rmmod xhci_pci xhci_hcd |
| 51 | + ${pkgs.kmod}/bin/modprobe xhci_pci xhci_hcd |
| 52 | + fi |
| 53 | + ''; |
| 54 | + after = [ |
| 55 | + "suspend.target" |
| 56 | + "hibernate.target" |
| 57 | + "hybrid-sleep.target" |
| 58 | + ]; |
| 59 | + wantedBy = [ |
| 60 | + "suspend.target" |
| 61 | + "hibernate.target" |
| 62 | + "hybrid-sleep.target" |
| 63 | + "multi-user.target" |
| 64 | + ]; |
| 65 | + }; |
| 66 | + |
| 67 | + # Workaround: Lenovo seems write bad acpi power management firmware. Without this config, |
| 68 | + # suspend (to ram / disk) will simply reboot instead of power off. :( |
| 69 | + sleep.extraConfig = '' |
| 70 | + HibernateMode=shutdown |
| 71 | + ''; |
| 72 | + }; |
| 73 | + |
| 74 | + # TPM2 module |
| 75 | + security.tpm2.enable = lib.mkDefault true; |
| 76 | + |
| 77 | + hardware = { |
| 78 | + enableRedistributableFirmware = lib.mkDefault true; # WiFi |
| 79 | + |
| 80 | + # Workaround: Lenovo wrote bad screen edid firmware that will cause system |
| 81 | + # not able to use 120Hz screen fresh rate. |
| 82 | + # Manually patch it with correct value fixes this problem. |
| 83 | + # |
| 84 | + # TODO: This laptop actually support VRR (Variable refresh rate). |
| 85 | + # But I do not have any interests in supporting this. |
| 86 | + # PR is welecomed :) |
| 87 | + display = { |
| 88 | + edid.packages = [ |
| 89 | + (pkgs.runCommand "edid-14imh9" { } '' |
| 90 | + mkdir -p "$out/lib/firmware/edid" |
| 91 | + base64 -d > "$out/lib/firmware/edid/14imh9.bin" <<'EOF' |
| 92 | + AP///////wAObxYUAAAAAAAgAQS1HhN4AyEVqFNJnCUPUFQAAAABAQEBAQEBAQEBAQEBAQEBzodAoLAIanAwIDYALbwQAAAYAAAA/QAoeOXlRgEKICAgICAgAAAA/gBDU09UIFQzCiAgICAgAAAA/gBNTkUwMDdaQTEtNQogAa9wE3kAAAMBFJoPAQU/C58ALwAfAAcHaQACAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD4kA== |
| 93 | + EOF |
| 94 | + '') |
| 95 | + ]; |
| 96 | + |
| 97 | + outputs = { |
| 98 | + "eDP-1".edid = "14imh9.bin"; |
| 99 | + }; |
| 100 | + }; |
| 101 | + |
| 102 | + i2c.enable = lib.mkDefault true; # Touchpad |
| 103 | + }; |
| 104 | + |
| 105 | + services = { |
| 106 | + fwupd.enable = lib.mkDefault true; # Firmware Upgrades. Partially supported. |
| 107 | + hardware.bolt.enable = lib.mkDefault true; # Thunderbolt |
| 108 | + thermald.enable = lib.mkDefault true; # This will save you money and possibly your life! |
| 109 | + }; |
| 110 | +} |
0 commit comments