nixos-config/modules/hardware/surface-pro6.nix

118 lines
3.4 KiB
Nix

{ pkgs, ... }:
let
fetchpatch = pkgs.fetchpatch;
commit = "f69eefacf7304857f8c0ce7ac0ebf4971121da72";
mkPatch = name: sha256: {
name = name;
patch = fetchpatch {
name = name + ".patch";
url = "https://raw.githubusercontent.com/linux-surface/linux-surface/${commit}/patches/5.13/${name}.patch";
sha256 = sha256;
};
};
in {
environment.etc."ipts.conf".text = ''
[Config]
BlockOnPalm = true
'';
systemd.services.iptsd = {
description = "Userspace daemon for Intel Precise Touch & Stylus";
wantedBy = [ "multi-user.target" ];
wants = [ "dev-ipts-15.device" ];
after = [ "dev-ipts-15.device" ];
serviceConfig = {
Type = "simple";
ExecStart = "${pkgs.iptsd}/bin/iptsd";
};
};
environment.systemPackages = with pkgs; [ iptsd surface-control ];
services.udev.packages = with pkgs; [ iptsd surface-control ];
boot = {
kernelPackages = pkgs.linuxPackages_5_13;
kernelPatches = [
(mkPatch "0001-surface3-oemb" "1h5f4qgrv74x8q02f29xfia9imcm6svh5gv5vb5izxx6w5i6c9fh")
#(mkPatch "0002-mwifiex" "1qn5lqhbg67j1226msiijq42zdjwmvxzyfd5q366hlczcsw7a7r2")
(mkPatch "0003-ath10k" "0zwyb1vksh6sjbwy5fp2c108m6fqzrv78cz3a296cff550ldn0fj")
(mkPatch "0004-ipts" "0ap5li17zyvba1zx4ryyyk42m00rg5ympj2n24g5ylrld0n2xc3x")
(mkPatch "0005-surface-sam-over-hid" "1vm4v84zbyiiqwby3cr7n8ffibx072rb7rhrl5hv37dsdr03gsa3")
(mkPatch "0006-surface-sam" "1fi0w9bnfnwllmypk3llc58dmfsvx34772g8c52dgi4h9wsgnbhj")
(mkPatch "0007-surface-hotplug" "0g3fkc12pc15aqq6nqk1zfp99lj1wj7cgc1n9691bp8fhqx5aj28")
(mkPatch "0008-surface-typecover" "0803nd0w5rv17kwk3y577pm22zwzpcb52ddlkanm7jrbsrhk130f")
#(mkPatch "0009-cameras" "1i5c16bx8drzagv5nkvmsyixvsz3w75lblabsmgxlh1znxsh7cj5")
(mkPatch "0010-amd-gpio" "0qibdak0ivsch0r5kxd5hhmvw7rd75xy9mmxjbcmysv8q2y9m6hn") # TODO: Maybe drop
(mkPatch "0011-amd-s0ix" "0awv32wqwkjsxs1bhg82rqq3c4ni2f9vsdm7iscilbad28ngdab8") # TODO: Maybe drop
{
name = "surface-config";
patch = null;
# Options from https://github.com/linux-surface/linux-surface/blob/master/configs/surface-5.13.config
extraConfig = ''
#
# Surface Aggregator Module
#
SURFACE_AGGREGATOR m
SURFACE_AGGREGATOR_ERROR_INJECTION n
SURFACE_AGGREGATOR_BUS y
SURFACE_AGGREGATOR_CDEV m
SURFACE_AGGREGATOR_REGISTRY m
SURFACE_ACPI_NOTIFY m
SURFACE_DTX m
SURFACE_PLATFORM_PROFILE m
SURFACE_HID m
SURFACE_KBD m
BATTERY_SURFACE m
CHARGER_SURFACE m
#
# Surface Hotplug
#
SURFACE_HOTPLUG m
#
# IPTS touchscreen
#
# This only enables the user interface for IPTS data.
# For the touchscreen to work, you need to install iptsd.
#
MISC_IPTS m
#
# Cameras: IPU3
#
#VIDEO_IPU3_IMGU m
VIDEO_IPU3_CIO2 m
CIO2_BRIDGE y
#INTEL_SKL_INT3472 m
#
# Cameras: Sensor drivers
#
#VIDEO_OV5693 m
VIDEO_OV8865 m
#
# ALS Sensor for Surface Book 3, Surface Laptop 3, Surface Pro 7
#
APDS9960 m
#
# Other Drivers
#
INPUT_SOC_BUTTON_ARRAY m
SURFACE_3_BUTTON m
SURFACE_3_POWER_OPREGION m
SURFACE_PRO3_BUTTON m
SURFACE_GPE m
SURFACE_BOOK1_DGPU_SWITCH m
'';
}
];
};
}