2023-01-10 02:59:44 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
2023-11-26 20:44:14 +00:00
|
|
|
inherit (lib) mkDefault mkEnableOption mkIf mkMerge mkOption types;
|
2023-01-10 02:59:44 +00:00
|
|
|
|
|
|
|
cfg = config.microsoft-surface.ipts;
|
|
|
|
|
2023-11-26 20:44:14 +00:00
|
|
|
iptsConfFile = pkgs.writeTextFile {
|
|
|
|
name = "iptsd.conf";
|
|
|
|
text = lib.generators.toINI { } cfg.config;
|
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
{
|
2023-01-10 02:59:44 +00:00
|
|
|
options.microsoft-surface.ipts = {
|
|
|
|
enable = mkEnableOption "Enable IPTSd for Microsoft Surface";
|
2023-11-26 20:44:14 +00:00
|
|
|
|
|
|
|
config = mkOption {
|
|
|
|
type = types.attrs;
|
|
|
|
default = { };
|
|
|
|
description = ''
|
|
|
|
Values to wrote to iptsd.conf, first key is section, second key is property.
|
|
|
|
See the example config; https://github.com/linux-surface/iptsd/blob/v1.4.0/etc/iptsd.conf
|
|
|
|
'';
|
|
|
|
example = ''
|
|
|
|
DFT = {
|
|
|
|
ButtonMinMag = 1000;
|
|
|
|
};
|
|
|
|
'';
|
|
|
|
};
|
2023-01-10 02:59:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkMerge [
|
|
|
|
{
|
|
|
|
microsoft-surface.ipts.enable = mkDefault false;
|
|
|
|
}
|
|
|
|
|
|
|
|
(mkIf cfg.enable {
|
|
|
|
systemd.services.iptsd = {
|
|
|
|
description = "IPTSD";
|
|
|
|
path = with pkgs; [ iptsd ];
|
2023-06-20 14:49:07 +00:00
|
|
|
script = "iptsd $(iptsd-find-hidraw)";
|
2023-01-10 02:59:44 +00:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
};
|
2023-11-26 20:44:14 +00:00
|
|
|
environment.etc."iptsd/iptsd.conf".source = "${iptsConfFile}";
|
2023-01-10 02:59:44 +00:00
|
|
|
})
|
|
|
|
];
|
|
|
|
}
|