stockholm/makefu/2configs/stats/arafetch.nix

52 lines
1.2 KiB
Nix
Raw Normal View History

2018-03-28 09:07:35 +00:00
{ pkgs, lib, ...}:
with import <stockholm/lib>;
let
pkg = with pkgs.python3Packages;buildPythonPackage rec {
2019-05-08 11:57:29 +00:00
rev = "775d0c2";
name = "arafetch-${rev}";
2018-03-28 09:07:35 +00:00
propagatedBuildInputs = [
requests
docopt
influxdb
beautifulsoup4
];
src = pkgs.fetchgit {
url = "http://cgit.euer.krebsco.de/arafetch";
inherit rev;
2019-05-08 11:57:29 +00:00
sha256 = "0z35avn7vmbd1661ca1zkc9i4lwcm03kpwgiqxddpkp1yxhl548p";
2018-03-28 09:07:35 +00:00
};
};
home = "/var/lib/arafetch";
in {
users.users.arafetch = {
uid = genid "arafetch";
inherit home;
createHome = true;
};
systemd.services.arafetch = {
startAt = "Mon,Wed,Fri 09:15:00";
2018-03-28 09:07:35 +00:00
wantedBy = [ "multi-user.target" ];
2018-11-05 12:55:24 +00:00
after = [ "network-online.target" ];
2018-03-28 09:07:35 +00:00
environment = {
OUTDIR = home;
};
path = [ pkg pkgs.git pkgs.wget ];
serviceConfig = {
User = "arafetch";
2019-05-08 11:57:29 +00:00
# Restart = "always";
WorkingDirectory = home;
PrivateTmp = true;
ExecStart = pkgs.writeDash "start-weekrun" ''
set -x
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 09:07:35 +00:00
};
}