2018-03-28 11:07:35 +02:00
|
|
|
{ pkgs, lib, ...}:
|
2023-06-30 10:00:32 +02:00
|
|
|
with pkgs.stockholm.lib;
|
2018-03-28 11:07:35 +02:00
|
|
|
let
|
|
|
|
pkg = with pkgs.python3Packages;buildPythonPackage rec {
|
2020-02-19 13:58:40 +01:00
|
|
|
rev = "56d41de8219adc";
|
2018-04-04 14:46:15 +02:00
|
|
|
name = "arafetch-${rev}";
|
2018-03-28 11:07:35 +02:00
|
|
|
propagatedBuildInputs = [
|
|
|
|
requests
|
|
|
|
docopt
|
|
|
|
influxdb
|
|
|
|
beautifulsoup4
|
2019-09-25 15:05:29 +02:00
|
|
|
paho-mqtt
|
2018-03-28 11:07:35 +02:00
|
|
|
];
|
|
|
|
src = pkgs.fetchgit {
|
|
|
|
url = "http://cgit.euer.krebsco.de/arafetch";
|
|
|
|
inherit rev;
|
2020-02-19 13:58:40 +01:00
|
|
|
sha256 = "0hnwbmj0plynhv3h2idhrzf2zcqx3qnw6lq8zzyn9am74pmvza39";
|
2018-03-28 11:07:35 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
home = "/var/lib/arafetch";
|
|
|
|
in {
|
|
|
|
users.users.arafetch = {
|
|
|
|
uid = genid "arafetch";
|
|
|
|
inherit home;
|
|
|
|
createHome = true;
|
2021-06-05 19:21:36 +02:00
|
|
|
isSystemUser = true;
|
2021-12-04 20:46:47 +01:00
|
|
|
group = "arafetch";
|
2018-03-28 11:07:35 +02:00
|
|
|
};
|
2021-12-04 20:46:47 +01:00
|
|
|
users.groups.arafetch = {};
|
2018-03-28 11:07:35 +02:00
|
|
|
|
2019-09-25 15:05:29 +02:00
|
|
|
systemd.services.ara2mqtt = {
|
|
|
|
startAt = "05:00:00";
|
|
|
|
after = [ "network-online.target" ];
|
|
|
|
path = [ pkg ];
|
|
|
|
serviceConfig = {
|
|
|
|
User = "arafetch";
|
|
|
|
# Restart = "always";
|
|
|
|
WorkingDirectory = home;
|
|
|
|
PrivateTmp = true;
|
|
|
|
ExecStart = pkgs.writeDash "daily-mqtt" ''
|
|
|
|
ara2mqtt db/thales-deutschland.json --cantine thales-deutschland --host localhost
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2018-03-28 11:07:35 +02:00
|
|
|
systemd.services.arafetch = {
|
2018-04-04 14:46:15 +02:00
|
|
|
startAt = "Mon,Wed,Fri 09:15:00";
|
2018-03-28 11:07:35 +02:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
2018-11-05 13:55:24 +01:00
|
|
|
after = [ "network-online.target" ];
|
2019-09-25 15:05:29 +02:00
|
|
|
environment.OUTDIR = home;
|
2018-03-28 11:07:35 +02:00
|
|
|
path = [ pkg pkgs.git pkgs.wget ];
|
2018-04-04 14:46:15 +02:00
|
|
|
serviceConfig = {
|
|
|
|
User = "arafetch";
|
2019-05-08 13:57:29 +02:00
|
|
|
# Restart = "always";
|
2018-04-04 14:46:15 +02:00
|
|
|
WorkingDirectory = home;
|
|
|
|
PrivateTmp = true;
|
|
|
|
ExecStart = pkgs.writeDash "start-weekrun" ''
|
|
|
|
weekrun || echo "weekrun failed!"
|
|
|
|
find $OUTDIR/db -name \*.json | while read path;do
|
|
|
|
file=''${path##*/}
|
|
|
|
cantine=''${file%%.json}
|
|
|
|
ara2influx $path --cantine $cantine --host wbob.r
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
};
|
2018-03-28 11:07:35 +02:00
|
|
|
};
|
|
|
|
}
|