33 lines
978 B
Nix
33 lines
978 B
Nix
{config, lib, pkgs, ...}:
|
|
{
|
|
options.printer_scraping = {
|
|
enable = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = false;
|
|
description = "Enable the script to pull data from the printer"
|
|
};
|
|
timer = lib.mkOption {
|
|
type = lib.types.string;
|
|
default = "1m";
|
|
description = "systemd timer for script execution";
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf config.printer_scraping.enable {
|
|
systemd.services."printer-scraping" = {
|
|
description = "Pull printer stats and upload to influxdb";
|
|
serviceConfig.Type = "oneshot";
|
|
path = with pkgs; [yq curl];
|
|
script = "exec ${./pull_info.sh}";
|
|
};
|
|
systemd.timers."printer-scraping" = {
|
|
wantedBy = ["timers.target"];
|
|
timerConfig = {
|
|
OnBootSec = "60s";
|
|
OnUnitActiveSec = config.printer_scraping.timer;
|
|
Unit = "printer-scraping.service";
|
|
};
|
|
};
|
|
services.prometheus.pushgateway.enable = true; #Im not dealing with influx
|
|
};
|
|
} |