2017-05-11 10:07:03 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with import <stockholm/lib>;
|
|
|
|
let
|
|
|
|
mq = "192.168.8.11";
|
2017-05-11 14:40:51 +00:00
|
|
|
|
|
|
|
pkg = pkgs.stdenv.mkDerivation {
|
|
|
|
name = "ampel-master";
|
|
|
|
src = pkgs.fetchgit {
|
|
|
|
url = "http://cgit.euer.krebsco.de/ampel";
|
|
|
|
rev = "07a6791de368e16cc0864d2676fd255eba522cee";
|
|
|
|
sha256 = "1jxjapvkfglvgapy7gjbr1nra3ay418nvz70bvypcmv7wc8d4h8q";
|
|
|
|
};
|
|
|
|
buildInputs = [
|
|
|
|
(pkgs.python35.withPackages (pythonPackages: with pythonPackages; [
|
|
|
|
docopt
|
|
|
|
paho-mqtt
|
|
|
|
]))
|
|
|
|
];
|
|
|
|
installPhase = ''
|
|
|
|
install -m755 -D fade.py $out/bin/fade.py
|
|
|
|
install -m755 -D ampel.py $out/bin/ampel
|
|
|
|
install -m755 -D times.json $out/share/times.json
|
|
|
|
'';
|
|
|
|
};
|
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");
|
2017-05-24 08:51:36 +00:00
|
|
|
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-05-11 14:40:51 +00:00
|
|
|
ExecStart = "${pkg}/bin/ampel 4 ${pkg}/share/times.json";
|
2017-05-11 10:07:03 +00:00
|
|
|
PrivateTmp = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|