summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitlab-ci.yml53
-rw-r--r--krebs/0tests/data/secrets/shack/muell_mail.js0
-rw-r--r--krebs/0tests/data/secrets/shack/s3-power.json1
-rw-r--r--krebs/0tests/data/secrets/shack/unifi-prometheus-pw0
-rw-r--r--krebs/1systems/puyak/config.nix9
-rw-r--r--krebs/1systems/wolf/config.nix32
-rw-r--r--krebs/2configs/collectd-base.nix4
-rw-r--r--krebs/2configs/default.nix7
-rw-r--r--krebs/2configs/shack/gitlab-runner.nix19
-rw-r--r--krebs/2configs/shack/mqtt.nix14
-rw-r--r--krebs/2configs/shack/muell_mail.nix33
-rw-r--r--krebs/2configs/shack/muellshack.nix43
-rw-r--r--krebs/2configs/shack/node-light.nix53
-rw-r--r--krebs/2configs/shack/powerraw.nix72
-rw-r--r--krebs/2configs/shack/prometheus/node.nix27
-rw-r--r--krebs/2configs/shack/prometheus/server.nix195
-rw-r--r--krebs/2configs/shack/prometheus/unifi.nix10
-rw-r--r--krebs/2configs/shack/s3-power.nix33
-rw-r--r--krebs/3modules/makefu/default.nix9
-rw-r--r--krebs/3modules/makefu/wiregrill/rockit.pub2
-rw-r--r--krebs/3modules/makefu/wiregrill/shackdev.pub1
-rw-r--r--krebs/krops.nix4
-rw-r--r--makefu/0tests/data/secrets/hass/citadel-bot.json1
-rw-r--r--makefu/0tests/data/secrets/hass/voicerss.apikey0
-rw-r--r--makefu/1systems/cake/config.nix7
-rw-r--r--makefu/1systems/filepimp/config.nix1
-rw-r--r--makefu/1systems/firecracker/config.nix25
-rw-r--r--makefu/1systems/firecracker/hardware-config.nix30
-rw-r--r--makefu/1systems/firecracker/source.nix4
-rw-r--r--makefu/1systems/gum/config.nix29
-rw-r--r--makefu/1systems/gum/hardware-config.nix4
-rw-r--r--makefu/1systems/sdcard/config.nix40
-rw-r--r--makefu/1systems/sdcard/kernel.nix15
-rw-r--r--makefu/1systems/sdcard/source.nix3
-rw-r--r--makefu/1systems/wbob/config.nix21
-rw-r--r--makefu/2configs/Reaktor/bgt.nix15
-rw-r--r--makefu/2configs/bureautomation/automation/10h_timer.nix154
-rw-r--r--makefu/2configs/bureautomation/automation/bureau-shutdown.nix10
-rw-r--r--makefu/2configs/bureautomation/automation/schlechteluft.nix74
-rw-r--r--makefu/2configs/bureautomation/combination/10h_timers.nix194
-rw-r--r--makefu/2configs/bureautomation/combination/README.md3
-rw-r--r--makefu/2configs/bureautomation/combination/matrix.nix65
-rw-r--r--makefu/2configs/bureautomation/combination/mittagessen.nix89
-rw-r--r--makefu/2configs/bureautomation/default.nix280
-rw-r--r--makefu/2configs/bureautomation/deps/dwd_pollen.nix32
-rw-r--r--makefu/2configs/bureautomation/deps/gtts-token.nix27
-rw-r--r--makefu/2configs/bureautomation/deps/pyhaversion.nix33
-rw-r--r--makefu/2configs/bureautomation/device_tracker/openwrt.nix3
-rw-r--r--makefu/2configs/bureautomation/hass.nix198
-rw-r--r--makefu/2configs/bureautomation/script/multi_blink.nix8
-rw-r--r--makefu/2configs/bureautomation/sensor/airquality.nix9
-rw-r--r--makefu/2configs/bureautomation/sensor/pollen.nix7
-rw-r--r--makefu/2configs/mail/mail.euer.nix6
-rw-r--r--makefu/2configs/tools/extra-gui.nix2
-rw-r--r--makefu/2configs/wireguard/wiregrill.nix46
55 files changed, 1602 insertions, 454 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 6d2f15063..fb273c932 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,20 +1,57 @@
before_script:
- - mkdir -p ~/.ssh
- - echo "$deploy_privkey" > deploy.key
- - export GIT_SSH_COMMAND="ssh -i $PWD/deploy.key"
- - chmod 600 deploy.key
- - ssh-keyscan -H 'github.com' >> ~/.ssh/known_hosts
+ - nix-env -iA nixpkgs.openssh nixpkgs.gnupg nixpkgs.curl nixpkgs.git nixpkgs.pass || true
+ # prepare github deployment for NUR
+ - mkdir -p ~/.ssh
+ - echo "$github_deploy_privkey" > ~/.ssh/github_deploy.key
+ - chmod 600 ~/.ssh/github_deploy.key
+ - ssh-keyscan -H 'github.com' >> ~/.ssh/known_hosts
+ # prepare git fetching of secrets
+ - echo "$gitlab_deploy_privkey" > ~/.ssh/gitlab_deploy.key
+ - chmod 600 ~/.ssh/gitlab_deploy.key
+ - ssh-keyscan -H 'ssh.git.shackspace.de' >> ~/.ssh/known_hosts
+ # import secret key for secrets
+ - echo "$secrets_gpg_key" | gpg --import
+wolf deployment test:
+ stage: test
+ script:
+ - GIT_SSH_COMMAND="ssh -i ~/.ssh/gitlab_deploy.key" git clone git@ssh.git.shackspace.de:rz/secrets.git ~/brain
+ - test $(PASSWORD_STORE_DIR=~/brain pass smoke) == 1337
+ - git submodule update --init
+ - $(nix-build krebs/krops.nix --no-out-link --argstr name wolf --argstr target /tmp -A test)
nix-shell test:
+ stage: test
script:
- - env
- nix-shell --pure --command 'true' -p stdenv && echo success
- nix-shell --pure --command 'false' -p stdenv || echo success
+ - git --version
+ - ssh -V
+ - gpg --version
+ - curl --version
+wolf deployment:
+ stage: deploy
+ script:
+ - cp ~/.ssh/gitlab_deploy.key ~/.ssh/id_rsa
+ - git clone git@ssh.git.shackspace.de:rz/secrets.git ~/brain
+ - git submodule update --init
+ - ssh-keyscan -H 'wolf.shack' >> ~/.ssh/known_hosts
+ # TODO, hostname wolf cannot be resolved
+ - $(nix-build krebs/krops.nix --no-out-link --argstr name wolf --argstr target wolf.shack -A deploy)
+ only:
+ changes:
+ - .gitlab-ci.yml
+ - krebs/**/*
+ - lib/**/*
+ - .gitmodules
nur-packages makefu:
+ stage: deploy
script:
- git reset --hard origin/master
- git filter-branch -f --prune-empty --subdirectory-filter makefu/5pkgs HEAD
- git remote add deploy git@github.com:makefu/nur-packages.git || git remote set-url deploy git@github.com:makefu/nur-packages.git
- - git push --force deploy HEAD:master
+ - GIT_SSH_COMMAND="ssh -i ~/.ssh/github_deploy.key" git push --force deploy HEAD:master
- curl -XPOST http://nur-update.herokuapp.com/update?repo=makefu
+ only:
+ changes:
+ - makefu/**/*
after_script:
- - rm -f deploy.key
+ - rm -rf .ssh/
diff --git a/krebs/0tests/data/secrets/shack/muell_mail.js b/krebs/0tests/data/secrets/shack/muell_mail.js
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/krebs/0tests/data/secrets/shack/muell_mail.js
diff --git a/krebs/0tests/data/secrets/shack/s3-power.json b/krebs/0tests/data/secrets/shack/s3-power.json
new file mode 100644
index 000000000..0967ef424
--- /dev/null
+++ b/krebs/0tests/data/secrets/shack/s3-power.json
@@ -0,0 +1 @@
+{}
diff --git a/krebs/0tests/data/secrets/shack/unifi-prometheus-pw b/krebs/0tests/data/secrets/shack/unifi-prometheus-pw
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/krebs/0tests/data/secrets/shack/unifi-prometheus-pw
diff --git a/krebs/1systems/puyak/config.nix b/krebs/1systems/puyak/config.nix
index af11c6944..ea73e4bd2 100644
--- a/krebs/1systems/puyak/config.nix
+++ b/krebs/1systems/puyak/config.nix
@@ -7,13 +7,14 @@
<stockholm/krebs/2configs/secret-passwords.nix>
<stockholm/krebs/2configs/hw/x220.nix>
- <stockholm/krebs/2configs/stats/puyak-client.nix>
<stockholm/krebs/2configs/binary-cache/nixos.nix>
<stockholm/krebs/2configs/binary-cache/prism.nix>
<stockholm/krebs/2configs/go.nix>
<stockholm/krebs/2configs/ircd.nix>
<stockholm/krebs/2configs/news.nix>
<stockholm/krebs/2configs/news-spam.nix>
+ <stockholm/krebs/2configs/shack/prometheus/node.nix>
+ <stockholm/krebs/2configs/shack/gitlab-runner.nix>
];
krebs.build.host = config.krebs.hosts.puyak;
@@ -59,9 +60,9 @@
};
};
- services.logind.extraConfig = ''
- HandleLidSwitch=ignore
- '';
+ services.logind.lidSwitch = "ignore";
+ services.logind.lidSwitchExternalPower = "ignore";
+
services.udev.extraRules = ''
SUBSYSTEM=="net", ATTR{address}=="8c:70:5a:b2:84:58", NAME="wl0"
diff --git a/krebs/1systems/wolf/config.nix b/krebs/1systems/wolf/config.nix
index 7ca0f0ec1..3cb358ca3 100644
--- a/krebs/1systems/wolf/config.nix
+++ b/krebs/1systems/wolf/config.nix
@@ -23,6 +23,16 @@ in
# <stockholm/krebs/2configs/shack/nix-cacher.nix>
# Say if muell will be collected
<stockholm/krebs/2configs/shack/muell_caller.nix>
+ # provide muellshack api
+ <stockholm/krebs/2configs/shack/muellshack.nix>
+ # provide light control api
+ <stockholm/krebs/2configs/shack/node-light.nix>
+ # send mail if muell was not handled
+ <stockholm/krebs/2configs/shack/muell_mail.nix>
+ # send mail if muell was not handled
+ <stockholm/krebs/2configs/shack/s3-power.nix>
+ # powerraw usb serial to mqtt and raw socket
+ <stockholm/krebs/2configs/shack/powerraw.nix>
# create samba share for anonymous usage with the laser and 3d printer pc
<stockholm/krebs/2configs/shack/share.nix>
@@ -38,13 +48,20 @@ in
<stockholm/krebs/2configs/shack/mqtt_sub.nix>
## Collect radioactive data and put into graphite
<stockholm/krebs/2configs/shack/radioactive.nix>
+ ## mqtt.shack
+ <stockholm/krebs/2configs/shack/mqtt.nix>
## Collect local statistics via collectd and send to collectd
<stockholm/krebs/2configs/stats/wolf-client.nix>
- ## write collectd statistics to wolf.shack
- <stockholm/krebs/2configs/collectd-base.nix>
+
{ services.influxdb.enable = true; }
<stockholm/krebs/2configs/shack/netbox.nix>
+ <stockholm/krebs/2configs/shack/prometheus/server.nix>
+ <stockholm/krebs/2configs/shack/prometheus/node.nix>
+ <stockholm/krebs/2configs/shack/prometheus/unifi.nix>
+ <stockholm/krebs/2configs/collectd-base.nix> # home-assistant
+ { services.influxdb.enable = true; }
+
];
# use your own binary cache, fallback use cache.nixos.org (which is used by
# apt-cacher-ng in first place)
@@ -76,10 +93,12 @@ in
networking = {
firewall.enable = false;
firewall.allowedTCPPorts = [ 8088 8086 8083 ];
- interfaces."${ext-if}".ipv4.addresses = [{
- address = shack-ip;
- prefixLength = 20;
- }];
+ interfaces."${ext-if}".ipv4.addresses = [
+ {
+ address = shack-ip;
+ prefixLength = 20;
+ }
+ ];
defaultGateway = "10.42.0.1";
nameservers = [ "10.42.0.100" "10.42.0.200" ];
@@ -125,6 +144,7 @@ in
config.krebs.users.raute.pubkey
config.krebs.users.makefu-omo.pubkey
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAEAQDb9NPa2Hf51afcG1H13UPbE5E02J8aC9a1sGCRls592wAVlQbmojYR1jWDPA2m32Bsyv0ztqi81zDyndWWZPQVJVBk00VjYBcgk6D5ifqoAuWLzfuHJPWZGOvBf/U74/LNFNUkj1ywjneK7HYTRPXrRBBfBSQNmQzkvue7s599L2vdueZKyjNsMpx2m6nm2SchaMuDskSQut/168JgU1l4M8BeT68Bo4WdelhBYnhSI1a59FGkgdu2SCjyighLQRy2sOH3ksnkHWENPkA+wwQOlKl7R3DsEybrNd4NU9FSwFDyDmdhfv5gJp8UGSFdjAwx43+8zM5t5ruZ25J0LnVb0PuTuRA00UsW83MkLxFpDQLrQV08tlsY6iGrqxP67C3VJ6t4v6oTp7/vaRLhEFc1PhOLh+sZ18o8MLO+e2rGmHGHQnSKfBOLUvDMGa4jb01XBGjdnIXLOkVo79YR5jZn7jJb2gTZ95OD6bWSDADoURSuwuLa7kh4ti1ItAKuhkIvbuky3rRVvQEc92kJ6aNUswIUXJa0K2ibbIY6ycKAA3Ljksl3Mm9KzOn6yc/i/lSF+SOrTGhabPJigKkIoqKIwnV5IU3gkfsxPQJOBMPqHDGAOeYQe3WpWedEPYuhQEczw4exMb9TkNE96F71PzuQPJDl5sPAWyPLeMKpy5XbfRiF2by4nxN3ZIQvjtoyVkjNV+qM0q0yKBzLxuRAEQOZ2yCEaBudZQkQiwHD97H2vu4SRQ/2aOie1XiOnmdbQRDZSO3BsoDK569K1w+gDfSnqY7zVUMj6tw+uKx6Gstck5lbvYMtdWKsfPv/pDM8eyIVFLL93dKTX+ertcQj6xDwLfOiNubE5ayFXhYkjwImV6NgfBuq+3hLK0URP2rPlOZbbZTQ0WlKD6CCRZPMSZCU9oD2zYfqpvRArBUcdkAwGePezORkfJQLE6mYEJp6pdFkJ/IeFLbO6M0lZVlfnpzAC9kjjkMCRofZUETcFSppyTImCbgo3+ok59/PkNU5oavBXyW80ue2tWHr08HX/QALNte3UITmIIlU6SFMCPMWJqadK1eDPWfJ4H4iDXRNn3D5wqN++iMloKvpaj0wieqXLY4+YfvNTNr177OU48GEWW8DnoEkbpwsCbjPxznGDQhdDqdYyMY/fDgRQReKITvKYGHRzesGysw5cKsp9LEfXD0R6WE2TeiiENla5AWzTgXJB0AyZEcOiIfqOgT9Nr9S8q5gc/BdA7P+jhGGJgEHhV3dVlfIZ7pmZc27Yu7UTQ0lbAKWqcMSTOdne+QL6ILzbvLrQwdvax4tQdm5opfU16SrOox1AMwAbkdq84z6uJqYVx3cUXfMJgTyDNrVv3or root@plattenschwein" # for backup
+ "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC1Lx5MKtVjB/Ef6LpEiIAgVwY5xKQFdHuLQR+odQO4cAgxj1QaIXGN0moixY52DebVQhAtiCNiFZ83uJyOj8kmu30yuXwtSOQeqziA859qMJKZ4ZcYdKvbXwnf2Chm5Ck/0FvtpjTWHIZAogwP1wQto/lcqHOjrTAnZeJfQuHTswYUSnmUU5zdsEZ9HidDPUc2Gv0wkBNd+KMQyOZl0HkaxHWvn0h4KK4hYZisOpeTfXJxD87bo+Eg4LL2vvnHW6dF6Ygrbd/0XRMsRRI8OAReVBUoJn7IE1wwAl/FpblNmhaF9hlL7g7hR1ADvaWMMw0e8SSzW6Y+oIa8qFQL6wR1 gitlab-builder" # for being deployed by gitlab ci
];
services.udev.extraRules = ''
SUBSYSTEM=="net", ATTR{address}=="${external-mac}", NAME="${ext-if}"
diff --git a/krebs/2configs/collectd-base.nix b/krebs/2configs/collectd-base.nix
index 440f83fce..71a00be3a 100644
--- a/krebs/2configs/collectd-base.nix
+++ b/krebs/2configs/collectd-base.nix
@@ -9,7 +9,7 @@ let
ModulePath "${collectd-connect-time}/lib/${python.libPrefix}/site-packages/"
Import "collectd_connect_time"
<Module collectd_connect_time>
- target "localhost:22" "google.com" "google.de" "gum.r:22" "gum.krebsco.de" "heidi.shack:22" "10.42.0.1:22" "heise.de" "t-online.de"
+ target "localhost:22" "google.com" "google.de" "gum.r:22" "gum.krebsco.de" "10.42.0.1:22" "heise.de" "t-online.de"
interval 10
</Module>
</Plugin>
@@ -18,7 +18,7 @@ let
LoadPlugin write_graphite
<Plugin "write_graphite">
<Carbon>
- Host "heidi.shack"
+ Host "wolf.r"
Port "2003"
Prefix "retiolum."
EscapeCharacter "_"
diff --git a/krebs/2configs/default.nix b/krebs/2configs/default.nix
index fafcd72c3..8771c0e1d 100644
--- a/krebs/2configs/default.nix
+++ b/krebs/2configs/default.nix
@@ -34,6 +34,13 @@ with import <stockholm/lib>;
rxvt_unicode.terminfo
];
+ i18n = {
+ consoleKeyMap = "us";
+ defaultLocale = lib.mkForce "C";
+ };
+
+
+
programs.ssh.startAgent = false;
services.openssh = {
diff --git a/krebs/2configs/shack/gitlab-runner.nix b/krebs/2configs/shack/gitlab-runner.nix
index 0fd06426a..5f2ca02d9 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/mqtt.nix b/krebs/2configs/shack/mqtt.nix
new file mode 100644
index 000000000..8e5438db2
--- /dev/null
+++ b/krebs/2configs/shack/mqtt.nix
@@ -0,0 +1,14 @@
+{
+ 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/muell_mail.nix b/krebs/2configs/shack/muell_mail.nix
new file mode 100644
index 000000000..39d49918d
--- /dev/null
+++ b/krebs/2configs/shack/muell_mail.nix
@@ -0,0 +1,33 @@
+{ config, lib, pkgs, ... }:
+
+let
+ pkg = pkgs.callPackage (
+ pkgs.fetchgit {
+ url = "https://git.shackspace.de/rz/muell_mail";
+ rev = "861ec25ab22797d8961efb32e72d79e113aa9f0f";
+ sha256 = "sha256:18cw95zbr7isv4cw80cbpd84n5z208fwh5390i6j10jkn398mjq2";
+ }) {};
+ 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";
+ Restart = "always";
+ PrivateTmp = true;
+ };
+ };
+}
diff --git a/krebs/2configs/shack/muellshack.nix b/krebs/2configs/shack/muellshack.nix
new file mode 100644
index 000000000..1e6843bdf
--- /dev/null
+++ b/krebs/2configs/shack/muellshack.nix
@@ -0,0 +1,43 @@
+{ config, lib, pkgs, ... }:
+
+let
+ pkg = pkgs.callPackage (
+ pkgs.fetchgit {
+ url = "https://git.shackspace.de/rz/muellshack";
+ rev = "d8a5e2d4c0a22804838675ac42b468299dcd9a76";
+ sha256 = "0ff6q64dgdxmpszp94z100fdic175b1vvxn4crg8p0jcabzxsv0m";
+ }) {};
+ 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";
+ Restart = "always";
+ PrivateTmp = true;
+ };
+ };
+}
diff --git a/krebs/2configs/shack/node-light.nix b/krebs/2configs/shack/node-light.nix
new file mode 100644
index 000000000..63772f182
--- /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}/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";
+ Restart = "always";
+ PrivateTmp = true;
+ };
+ };
+}
diff --git a/krebs/2configs/shack/powerraw.nix b/krebs/2configs/shack/powerraw.nix
new file mode 100644
index 000000000..af3f129c1
--- /dev/null
+++ b/krebs/2configs/shack/powerraw.nix
@@ -0,0 +1,72 @@
+{ 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:0wfpm3ik5r081qv2crmpjwylgg2v8ximq347qh0fzq1rwv0dqbnn";
+ }) {};
+in {
+ # receive response from light.shack / standby.shack
+ networking.firewall.allowedUDPPorts = [ 11111 ];
+ users.users.powermeter.extraGroups = [ "dialout" ];
+
+ systemd.services.powermeter-serial2mqtt = {
+ description = "powerraw Serial -> mqtt";
+ wantedBy = [ "multi-user.target" ];
+ serviceConfig = {
+ User = "powermeter";
+ ExecStart = "${pkg}/bin/powermeter-serial2mqtt";
+ Restart = "always";
+ PrivateTmp = true;
+ };
+ };
+
+ systemd.services.powermeter-mqtt2socket = {
+ description = "powerraw mqtt -> raw socket 11111";
+ wantedBy = [ "multi-user.target" ];
+ serviceConfig = {
+ User = "powermeter";
+ ExecStart = "${pkg}/bin/powermeter-mqtt2socket";
+ Restart = "always";
+ PrivateTmp = true;
+ };
+ };
+
+ services.telegraf = {
+ enable = true;
+ extraConfig = {
+ agent.debug = false;
+ outputs = {
+ influxdb = [{
+ urls = [ influx-url ];
+ database = "telegraf";
+ }];
+ };
+ };
+ };
+
+ services.telegraf.extraConfig.inputs.mqtt_consumer = let
+ genTopic = name: topic: tags: {
+ servers = [ "tcp://mqtt.shack:1883" ];
+ qos = 0;
+ connection_timeout = "30s";
+ topics = [ topic ];
+ inherit tags;
+ persistent_session = false;
+ name_override = name;
+ data_format = "value";
+ data_type = "float";
+ };
+ sensor = "total";
+ types = [ "Voltage" "Current" "Power" ];
+ phases = [ 1 2 3 ];
+ in
+ [ (genTopic "Power consumed" "/power/${sensor}/consumed" { inherit sensor; }) ] ++
+ (lib.flatten (map (type: (map (phase: (genTopic "Power" "/power/${sensor}/L${toString phase}/${type}" { inherit sensor phase type; }) ) phases)) types));
+}
diff --git a/krebs/2configs/shack/prometheus/