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