stockholm/krebs/2configs/shack/mqtt_sub.nix

37 lines
991 B
Nix
Raw Normal View History

2017-06-01 07:21:20 +00:00
{ config, lib, pkgs, ... }:
with import <stockholm/lib>;
let
pkg = pkgs.stdenv.mkDerivation {
name = "mqtt2graphite-2017-05-29";
src = pkgs.fetchgit {
url = "https://github.com/shackspace/mqtt2graphite/";
2017-06-09 11:53:48 +00:00
rev = "117179d";
sha256 = "1334jbbzlqizyp7zcn4hdswhhrnkj1p4p435n5nph82lzffrsi44";
2017-06-01 07:21:20 +00:00
};
buildInputs = [
(pkgs.python3.withPackages (pythonPackages: with pythonPackages; [
2017-06-01 07:21:20 +00:00
docopt
paho-mqtt
]))
];
installPhase = ''
install -m755 -D sub.py $out/bin/sub
install -m755 -D sub2.py $out/bin/sub-new
'';
};
in {
systemd.services.mqtt_sub = {
description = "subscribe to mqtt, send to graphite";
# after = [ (lib.optional config.services.mosqitto.enable "mosquitto.service") ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
User = "nobody";
ExecStart = "${pkg}/bin/sub-new";
PrivateTmp = true;
2019-09-26 19:46:14 +00:00
Restart = "always";
RestartSec = "15";
2017-06-01 07:21:20 +00:00
};
};
}