summaryrefslogtreecommitdiffstats
path: root/nixos/modules/hardware/apple-touchbar.nix
blob: 700ef173a9071c55478b4e37d70d5070e8e6bd3c (plain)
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
{
  config,
  lib,
  pkgs,
  ...
}:

let
  cfg = config.hardware.apple.touchBar;
  format = pkgs.formats.toml { };
  cfgFile = format.generate "config.toml" cfg.settings;
in
{
  options.hardware.apple.touchBar = {
    enable = lib.mkEnableOption "support for the Touch Bar on some Apple laptops using tiny-dfr";
    package = lib.mkPackageOption pkgs "tiny-dfr" { };

    settings = lib.mkOption {
      type = format.type;
      default = { };
      description = ''
        Configuration for tiny-dfr. See [example configuration][1] for available options.

        [1]: https://github.com/WhatAmISupposedToPutHere/tiny-dfr/blob/master/share/tiny-dfr/config.toml
      '';
      example = lib.literalExpression ''
        {
          MediaLayerDefault = true;
          ShowButtonOutlines = false;
          EnablePixelShift = true;
        }
      '';
    };
  };

  config = lib.mkIf cfg.enable {
    systemd.packages = [ cfg.package ];
    services.udev.packages = [ cfg.package ];

    environment.etc."tiny-dfr/config.toml".source = cfgFile;
    systemd.services.tiny-dfr.restartTriggers = [ cfgFile ];
  };
}