summary refs log tree commit diff
path: root/nixos/modules/services/monitoring/arbtt.nix
blob: 8bf4f78cc7279220008d5d79b4faa580ae81e403 (plain) (blame)
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
{ config, lib, pkgs, ... }:

with lib;

let
  cfg = config.services.arbtt;
in {
  options = {
    services.arbtt = {
      enable = mkOption {
        type = types.bool;
        default = false;
        description = lib.mdDoc ''
          Enable the arbtt statistics capture service.
        '';
      };

      package = mkOption {
        type = types.package;
        default = pkgs.haskellPackages.arbtt;
        defaultText = literalExpression "pkgs.haskellPackages.arbtt";
        description = lib.mdDoc ''
          The package to use for the arbtt binaries.
        '';
      };

      logFile = mkOption {
        type = types.str;
        default = "%h/.arbtt/capture.log";
        example = "/home/username/.arbtt-capture.log";
        description = lib.mdDoc ''
          The log file for captured samples.
        '';
      };

      sampleRate = mkOption {
        type = types.int;
        default = 60;
        example = 120;
        description = lib.mdDoc ''
          The sampling interval in seconds.
        '';
      };
    };
  };

  config = mkIf cfg.enable {
    systemd.user.services.arbtt = {
      description = "arbtt statistics capture service";
      wantedBy = [ "graphical-session.target" ];
      partOf = [ "graphical-session.target" ];

      serviceConfig = {
        Type = "simple";
        ExecStart = "${cfg.package}/bin/arbtt-capture --logfile=${cfg.logFile} --sample-rate=${toString cfg.sampleRate}";
        Restart = "always";
      };
    };
  };

  meta.maintainers = [ maintainers.michaelpj ];
}