Add module.nix
This commit is contained in:
33
module.nix
Normal file
33
module.nix
Normal file
@@ -0,0 +1,33 @@
|
||||
{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
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user