stockholm/makefu/2configs/deployment/led-fader.nix

42 lines
1.1 KiB
Nix
Raw Normal View History

2017-12-08 13:04:35 +00:00
{ config, lib, pkgs, buildPythonPackage, ... }:
2017-05-11 10:07:03 +00:00
let
mq = "192.168.8.11";
2017-05-11 14:40:51 +00:00
2017-12-08 13:04:35 +00:00
pkg = pkgs.python3Packages.buildPythonPackage {
2017-05-11 14:40:51 +00:00
name = "ampel-master";
2017-12-08 13:04:35 +00:00
2017-05-11 14:40:51 +00:00
src = pkgs.fetchgit {
url = "http://cgit.euer.krebsco.de/ampel";
2017-12-08 13:04:35 +00:00
rev = "531741b";
sha256 = "110yij53jz074zbswylbzcd8jy7z49r9fg6i3j1gk2y3vl91g81c";
2017-05-11 14:40:51 +00:00
};
2017-12-08 13:04:35 +00:00
propagatedBuildInputs = with pkgs.python3Packages; [
2017-05-11 14:40:51 +00:00
docopt
paho-mqtt
2017-12-08 13:04:35 +00:00
requests
pytz
influxdb
httplib2
google_api_python_client
2017-05-11 14:40:51 +00:00
];
};
2017-05-11 10:07:03 +00:00
in {
systemd.services.led-fader = {
description = "Send led change to message queue";
environment = {
NIX_PATH = "/var/src";
};
2017-09-29 19:36:01 +00:00
after = [ "network-online.target" ] ++ (lib.optional config.services.mosquitto.enable "mosquitto.service");
wantedBy = [ "multi-user.target" ];
2017-05-11 10:07:03 +00:00
serviceConfig = {
# User = "nobody"; # need a user with permissions to run nix-shell
2017-09-29 19:36:01 +00:00
ExecStartPre = pkgs.writeDash "sleep.sh" "sleep 2";
2017-12-08 13:04:35 +00:00
ExecStart = "${pkg}/bin/ampel 4";
Restart = "always";
RestartSec = 10;
2017-05-11 10:07:03 +00:00
PrivateTmp = true;
};
};
}