summaryrefslogtreecommitdiffstats
path: root/nixos/modules/services/hardware/tuxedo-rs.nix
blob: 7fd96d7705efc09d7ac55d572f7f356f8b48bded (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
44
45
46
47
48
49
50
51
52
53
54
55
{
  config,
  lib,
  pkgs,
  ...
}:
let
  cfg = config.hardware.tuxedo-rs;

in
{
  options = {
    hardware.tuxedo-rs = {
      enable = lib.mkEnableOption "Rust utilities for interacting with hardware from TUXEDO Computers";

      tailor-gui.enable = lib.mkEnableOption "tailor-gui, an alternative to TUXEDO Control Center, written in Rust";
    };
  };

  config = lib.mkIf cfg.enable (
    lib.mkMerge [
      {
        hardware.tuxedo-drivers.enable = true;

        systemd = {
          services.tailord = {
            enable = true;
            description = "Tuxedo Tailor hardware control service";
            after = [ "systemd-logind.service" ];
            wantedBy = [ "multi-user.target" ];

            serviceConfig = {
              Type = "dbus";
              BusName = "com.tux.Tailor";
              ExecStart = "${pkgs.tuxedo-rs}/bin/tailord";
              Environment = "RUST_BACKTRACE=1";
              Restart = "on-failure";
            };
          };
        };

        services.dbus.packages = [ pkgs.tuxedo-rs ];

        environment.systemPackages = [ pkgs.tuxedo-rs ];
      }
      (lib.mkIf cfg.tailor-gui.enable {
        environment.systemPackages = [ pkgs.tailor-gui ];
      })
    ]
  );

  meta.maintainers = with lib.maintainers; [
    xaverdh
  ];
}