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 = "pkgs.haskellPackages.arbtt";
22 example = literalExample "pkgs.haskellPackages.arbtt";
23 description = ''
24 The package to use for the arbtt binaries.
25 '';
26 };
27
28 logFile = mkOption {
29 type = types.str;
30 default = "%h/.arbtt/capture.log";
31 example = "/home/username/.arbtt-capture.log";
32 description = ''
33 The log file for captured samples.
34 '';
35 };
36
37 sampleRate = mkOption {
38 type = types.int;
39 default = 60;
40 example = 120;
41 description = ''
42 The sampling interval in seconds.
43 '';
44 };
45 };
46 };
47
48 config = mkIf cfg.enable {
49 systemd.user.services.arbtt = {
50 description = "arbtt statistics capture service";
51 wantedBy = [ "graphical-session.target" ];
52 partOf = [ "graphical-session.target" ];
53
54 serviceConfig = {
55 Type = "simple";
56 ExecStart = "${cfg.package}/bin/arbtt-capture --logfile=${cfg.logFile} --sample-rate=${toString cfg.sampleRate}";
57 Restart = "always";
58 };
59 };
60 };
61
62 meta.maintainers = [ maintainers.michaelpj ];
63}