modules/.gitkeep
modules/.gitkeep
This is a binary file and will not be displayed.
-126
modules/tiny-dfr/default.nix
-126
modules/tiny-dfr/default.nix
···
1
-
{
2
-
config,
3
-
pkgs,
4
-
lib,
5
-
...
6
-
}: let
7
-
inherit (lib) mkOption types;
8
-
9
-
toml = pkgs.formats.toml {};
10
-
filterConfig = lib.filterAttrsRecursive (_: v: v != null);
11
-
configFile = toml.generate "tiny-dfr.conf" (filterConfig cfg.settings);
12
-
13
-
cfg = config.services.tiny-dfr;
14
-
in {
15
-
options = {
16
-
services.tiny-dfr = {
17
-
enable = lib.mkEnableOption "tiny-dfr, a tiny Apple touchbar daemon";
18
-
package = lib.mkPackageOption pkgs "tiny-dfr" {};
19
-
20
-
settings = mkOption {
21
-
description = ''
22
-
Freeform settings for tiny-dfr.
23
-
24
-
See [the template config](https://github.com/WhatAmISupposedToPutHere/tiny-dfr/blob/master/share/tiny-dfr/config.toml)
25
-
for a list of available options.
26
-
27
-
Passing `null` as a value will cause the key to not be set and the value from the template to be used.
28
-
'';
29
-
default = {};
30
-
type = types.submodule {
31
-
freeformType = toml.type;
32
-
options = {
33
-
MediaLayerDefault = mkOption {
34
-
description = "Whether the media layer (non-Fn keys) should be displayed by default. Hold the fn key to change layers.";
35
-
type = types.nullOr types.bool;
36
-
default = false;
37
-
example = true;
38
-
};
39
-
ShowButtonOutlines = mkOption {
40
-
description = "Whether to show the outline around icons.";
41
-
type = types.nullOr types.bool;
42
-
default = true;
43
-
example = false;
44
-
};
45
-
EnablePixelShift = mkOption {
46
-
description = "Shift the entire touchbar screen by a small amount periodically.";
47
-
type = types.nullOr types.bool;
48
-
default = false;
49
-
example = true;
50
-
};
51
-
FontTemplate = mkOption {
52
-
description = ''
53
-
The fontconfig pattern to use.
54
-
55
-
See the "Font Names" section in [the fontconfig docs](https://www.freedesktop.org/software/fontconfig/fontconfig-user.html)
56
-
for more information.
57
-
'';
58
-
type = types.nullOr types.str;
59
-
default = "";
60
-
example = ":bold";
61
-
};
62
-
AdaptiveBrightness = mkOption {
63
-
description = "Whether the touchbar screen should follow the primary screen's brightness.";
64
-
type = types.nullOr types.bool;
65
-
default = null;
66
-
example = true;
67
-
};
68
-
ActiveBrightness = mkOption {
69
-
description = "The brightness to use when adaptive brightness is disabled.";
70
-
type = types.nullOr types.ints.u8;
71
-
default = null;
72
-
example = 155;
73
-
};
74
-
};
75
-
};
76
-
};
77
-
};
78
-
};
79
-
80
-
config = lib.mkIf cfg.enable {
81
-
services.udev.packages = [cfg.package];
82
-
83
-
# TODO: migrate to systemd.packages
84
-
systemd.services.tiny-dfr = let
85
-
backlightDevices = [
86
-
"dev-tiny_dfr_display.device"
87
-
"dev-tiny_dfr_backlight.device"
88
-
"dev-tiny_dfr_display_backlight.device"
89
-
];
90
-
in {
91
-
enable = true;
92
-
description = "Tiny Apple Silicon touch bar daemon";
93
-
after =
94
-
[
95
-
"systemd-user-sessions.service"
96
-
"getty@tty1.service"
97
-
"plymouth-quit.service"
98
-
"systemd-logind.service"
99
-
]
100
-
++ backlightDevices;
101
-
bindsTo = backlightDevices;
102
-
startLimitIntervalSec = 30;
103
-
startLimitBurst = 2;
104
-
restartTriggers = [
105
-
cfg.package
106
-
configFile
107
-
];
108
-
109
-
serviceConfig = {
110
-
Type = "simple";
111
-
ExecStart = lib.getExe cfg.package;
112
-
};
113
-
};
114
-
115
-
systemd.units = {
116
-
"systemd-backlight@backlight:228200000.display-pipe.0.service" = {};
117
-
"systemd-backlight@backlight:appletb_backlight.service" = {};
118
-
};
119
-
120
-
environment.etc."tiny-dfr/config.toml" = {
121
-
source = configFile;
122
-
};
123
-
};
124
-
125
-
meta.maintainers = with lib.maintainers; [soopyc];
126
-
}