1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6 cfg = config.services.arbtt;
7in {
8 options = {
9 services.arbtt = {
10 enable = mkOption {
11 type = types.bool;
12 default = false;
13 description = ''
14 Enable the arbtt statistics capture service.
15 '';
16 };
17
18 package = mkOption {
19 type = types.package;
20 default = pkgs.haskellPackages.arbtt;
21 defaultText = literalExpression "pkgs.haskellPackages.arbtt";
22 description = ''
23 The package to use for the arbtt binaries.
24 '';
25 };
26
27 logFile = mkOption {
28 type = types.str;
29 default = "%h/.arbtt/capture.log";
30 example = "/home/username/.arbtt-capture.log";
31 description = ''
32 The log file for captured samples.
33 '';
34 };
35
36 sampleRate = mkOption {
37 type = types.int;
38 default = 60;
39 example = 120;
40 description = ''
41 The sampling interval in seconds.
42 '';
43 };
44 };
45 };
46
47 config = mkIf cfg.enable {
48 systemd.user.services.arbtt = {
49 description = "arbtt statistics capture service";
50 wantedBy = [ "graphical-session.target" ];
51 partOf = [ "graphical-session.target" ];
52
53 serviceConfig = {
54 Type = "simple";
55 ExecStart = "${cfg.package}/bin/arbtt-capture --logfile=${cfg.logFile} --sample-rate=${toString cfg.sampleRate}";
56 Restart = "always";
57 };
58 };
59 };
60
61 meta.maintainers = [ maintainers.michaelpj ];
62}