2021-11-01 20:33:21 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
2021-09-03 13:17:43 +00:00
|
|
|
|
|
|
|
let
|
2021-11-01 20:33:21 +00:00
|
|
|
cfg = config.ptw.hardware.surface;
|
2022-01-06 13:27:12 +00:00
|
|
|
fetchurl = pkgs.fetchurl;
|
|
|
|
commit = "69d1e5826e6380c8ff0cd532e244482097562c3d";
|
2021-09-03 13:17:43 +00:00
|
|
|
in {
|
2021-11-01 20:33:21 +00:00
|
|
|
options.ptw.hardware.surface = {
|
|
|
|
enable = lib.mkEnableOption "Enable support for the Microsoft Surface Pro 6";
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
environment.etc = {
|
|
|
|
"ipts.conf".text = ''
|
2021-09-07 13:40:07 +00:00
|
|
|
[Config]
|
|
|
|
BlockOnPalm = true
|
|
|
|
'';
|
2021-11-01 20:33:21 +00:00
|
|
|
"thermald/thermal-cpu-cdev-order.xml".source = fetchurl {
|
|
|
|
url = "https://raw.githubusercontent.com/linux-surface/linux-surface/${commit}/contrib/thermald/surface_pro_5/thermal-conf.xml.auto.mobile";
|
|
|
|
sha256 = "1wsrgad6k4haw4m0jjcjxhmj4742kcb3q8rmfpclbw0czm8384al";
|
|
|
|
};
|
2021-10-21 21:37:31 +00:00
|
|
|
};
|
2021-09-05 11:26:29 +00:00
|
|
|
|
2021-11-01 20:33:21 +00:00
|
|
|
powerManagement = {
|
2021-09-07 13:40:07 +00:00
|
|
|
enable = true;
|
2021-11-01 20:33:21 +00:00
|
|
|
cpuFreqGovernor = "powersave";
|
|
|
|
};
|
|
|
|
hardware.video.hidpi.enable = true;
|
|
|
|
|
2022-01-06 13:27:12 +00:00
|
|
|
systemd.services.iptsd = lib.mkForce {
|
2021-11-01 20:33:21 +00:00
|
|
|
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 ];
|
|
|
|
thermald = {
|
|
|
|
enable = true;
|
|
|
|
configFile = fetchurl {
|
|
|
|
url = "https://raw.githubusercontent.com/linux-surface/linux-surface/${commit}/contrib/thermald/thermal-conf.xml";
|
|
|
|
sha256 = "1xj70n9agy41906jgm4yjmsx58i7pzsizpvv3rkzq78k95qjfmc9";
|
|
|
|
};
|
2021-09-07 13:40:07 +00:00
|
|
|
};
|
|
|
|
};
|
2021-09-03 13:17:43 +00:00
|
|
|
|
2021-11-01 20:33:21 +00:00
|
|
|
boot = {
|
|
|
|
kernelPatches = [
|
|
|
|
{
|
|
|
|
name = "surface-config";
|
|
|
|
patch = null;
|
|
|
|
# Options from https://github.com/linux-surface/linux-surface/blob/master/configs/surface-5.13.config
|
|
|
|
extraConfig = ''
|
2022-01-06 13:15:28 +00:00
|
|
|
#
|
|
|
|
# Other
|
|
|
|
#
|
|
|
|
# Prevent a non-fatal "kernel oops" at boot crashing udev
|
|
|
|
# (https://github.com/linux-surface/linux-surface/issues/61#issuecomment-579298172)
|
|
|
|
PINCTRL_INTEL y
|
|
|
|
PINCTRL_SUNRISEPOINT y
|
|
|
|
# Required for reading battery data
|
|
|
|
# (https://github.com/linux-surface/surface-aggregator-module/wiki/Testing-and-Installing)
|
|
|
|
SERIAL_DEV_BUS y
|
|
|
|
SERIAL_DEV_CTRL_TTYPORT y
|
|
|
|
MFD_INTEL_LPSS_PCI y
|
|
|
|
INTEL_IDMA64 y
|
|
|
|
'';
|
2021-11-01 20:33:21 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
2021-09-03 13:17:43 +00:00
|
|
|
};
|
|
|
|
}
|