m 2 led-fader: use ampel
This commit is contained in:
parent
d2f896842e
commit
d92281cf4d
|
@ -3,6 +3,26 @@
|
||||||
with import <stockholm/lib>;
|
with import <stockholm/lib>;
|
||||||
let
|
let
|
||||||
mq = "192.168.8.11";
|
mq = "192.168.8.11";
|
||||||
|
|
||||||
|
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
|
||||||
|
'';
|
||||||
|
};
|
||||||
in {
|
in {
|
||||||
systemd.services.led-fader = {
|
systemd.services.led-fader = {
|
||||||
description = "Send led change to message queue";
|
description = "Send led change to message queue";
|
||||||
|
@ -10,17 +30,9 @@ in {
|
||||||
NIX_PATH = "/var/src";
|
NIX_PATH = "/var/src";
|
||||||
};
|
};
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
path = with pkgs; [
|
|
||||||
nix # nix-shell
|
|
||||||
mosquitto #mosquitto_pub
|
|
||||||
bash # nix-shell
|
|
||||||
];
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
# User = "nobody"; # need a user with permissions to run nix-shell
|
# User = "nobody"; # need a user with permissions to run nix-shell
|
||||||
ExecStart = pkgs.writeDash "run-fader" ''
|
ExecStart = "${pkg}/bin/ampel 4 ${pkg}/share/times.json";
|
||||||
${./fade.py} --add-empty --mode chain 3 loop --skip-unchanged 0.002 0.1 \
|
|
||||||
| mosquitto_pub -h ${mq} -p 1883 -l -t '/leds/nodemcu-switcher/set'
|
|
||||||
'';
|
|
||||||
PrivateTmp = true;
|
PrivateTmp = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue