summaryrefslogtreecommitdiffstats
path: root/krebs/2configs
diff options
context:
space:
mode:
Diffstat (limited to 'krebs/2configs')
-rw-r--r--krebs/2configs/default.nix17
-rw-r--r--krebs/2configs/exim-smarthost.nix5
-rw-r--r--krebs/2configs/reaktor2.nix3
-rw-r--r--krebs/2configs/shack/gitlab-runner.nix19
-rw-r--r--krebs/2configs/shack/glados/default.nix139
-rw-r--r--krebs/2configs/shack/glados/deps/dwd_pollen.nix32
-rw-r--r--krebs/2configs/shack/glados/deps/gtts-token.nix27
-rw-r--r--krebs/2configs/shack/glados/deps/pyhaversion.nix33
-rw-r--r--krebs/2configs/shack/glados/multi/shackopen.nix23
-rw-r--r--krebs/2configs/shack/glados/multi/wasser.nix66
-rw-r--r--krebs/2configs/shack/glados/sensors/hass.nix22
-rw-r--r--krebs/2configs/shack/glados/sensors/power.nix27
-rw-r--r--krebs/2configs/shack/grafana.nix19
-rw-r--r--krebs/2configs/shack/graphite.nix (renamed from krebs/2configs/graphite.nix)20
-rw-r--r--krebs/2configs/shack/influx.nix33
-rw-r--r--krebs/2configs/shack/mqtt.nix15
-rw-r--r--krebs/2configs/shack/mqtt_sub.nix2
-rw-r--r--krebs/2configs/shack/muell_caller.nix3
-rw-r--r--krebs/2configs/shack/muell_mail.nix34
-rw-r--r--krebs/2configs/shack/muellshack.nix44
-rw-r--r--krebs/2configs/shack/node-light.nix54
-rw-r--r--krebs/2configs/shack/powerraw.nix74
-rw-r--r--krebs/2configs/shack/prometheus/node.nix27
-rw-r--r--krebs/2configs/shack/prometheus/server.nix205
-rw-r--r--krebs/2configs/shack/prometheus/unifi.nix10
-rw-r--r--krebs/2configs/shack/radioactive.nix3
-rw-r--r--krebs/2configs/shack/s3-power.nix34
-rw-r--r--krebs/2configs/shack/worlddomination.nix2
-rw-r--r--krebs/2configs/stats/shack-client.nix (renamed from krebs/2configs/stats/wolf-client.nix)12
-rw-r--r--krebs/2configs/stats/shack-debugging.nix (renamed from krebs/2configs/collectd-base.nix)4
30 files changed, 963 insertions, 45 deletions
diff --git a/krebs/2configs/default.nix b/krebs/2configs/default.nix
index fafcd72c..d7d6fbf3 100644
--- a/krebs/2configs/default.nix
+++ b/krebs/2configs/default.nix
@@ -14,18 +14,13 @@ with import <stockholm/lib>;
];
krebs.announce-activation.enable = true;
krebs.enable = true;
- krebs.tinc.retiolum.enable = true;
+ krebs.tinc.retiolum.enable = mkDefault true;
krebs.build.user = mkDefault config.krebs.users.krebs;
networking.hostName = config.krebs.build.host.name;
nix.maxJobs = 1;
- nix.trustedBinaryCaches = [
- "https://cache.nixos.org"
- "http://cache.nixos.org"
- "http://hydra.nixos.org"
- ];
nix.useSandbox = true;
environment.systemPackages = with pkgs; [
@@ -34,6 +29,11 @@ with import <stockholm/lib>;
rxvt_unicode.terminfo
];
+ i18n = {
+ consoleKeyMap = "us";
+ defaultLocale = lib.mkForce "C";
+ };
+
programs.ssh.startAgent = false;
services.openssh = {
@@ -48,18 +48,13 @@ with import <stockholm/lib>;
users.mutableUsers = false;
users.extraUsers.root.openssh.authorizedKeys.keys = [
- # TODO
config.krebs.users.jeschli-brauerei.pubkey
config.krebs.users.lass.pubkey
config.krebs.users.lass-mors.pubkey
config.krebs.users.makefu.pubkey
- # TODO HARDER:
- config.krebs.users.makefu-omo.pubkey
config.krebs.users.tv.pubkey
];
-
# The NixOS release to be compatible with for stateful data such as databases.
system.stateVersion = "17.03";
-
}
diff --git a/krebs/2configs/exim-smarthost.nix b/krebs/2configs/exim-smarthost.nix
index 5dc24f1d..698e20da 100644
--- a/krebs/2configs/exim-smarthost.nix
+++ b/krebs/2configs/exim-smarthost.nix
@@ -25,12 +25,11 @@ in {
in {
"anmeldung@eloop.org" = eloop-ml;
"brain@krebsco.de" = brain-ml;
- "cfp@eloop.org" = eloop-ml;
+ "cfp2019@eloop.org" = eloop-ml;
+ "eloop2019@krebsco.de" = eloop-ml;
"kontakt@eloop.org" = eloop-ml;
"root@eloop.org" = eloop-ml;
"youtube@eloop.org" = eloop-ml;
- "eloop2016@krebsco.de" = eloop-ml;
- "eloop2017@krebsco.de" = eloop-ml;
"postmaster@krebsco.de" = spam-ml; # RFC 822
"lass@krebsco.de" = lass;
"makefu@krebsco.de" = makefu;
diff --git a/krebs/2configs/reaktor2.nix b/krebs/2configs/reaktor2.nix
index b52125ae..f4fa2ca7 100644
--- a/krebs/2configs/reaktor2.nix
+++ b/krebs/2configs/reaktor2.nix
@@ -70,7 +70,8 @@ let
filename = pkgs.writeDash "bier-balance" ''
${pkgs.hledger}/bin/hledger -f $state_file bal -N -O csv \
| ${pkgs.coreutils}/bin/tail +2 \
- | ${pkgs.miller}/bin/mlr --icsv --opprint cat
+ | ${pkgs.miller}/bin/mlr --icsv --opprint cat \
+ | ${pkgs.gnused}/bin/sed 's/^/the_/'
'';
};
}
diff --git a/krebs/2configs/shack/gitlab-runner.nix b/krebs/2configs/shack/gitlab-runner.nix
index 0fd06426..5f2ca02d 100644
--- a/krebs/2configs/shack/gitlab-runner.nix
+++ b/krebs/2configs/shack/gitlab-runner.nix
@@ -6,16 +6,17 @@ let
};
in
{
- systemd.services.gitlab-runner.path = [
- "/run/wrappers" # /run/wrappers/bin/su
- "/" # /bin/sh
- ];
imports = [
"${runner-src}/gitlab-runner.nix"
];
- services.gitlab-runner2.enable = true;
- ## registrationConfigurationFile contains:
- # CI_SERVER_URL=<CI server URL>
- # REGISTRATION_TOKEN=<registration secret>
- services.gitlab-runner2.registrationConfigFile = <secrets/shackspace-gitlab-ci>;
+ services.gitlab-runner2 = {
+ enable = true;
+ ## registrationConfigurationFile contains:
+ # CI_SERVER_URL=<CI server URL>
+ # REGISTRATION_TOKEN=<registration secret>
+ registrationConfigFile = <secrets/shackspace-gitlab-ci>;
+ #gracefulTermination = true;
+ };
+ systemd.services.gitlab-runner2.restartIfChanged = false;
+ systemd.services.docker.restartIfChanged = false;
}
diff --git a/krebs/2configs/shack/glados/default.nix b/krebs/2configs/shack/glados/default.nix
new file mode 100644
index 00000000..dc345cc4
--- /dev/null
+++ b/krebs/2configs/shack/glados/default.nix
@@ -0,0 +1,139 @@
+{ config, pkgs, lib, ... }:
+let
+ shackopen = import ./multi/shackopen.nix;
+ wasser = import ./multi/wasser.nix;
+in {
+ services.nginx.virtualHosts."hass.shack" = {
+ serverAliases = [ "glados.shack" ];
+ locations."/" = {
+ proxyPass = "http://localhost:8123";
+ extraConfig = ''
+ proxy_http_version 1.1;
+ proxy_set_header Upgrade $http_upgrade;
+ proxy_set_header Connection "upgrade";
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header Host $host;
+ proxy_set_header X-Real-IP $remote_addr;
+
+ proxy_buffering off;
+ '';
+ };
+ };
+ services.home-assistant = let
+ dwd_pollen = pkgs.fetchFromGitHub {
+ owner = "marcschumacher";
+ repo = "dwd_pollen";
+ rev = "0.1";
+ sha256 = "1af2mx99gv2hk1ad53g21fwkdfdbymqcdl3jvzd1yg7dgxlkhbj1";
+ };
+ in {
+ enable = true;
+ package = (pkgs.home-assistant.overrideAttrs (old: {
+ # TODO: find correct python package
+ installCheckPhase = ''
+ echo LOLLLLLLLLLLLLLL
+ '';
+ postInstall = ''
+ cp -r ${dwd_pollen} $out/lib/python3.7/site-packages/homeassistant/components/dwd_pollen
+ '';
+ })).override {
+ extraPackages = ps: with ps; [
+ python-forecastio jsonrpc-async jsonrpc-websocket mpd2
+ (callPackage ./deps/gtts-token.nix { })
+ (callPackage ./deps/pyhaversion.nix { })
+ ];
+ };
+ autoExtraComponents = true;
+ config = {
+ homeassistant = {
+ name = "Bureautomation";
+ time_zone = "Europe/Berlin";
+ latitude = "48.8265";
+ longitude = "9.0676";
+ elevation = 303;
+ auth_providers = [
+ { type = "homeassistant";}
+ { type = "legacy_api_password";}
+ { type = "trusted_networks";
+ # allow_bypass_login = true;
+ }
+ ];
+ };
+ # https://www.home-assistant.io/components/influxdb/
+ influxdb = {
+ database = "hass";
+ tags = {
+ instance = "wolf";
+ source = "hass";
+ };
+ };
+ mqtt = {
+ broker = "localhost";
+ port = 1883;
+ client_id = "home-assistant";
+ keepalive = 60;
+ protocol = 3.1;
+ birth_message = {
+ topic = "glados/hass/status/LWT";
+ payload = "Online";
+ qos = 1;
+ retain = true;
+ };
+ will_message = {
+ topic = "glados/hass/status/LWT";
+ payload = "Offline";
+ qos = 1;
+ retain = true;
+ };
+ };
+ switch = wasser.switch;
+ light = [];
+ media_player = [
+ { platform = "mpd";
+ host = "lounge.mpd.shack";
+ }
+ ];
+
+ sensor =
+ [{ platform = "version"; }]
+ ++ (import ./sensors/hass.nix)
+ ++ (import ./sensors/power.nix)
+ ++ shackopen.sensor;
+
+ binary_sensor = shackopen.binary_sensor;
+
+ camera = [];
+
+ frontend = { };
+ http = {
+ # TODO: https://github.com/home-assistant/home-assistant/issues/16149
+ base_url = "http://hass.shack";
+ use_x_forwarded_for = true;
+ trusted_proxies = "127.0.0.1";
+ api_password = "shackit";
+ trusted_networks = [
+ "127.0.0.1/32"
+ "10.42.0.0/16"
+ "::1/128"
+ "fd00::/8"
+ ];
+ };
+ conversation = {};
+ history = {};
+ logbook = {};
+ tts = [
+ { platform = "google";
+ language = "de";
+ }
+ { platform = "picotts";
+ language = "de-DE";
+ }
+ ];
+ recorder = {};
+ sun = {};
+
+ automation = wasser.automation;
+ device_tracker = [];
+ };
+ };
+}
diff --git a/krebs/2configs/shack/glados/deps/dwd_pollen.nix b/krebs/2configs/shack/glados/deps/dwd_pollen.nix
new file mode 100644
index 00000000..39d9c306
--- /dev/null
+++ b/krebs/2configs/shack/glados/deps/dwd_pollen.nix
@@ -0,0 +1,32 @@
+{ lib
+, buildPythonPackage
+, fetchFromGitHub
+, python
+, voluptuous
+}:
+
+buildPythonPackage rec {
+ format = "other";
+ pname = "dwd_pollen";
+ version = "0.1";
+
+ src = fetchFromGitHub {
+ owner = "marcschumacher";
+ repo = "dwd_pollen";
+ rev = version;
+ sha256 = "1af2mx99gv2hk1ad53g21fwkdfdbymqcdl3jvzd1yg7dgxlkhbj1";
+ };
+ propagatedBuildInputs = [
+ voluptuous
+ ];
+ installPhase = ''
+ install -D -t $out/${python.sitePackages}/homeassistant/components/sensor/dwd_pollen *
+ '';
+
+ meta = with lib; {
+ description = "Home Assistant component to retrieve Pollen data from DWD (Germany)";
+ homepage = https://github.com/marcschumacher/dwd_pollen;
+ license = licenses.mit;
+ maintainers = [ maintainers.makefu ];
+ };
+}
diff --git a/krebs/2configs/shack/glados/deps/gtts-token.nix b/krebs/2configs/shack/glados/deps/gtts-token.nix
new file mode 100644
index 00000000..69640f03
--- /dev/null
+++ b/krebs/2configs/shack/glados/deps/gtts-token.nix
@@ -0,0 +1,27 @@
+{ lib
+, buildPythonPackage
+, fetchPypi
+, requests
+}:
+
+buildPythonPackage rec {
+ pname = "gtts-token";
+ version = "1.1.3";
+
+ src = fetchPypi {
+ pname = "gTTS-token";
+ inherit version;
+ sha256 = "9d6819a85b813f235397ef931ad4b680f03d843c9b2a9e74dd95175a4bc012c5";
+ };
+
+ propagatedBuildInputs = [
+ requests
+ ];
+
+ meta = with lib; {
+ description = "Calculates a token to run the Google Translate text to speech";
+ homepage = https://github.com/boudewijn26/gTTS-token;
+ license = licenses.mit;
+ # maintainers = [ maintainers. ];
+ };
+}
diff --git a/krebs/2configs/shack/glados/deps/pyhaversion.nix b/krebs/2configs/shack/glados/deps/pyhaversion.nix
new file mode 100644
index 00000000..a75c6a97
--- /dev/null
+++ b/krebs/2configs/shack/glados/deps/pyhaversion.nix
@@ -0,0 +1,33 @@
+{ lib
+, buildPythonPackage
+, fetchpatch
+, fetchPypi
+, aiohttp
+, async-timeout
+}:
+
+buildPythonPackage rec {
+ pname = "pyhaversion";
+ version = "2.2.1";
+
+ src = fetchPypi {
+ inherit pname version;
+ sha256 = "72b65aa25d7b2dbb839a4d0218df2005c2335e93526035904d365bb668030b9f";
+ };
+ patches = [
+ (fetchpatch { url = "https://github.com/makefu/pyhaversion/commit/f3bdc38970272cd345c2cfbde3037ea492ca27c4.patch";
+ sha256 =
+ "1rhq4z7mdgnwhwpf5fmarnbc1ba3qysk1wqjdr0hvbzi8vmvbfcc";})
+ ];
+ doCheck = false;
+ propagatedBuildInputs = [
+ aiohttp
+ async-timeout
+ ];
+
+ meta = with lib; {
+ description = "";
+ homepage = https://github.com/ludeeus/pyhaversion;
+ # maintainers = [ maintainers. ];
+ };
+}
diff --git a/krebs/2configs/shack/glados/multi/shackopen.nix b/krebs/2configs/shack/glados/multi/shackopen.nix
new file mode 100644
index 00000000..354405d0
--- /dev/null
+++ b/krebs/2configs/shack/glados/multi/shackopen.nix
@@ -0,0 +1,23 @@
+{
+ binary_sensor = [
+ { platform = "mqtt";
+ name = "Portal Lock";
+ device_class = "door";
+ state_topic = "portal/gateway/status";
+ availability_topic = "portal/gateway/lwt";
+ payload_on = "open";
+ payload_off = "closed";
+ payload_available = "online";
+ payload_not_available = "offline";
+ }
+ ];
+ sensor = [
+ { platform = "mqtt";
+ name = "Keyholder";
+ state_topic = "portal/gateway/keyholder";
+ availability_topic = "portal/gateway/lwt";
+ payload_available = "online";
+ payload_not_available = "offline";
+ }
+ ];
+}
diff --git a/krebs/2configs/shack/glados/multi/wasser.nix b/krebs/2configs/shack/glados/multi/wasser.nix
new file mode 100644
index 00000000..578bb075
--- /dev/null
+++ b/krebs/2configs/shack/glados/multi/wasser.nix
@@ -0,0 +1,66 @@
+let
+ tasmota_plug = name: topic:
+ { platform = "mqtt";
+ inherit name;
+ state_topic = "sonoff/stat/${topic}/POWER1";
+ command_topic = "sonoff/cmnd/${topic}/POWER1";
+ availability_topic = "sonoff/tele/${topic}/LWT";
+ payload_on= "ON";
+ payload_off= "OFF";
+ payload_available= "Online";
+ payload_not_available= "Offline";
+ retain = false;
+ qos = 1;
+ };
+ seconds = 20;
+in
+{
+ switch = [
+ (tasmota_plug "Wasser" "plug")
+ ];
+ automation =
+ [
+ { alias = "Water the plant for ${toString seconds} seconds";
+ trigger = [
+ { # trigger at 20:00 no matter what
+ # TODO: retry or run only if switch.wasser is available
+ platform = "time";
+ at = "20:00:00";
+ }
+ ];
+ action =
+ [
+ {
+ service = "homeassistant.turn_on";
+ entity_id = [
+ "switch.wasser"
+ ];
+ }
+ { delay.seconds = seconds; }
+ {
+ service = "homeassistant.turn_off";
+ entity_id = [
+ "switch.wasser"
+ ];
+ }
+ ];
+ }
+ { alias = "Always turn off water after ${toString (seconds * 2)}seconds";
+ trigger = [
+ {
+ platform = "state";
+ entity_id = "switch.wasser";
+ to = "on";
+ for.seconds = seconds*2;
+ }
+ ];
+ action =
+ [
+ {
+ service = "homeassistant.turn_off";
+ entity_id = [ "switch.wasser" ];
+ }
+ ];
+ }
+ ];
+}
diff --git a/krebs/2configs/shack/glados/sensors/hass.nix b/krebs/2configs/shack/glados/sensors/hass.nix
new file mode 100644
index 00000000..63475870
--- /dev/null
+++ b/krebs/2configs/shack/glados/sensors/hass.nix
@@ -0,0 +1,22 @@
+let
+ esphome_temp = name:
+ { platform = "mqtt";
+ name = "${name} Temperature";
+ device_class = "temperature";
+ state_topic = "glados/${name}/sensor/temperature/state";
+ availability_topic = "glados/${name}/status";
+ payload_available = "online";
+ payload_not_available = "offline";
+ };
+ esphome_hum = name:
+ { platform = "mqtt";
+ device_class = "humidity";
+ name = "${name} Humidity";
+ state_topic = "glados/${name}/sensor/humidity/state";
+ availability_topic = "glados/${name}/status";
+ payload_available = "online";
+ payload_not_available = "offline";
+ };
+in
+ (map esphome_temp [ "lounge" "werkstatt" "herrenklo" "dusche" "fablab" "whc" ])
+ ++ (map esphome_hum [ "lounge" "werkstatt" "herrenklo" "dusche" "fablab" "whc" ])
diff --git a/krebs/2configs/shack/glados/sensors/power.nix b/krebs/2configs/shack/glados/sensors/power.nix
new file mode 100644
index 00000000..1aa250a1
--- /dev/null
+++ b/krebs/2configs/shack/glados/sensors/power.nix
@@ -0,0 +1,27 @@
+let
+ power_x = name: phase:
+ { platform = "mqtt";
+ name = "${phase} ${name}";
+ # device_class = "power";
+ state_topic = "/power/total/${phase}/${name}";
+ availability_topic = "/power/lwt";
+ payload_available = "Online";
+ payload_not_available = "Offline";
+ };
+ power_consumed =
+ { platform = "mqtt";
+ name = "Power Consumed";
+ #device_class = "power";
+ state_topic = "/power/total/consumed";
+ availability_topic = "/power/lwt";
+ payload_available = "Online";
+ payload_not_available = "Offline";
+ };
+ power_volt = power_x "Voltage";
+ power_watt = power_x "Power";
+ power_curr = power_x "Current";
+in
+ (map power_volt [ "L1" "L2" "L3" ])
+++ (map power_watt [ "L1" "L2" "L3" ])
+++ (map power_curr [ "L1" "L2" "L3" ])
+++ [ power_consumed ]
diff --git a/krebs/2configs/shack/grafana.nix b/krebs/2configs/shack/grafana.nix
new file mode 100644
index 00000000..adf0a4bc
--- /dev/null
+++ b/krebs/2configs/shack/grafana.nix
@@ -0,0 +1,19 @@
+let
+ port = 3000;
+in {
+
+ networking.firewall.allowedTCPPorts = [ port ]; # legacy
+ services.nginx.virtualHosts."grafana.shack" = {
+ locations."/".proxyPass = "http://localhost:${toString port}";
+ };
+ services.grafana = {
+ enable = true;
+ port = port;
+ addr = "0.0.0.0";
+ users.allowSignUp = true;
+ users.allowOrgCreate = true;
+ users.autoAssignOrg = true;
+ auth.anonymous.enable = true;
+ security = import <secrets/grafana_security.nix>;
+ };
+}
diff --git a/krebs/2configs/graphite.nix b/krebs/2configs/shack/graphite.nix
index 64222e43..1c8ec6a8 100644
--- a/krebs/2configs/graphite.nix
+++ b/krebs/2configs/shack/graphite.nix
@@ -1,16 +1,22 @@
{ config, lib, pkgs, ... }:
+# hostname: graphite.shack
+
# graphite-web on port 8080
# carbon cache on port 2003 (tcp/udp)
-
-# TODO: krebs.graphite.minimal.enable
-# TODO: configure firewall
-with import <stockholm/lib>;
-{
- imports = [ ];
-
+let
+ port = 8080;
+in {
+ networking.firewall.allowedTCPPorts = [ 2003 port ];
+ networking.firewall.allowedUDPPorts = [ 2003 ];
+ services.nginx.virtualHosts."graphite.shack" = {
+ locations."/" = {
+ proxyPass = "http://localhost:${toString port}/";
+ };
+ };
services.graphite = {
api = {
+ inherit port;
enable = true;
listenAddress = "0.0.0.0";
};
diff --git a/krebs/2configs/shack/influx.nix b/krebs/2configs/shack/influx.nix
new file mode 100644
index 00000000..92cb24bf
--- /dev/null
+++ b/krebs/2configs/shack/influx.nix
@@ -0,0 +1,33 @@
+{pkgs, ... }: # hostname: influx.shack
+let
+ port = 8086;
+ collectd-port = 25826;
+ db = "collectd_db";
+in
+{
+ networking.firewall.allowedTCPPorts = [ port ]; # for legacy applications
+ networking.firewall.allowedUDPPorts = [ collectd-port ];
+ services.nginx.virtualHosts."influx.shack" = {
+ locations."/" = {
+ proxyPass = "http://localhost:${toString port}/";
+ };
+ };
+ services.influxdb = {
+ enable = true;
+ extraConfig = {
+ http.bind-address = "0.0.0.0:${toString port}";
+ http.log-enabled = false;
+ http.write-tracing = false;
+ http.suppress-write-log = true;
+ data.trace-logging-enabled = false;
+ data.query-log-enabled = false;
+ monitoring.enabled = false;
+ collectd = [{
+ enabled = true;
+ typesdb = "${pkgs.collectd}/share/collectd/types.db";
+ database = db;
+ bind-address = ":${toString collectd-port}";
+ }];
+ };
+ };
+}
diff --git a/krebs/2configs/shack/mqtt.nix b/krebs/2configs/shack/mqtt.nix
new file mode 100644
index 00000000..e78f0f97
--- /dev/null
+++ b/krebs/2configs/shack/mqtt.nix
@@ -0,0 +1,15 @@
+# hostname: mqtt.shack
+{
+ networking.firewall.allowedTCPPorts = [ 1883 ];
+ networking.firewall.allowedUDPPorts = [ 1883 ];
+ services.mosquitto = {
+ enable = true;
+ host = "0.0.0.0";
+ users = {};
+ # TODO: secure that shit
+ aclExtraConf = ''
+ pattern readwrite #
+ '';
+ allowAnonymous = true;
+ };
+}
diff --git a/krebs/2configs/shack/mqtt_sub.nix b/krebs/2configs/shack/mqtt_sub.nix
index a8427dde..bd0b6df8 100644
--- a/krebs/2configs/shack/mqtt_sub.nix
+++ b/krebs/2configs/shack/mqtt_sub.nix
@@ -29,6 +29,8 @@ in {
User = "nobody";
ExecStart = "${pkg}/bin/sub-new";
PrivateTmp = true;
+ Restart = "always";
+ RestartSec = "15";
};
};
}
diff --git a/krebs/2configs/shack/muell_caller.nix b/krebs/2configs/shack/muell_caller.nix
index 19768cb2..33f6b8c8 100644
--- a/krebs/2configs/shack/muell_caller.nix
+++ b/krebs/2configs/shack/muell_caller.nix
@@ -33,9 +33,10 @@ in {
chown nobody /tmp/tell.json
'';
ExecStart = "${pkg}/bin/call-muell --cfg /tmp/tell.json --mode mpd loop 60";
- Restart = "always";
PrivateTmp = true;
PermissionsStartOnly = true;
+ Restart = "always";
+ RestartSec = "15";
};
};
}
diff --git a/krebs/2configs/shack/muell_mail.nix b/krebs/2configs/shack/muell_mail.nix
new file mode 100644
index 00000000..40927895
--- /dev/null
+++ b/krebs/2configs/shack/muell_mail.nix
@@ -0,0 +1,34 @@
+{ config, lib, pkgs, ... }:
+
+let
+ pkg = pkgs.callPackage (
+ pkgs.fetchgit {
+ url = "https://git.shackspace.de/rz/muell_mail";
+ rev = "57b67c95052d90044137b2c89007a371dc389afd";
+ sha256 = "1grkzs6fxjnc2bv4kskj63d5sb4qxz6yyr85nj0da9hn7qkk4jkj";
+ }) { mkYarnPackage = pkgs.yarn2nix-moretea.mkYarnPackage; };
+ home = "/var/lib/muell_mail";
+ cfg = toString <secrets/shack/muell_mail.js>;
+in {
+ users.users.muell_mail = {
+ inherit home;
+ createHome = true;
+ };
+ systemd.services.muell_mail = {
+ description = "muell_mail";
+ wantedBy = [ "multi-user.target" ];
+ environment.CONFIG = "${home}/muell_mail.js";
+ serviceConfig = {
+ User = "muell_mail";
+ ExecStartPre = pkgs.writeDash "muell_mail-pre" ''
+ install -D -omuell_mail -m700 ${cfg} ${home}/muell_mail.js
+ '';
+ WorkingDirectory = home;
+ PermissionsStartOnly = true;
+ ExecStart = "${pkg}/bin/muell_mail";
+ PrivateTmp = true;
+ Restart = "always";
+ RestartSec = "15";
+ };
+ };
+}
diff --git a/krebs/2configs/shack/muellshack.nix b/krebs/2configs/shack/muellshack.nix
new file mode 100644
index 00000000..c1c957da
--- /dev/null
+++ b/krebs/2configs/shack/muellshack.nix
@@ -0,0 +1,44 @@
+{ config, lib, pkgs, ... }:
+
+let
+ pkg = pkgs.callPackage (
+ pkgs.fetchgit {
+ url = "https://git.shackspace.de/rz/muellshack";
+ rev = "4601f59787de090c83be6dbae6ca72d7fc84ab9f";
+ sha256 = "1cshbd6ipvynbm3gmnsm58ccc1m5xc87cpd3b6jx0s6pr2j19g9j";
+ }) { mkYarnPackage = pkgs.yarn2nix-moretea.mkYarnPackage; };
+ home = "/var/lib/muellshack";
+ port = "8081";
+in {
+ users.users.muellshack = {
+ inherit home;
+ createHome = true;
+ };
+ services.nginx.virtualHosts."muell.shack" = {
+ locations."/" = {
+ proxyPass = "http://localhost:${port}/muellshack/";
+ };
+ };
+ services.nginx.virtualHosts."openhab.shack" = {
+ locations."/muellshack/".proxyPass = "http://localhost:${port}/muellshack/";
+ };
+ systemd.services.muellshack = {
+ description = "muellshack";
+ wantedBy = [ "multi-user.target" ];
+ environment.PORT = port;
+ serviceConfig = {
+ User = "muellshack";
+ # do not override the current storage fil
+ ExecStartPre = pkgs.writeDash "call-muell-pre" ''
+ cp -vf ${pkg}/share/static_muelldata.json ${home}
+ cp -vn ${pkg}/share/storage.json ${home}
+ chmod 700 ${home}/storage.json
+ '';
+ WorkingDirectory = home;
+ ExecStart = "${pkg}/bin/muellshack";
+ PrivateTmp = true;
+ Restart = "always";
+ RestartSec = "15";
+ };
+ };
+}
diff --git a/krebs/2configs/shack/node-light.nix b/krebs/2configs/shack/node-light.nix
new file mode 100644
index 00000000..38cb3b55
--- /dev/null
+++ b/krebs/2configs/shack/node-light.nix
@@ -0,0 +1,54 @@
+{ config, lib, pkgs, ... }:
+
+let
+ pkg = pkgs.callPackage (
+ pkgs.fetchgit {
+ url = "https://git.shackspace.de/rz/node-light.git";
+ rev = "32d8064db5172b8068f633211c8bd5688b2c8773";
+ sha256 = "14jzhs7pp3hq42wq3cwqarivn1z7vcgksfzfqfc4yyh21096yi1j";
+ }) { mkYarnPackage = pkgs.yarn2nix-moretea.mkYarnPackage; };
+ 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}/power/";
+ locations."/lounge/".proxyPass = "http://localhost:${port}/lounge/";
+ };
+ 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";
+ PrivateTmp = true;
+ Restart = "always";
+ RestartSec = "15";
+ };
+ };
+}
diff --git a/krebs/2configs/shack/powerraw.nix b/krebs/2configs/shack/powerraw.nix
new file mode 100644
index 00000000..4118e7a7
--- /dev/null
+++ b/krebs/2configs/shack/powerraw.nix
@@ -0,0 +1,74 @@
+{ config, lib, pkgs, ... }:
+# Replacement for powerraw.shack pollin box
+# Requires usb-serial device on host
+# Requires mqtt available at mqtt.shack
+# Requires hostname powerraw.shack
+let
+ influx-url = "http://influx.shack:8086";
+ pkg = pkgs.python3.pkgs.callPackage (
+ pkgs.fetchgit {
+ url = "https://git.shackspace.de/rz/powermeter.git";
+ rev = "96609f0d632e0732afa768ddd7b3f8841ca37c1b";
+ sha256 = "sha256:0wfpm3ik5r081