summaryrefslogtreecommitdiffstats
path: root/krebs
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2019-07-11 18:11:50 +0200
committermakefu <github@syntax-fehler.de>2019-07-11 18:11:50 +0200
commit31960101a75796c184d44264744da73d27f8cd78 (patch)
treee9f96540fa4f4658c415cd18f5cbe1e7867ab026 /krebs
parent4dad3683f9acfa243b195e498af422b25bb9056e (diff)
shack/node-light: init
Diffstat (limited to 'krebs')
-rw-r--r--krebs/2configs/shack/node-light.nix53
1 files changed, 53 insertions, 0 deletions
diff --git a/krebs/2configs/shack/node-light.nix b/krebs/2configs/shack/node-light.nix
new file mode 100644
index 000000000..d7e9e90bb
--- /dev/null
+++ b/krebs/2configs/shack/node-light.nix
@@ -0,0 +1,53 @@
+{ config, lib, pkgs, ... }:
+
+let
+ pkg = pkgs.callPackage (
+ pkgs.fetchgit {
+ url = "https://git.shackspace.de/rz/node-light.git";
+ rev = "a32c782650c4cc0adf51250fe249167d7246c59b";
+ sha256 = "0clvcp1m2ay0a9ibh7s21q7d9a6nam3497bysvc6mdygblks22qy";
+ }) {};
+ home = "/var/lib/node-light";
+ port = "8082";
+in {
+ # receive response from light.shack / standby.shack
+ networking.firewall.allowedUDPPorts = [ 2342 ];
+ users.users.node-light = {
+ inherit home;
+ createHome = true;
+ };
+ services.nginx.virtualHosts."lounge.light.shack" = {
+ locations."/" = {
+ proxyPass = "http://localhost:${port}/lounge/";
+ };
+ };
+ services.nginx.virtualHosts."power.light.shack" = {
+ locations."/" = {
+ proxyPass = "http://localhost:${port}/power/";
+ };
+ };
+
+ services.nginx.virtualHosts."openhab.shack" = {
+ serverAliases = [ "lightapi.shack" ];
+ locations."/power".proxyPass = "http://localhost:${port}";
+ locations."/lounge".proxyPass = "http://localhost:${port}";
+ };
+ systemd.services.node-light= {
+ description = "node-light";
+ wantedBy = [ "multi-user.target" ];
+ environment.PORT = port;
+ serviceConfig = {
+ User = "node-light";
+ # do not override the current storage file
+ ExecStartPre = pkgs.writeDash "call-light-pre" ''
+ cp -vn ${pkg}/share/storage.json ${home}
+ chmod 700 ${home}/storage.json
+
+ '';
+ WorkingDirectory = home;
+ ExecStart = "${pkg}/bin/node-light";
+ Restart = "always";
+ PrivateTmp = true;
+ };
+ };
+}