Add garmin data scraper on a timer
This commit is contained in:
parent
3b47a9b9e0
commit
45d7da3983
6 changed files with 119 additions and 0 deletions
37
modules/services/garmin-scraper/default.nix
Normal file
37
modules/services/garmin-scraper/default.nix
Normal file
|
@ -0,0 +1,37 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
garmin2influx = pkgs.writers.writePython3Bin "garmin2influx" {
|
||||
libraries = with pkgs.python3Packages; [ garminconnect influxdb-client ];
|
||||
} (builtins.readFile ./garmin2influx.py);
|
||||
in
|
||||
{
|
||||
options.chvp.services.garmin-scraper.enable = lib.mkEnableOption "garmin scraper";
|
||||
|
||||
config = lib.mkIf config.chvp.services.garmin-scraper.enable {
|
||||
# Install in environment to allow manual data collection
|
||||
environment.systemPackages = [ garmin2influx ];
|
||||
systemd = {
|
||||
services.garmin2influx = {
|
||||
description = "Garmin health data importer";
|
||||
restartIfChanged = false;
|
||||
unitConfig.X-StopOnRemoval = false;
|
||||
serviceConfig = {
|
||||
EnvironmentFile = config.age.secrets."passwords/services/garmin2influx-env".path;
|
||||
Type = "oneshot";
|
||||
User = "charlotte";
|
||||
Group = "users";
|
||||
ExecStart = "${garmin2influx}/bin/garmin2influx";
|
||||
RestartSec = "5s";
|
||||
Restart = "on-failure";
|
||||
};
|
||||
startAt = "02/4:00";
|
||||
};
|
||||
timers.garmin2influx.timerConfig.RandomizedDelaySec = "30min";
|
||||
};
|
||||
age.secrets."passwords/services/garmin2influx-env" = {
|
||||
file = ../../../secrets/passwords/services/garmin2influx-env.age;
|
||||
owner = "charlotte";
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue