···
7
-
inherit (lib) mkOption types;
9
-
toml = pkgs.formats.toml {};
10
-
filterConfig = lib.filterAttrsRecursive (_: v: v != null);
11
-
configFile = toml.generate "tiny-dfr.conf" (filterConfig cfg.settings);
13
-
cfg = config.services.tiny-dfr;
16
-
services.tiny-dfr = {
17
-
enable = lib.mkEnableOption "tiny-dfr, a tiny Apple touchbar daemon";
18
-
package = lib.mkPackageOption pkgs "tiny-dfr" {};
20
-
settings = mkOption {
22
-
Freeform settings for tiny-dfr.
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.
27
-
Passing `null` as a value will cause the key to not be set and the value from the template to be used.
30
-
type = types.submodule {
31
-
freeformType = toml.type;
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;
39
-
ShowButtonOutlines = mkOption {
40
-
description = "Whether to show the outline around icons.";
41
-
type = types.nullOr types.bool;
45
-
EnablePixelShift = mkOption {
46
-
description = "Shift the entire touchbar screen by a small amount periodically.";
47
-
type = types.nullOr types.bool;
51
-
FontTemplate = mkOption {
53
-
The fontconfig pattern to use.
55
-
See the "Font Names" section in [the fontconfig docs](https://www.freedesktop.org/software/fontconfig/fontconfig-user.html)
56
-
for more information.
58
-
type = types.nullOr types.str;
62
-
AdaptiveBrightness = mkOption {
63
-
description = "Whether the touchbar screen should follow the primary screen's brightness.";
64
-
type = types.nullOr types.bool;
68
-
ActiveBrightness = mkOption {
69
-
description = "The brightness to use when adaptive brightness is disabled.";
70
-
type = types.nullOr types.ints.u8;
80
-
config = lib.mkIf cfg.enable {
81
-
services.udev.packages = [cfg.package];
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"
92
-
description = "Tiny Apple Silicon touch bar daemon";
95
-
"systemd-user-sessions.service"
96
-
"getty@tty1.service"
97
-
"plymouth-quit.service"
98
-
"systemd-logind.service"
100
-
++ backlightDevices;
101
-
bindsTo = backlightDevices;
102
-
startLimitIntervalSec = 30;
103
-
startLimitBurst = 2;
104
-
restartTriggers = [
111
-
ExecStart = lib.getExe cfg.package;
116
-
"systemd-backlight@backlight:228200000.display-pipe.0.service" = {};
117
-
"systemd-backlight@backlight:appletb_backlight.service" = {};
120
-
environment.etc."tiny-dfr/config.toml" = {
121
-
source = configFile;
125
-
meta.maintainers = with lib.maintainers; [soopyc];