This repository was archived by the owner on Apr 26, 2024. It is now read-only.
forked from blitz/tuxedo-nixos
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmodule.nix
99 lines (81 loc) · 2.93 KB
/
module.nix
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
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.hardware.tuxedo-control-center;
tuxedo-keyboard = config.boot.kernelPackages.tuxedo-keyboard;
tuxedo-control-center = pkgs.callPackage ./tuxedo-control-center {};
in
{
options.hardware.tuxedo-control-center = {
enable = mkEnableOption ''
Tuxedo Control Center, the official fan and power management UI
for Tuxedo laptops.
This module does not offer any hardcoded configuration. So you
will get the default configuration until you change it in the
Tuxedo Control Center.
'';
package = mkOption {
type = types.package;
default = tuxedo-control-center;
defaultText = "pkgs.tuxedo-control-center";
description = ''
Which package to use for tuxedo-control-center.
'';
};
};
config = mkIf cfg.enable {
hardware.tuxedo-keyboard.enable = true;
boot.kernelModules = [
# Tuxedo Control Center has a requirement on the minimum version
# of "tuxedo_io" kernel module.
# The exact requirement is currently in the
# "src/native-lib/tuxedo_io_lib/tuxedo_io_ioctl.h" file of tuxedo-control-center
# (i.e. the #define of MOD_API_MIN_VERSION).
# The respective version of the module itself is in the
# "src/tuxedo_io/tuxedo_io.c" file of tuxedo-keyboard
# (i.e. the #define of MODULE_VERSION).
(warnIf
((builtins.compareVersions tuxedo-keyboard.version "3.1.2") < 0)
"Tuxedo Control Center requires at least version 3.1.2 of tuxedo-keyboard (0.2.6 tuxedo_io kernel module); current version is ${tuxedo-keyboard.version}"
"tuxedo_io")
];
environment.systemPackages = [ cfg.package ];
services.dbus.packages = [ cfg.package ];
# See https://github.com/tuxedocomputers/tuxedo-control-center/issues/148
nixpkgs.config.permittedInsecurePackages = [
"electron-13.6.9"
"nodejs-14.21.3"
"openssl-1.1.1t"
"openssl-1.1.1u"
"openssl-1.1.1v"
"openssl-1.1.1w"
];
systemd.services.tccd = {
# tccd uses ps, xargs
# (note: this is a hack, but replacing 'ps' and 'xargs' in some
# string in a typescript file isn't any less hacky I guess)
path = with pkgs; [ cfg.package procps findutils ];
description = "Tuxedo Control Center Service";
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "simple";
ExecStart = "${cfg.package}/bin/tccd --start";
ExecStop = "${cfg.package}/bin/tccd --stop";
};
};
systemd.services.tccd-sleep = {
path = [ cfg.package ];
description = "Tuxedo Control Center Service (sleep/resume)";
wantedBy = [ "sleep.target" ];
unitConfig = {
StopWhenUnneeded = "yes";
};
serviceConfig = {
Type = "oneshot";
RemainAfterExit = "yes";
ExecStart = "systemctl stop tccd";
ExecStop = "systemctl start tccd";
};
};
};
}