From f786e5a22f4dcf6a852d8cf87695e6fd90faf888 Mon Sep 17 00:00:00 2001
From: makefu <github@syntax-fehler.de>
Date: Wed, 27 Feb 2019 23:27:39 +0100
Subject: [PATCH 01/11] ma: make extensive use of defaults for inventory

---
 krebs/3modules/makefu/default.nix             | 189 ++++++------------
 .../makefu/{tinc => retiolum}/cake.pub        |   0
 .../makefu/{tinc => retiolum}/crapi.pub       |   0
 .../makefu/{tinc => retiolum}/filebitch.pub   |   0
 .../makefu/{tinc => retiolum}/fileleech.pub   |   0
 .../makefu/{tinc => retiolum}/filepimp.pub    |   0
 .../makefu/{tinc => retiolum}/firecracker.pub |   0
 .../makefu/{tinc => retiolum}/flap.pub        |   0
 .../makefu/{tinc => retiolum}/gum.pub         |   0
 .../makefu/{tinc => retiolum}/nukular.pub     |   0
 .../makefu/{tinc => retiolum}/omo.pub         |   0
 .../makefu/{tinc => retiolum}/sdev.pub        |   0
 .../{tinc => retiolum}/senderechner.pub       |   0
 .../makefu/{tinc => retiolum}/studio.pub      |   0
 .../makefu/{tinc => retiolum}/tsp.pub         |   0
 .../makefu/{tinc => retiolum}/wbob.pub        |   0
 .../3modules/makefu/{tinc => retiolum}/x.pub  |   0
 krebs/3modules/makefu/wiregrill/gum.pub       |   1 +
 krebs/3modules/makefu/wiregrill/x.pub         |   1 +
 19 files changed, 65 insertions(+), 126 deletions(-)
 rename krebs/3modules/makefu/{tinc => retiolum}/cake.pub (100%)
 rename krebs/3modules/makefu/{tinc => retiolum}/crapi.pub (100%)
 rename krebs/3modules/makefu/{tinc => retiolum}/filebitch.pub (100%)
 rename krebs/3modules/makefu/{tinc => retiolum}/fileleech.pub (100%)
 rename krebs/3modules/makefu/{tinc => retiolum}/filepimp.pub (100%)
 rename krebs/3modules/makefu/{tinc => retiolum}/firecracker.pub (100%)
 rename krebs/3modules/makefu/{tinc => retiolum}/flap.pub (100%)
 rename krebs/3modules/makefu/{tinc => retiolum}/gum.pub (100%)
 rename krebs/3modules/makefu/{tinc => retiolum}/nukular.pub (100%)
 rename krebs/3modules/makefu/{tinc => retiolum}/omo.pub (100%)
 rename krebs/3modules/makefu/{tinc => retiolum}/sdev.pub (100%)
 rename krebs/3modules/makefu/{tinc => retiolum}/senderechner.pub (100%)
 rename krebs/3modules/makefu/{tinc => retiolum}/studio.pub (100%)
 rename krebs/3modules/makefu/{tinc => retiolum}/tsp.pub (100%)
 rename krebs/3modules/makefu/{tinc => retiolum}/wbob.pub (100%)
 rename krebs/3modules/makefu/{tinc => retiolum}/x.pub (100%)
 create mode 100644 krebs/3modules/makefu/wiregrill/gum.pub
 create mode 100644 krebs/3modules/makefu/wiregrill/x.pub

diff --git a/krebs/3modules/makefu/default.nix b/krebs/3modules/makefu/default.nix
index 8c7e415cb..c65b27973 100644
--- a/krebs/3modules/makefu/default.nix
+++ b/krebs/3modules/makefu/default.nix
@@ -5,128 +5,103 @@
 with import <stockholm/lib>;
 { config, ... }: let
 
-  hostDefaults = hostName: host: flip recursiveUpdate host ({
-    owner = config.krebs.users.makefu;
-  } // optionalAttrs (host.nets?retiolum) {
-    nets.retiolum.ip6.addr =
-      (krebs.genipv6 "retiolum" "makefu" { inherit hostName; }).address;
-  });
+  hostDefaults = hostName: host: foldl' recursiveUpdate {} [
+    {
+      owner = config.krebs.users.makefu;
+    }
+    # Retiolum defaults
+    (let
+      pubkey-path = ./retiolum + "/${hostName}.pub";
+    in optionalAttrs (pathExists pubkey-path) {
+      nets.retiolum = {
+        tinc.pubkey = readFile pubkey-path;
+        aliases = [
+          "${hostName}.r"
+        ];
+        ip6.addr =
+          (krebs.genipv6 "retiolum" "makefu" { inherit hostName; }).address;
+      };
+    })
+    # Wiregrill defaults
+    (let
+      pubkey-path = ./wiregrill + "/${hostName}.pub";
+    in optionalAttrs (pathExists pubkey-path) {
+      nets.wiregrill = {
+        aliases = [
+          "${hostName}.w"
+        ];
+        ip6.addr =
+          (krebs.genipv6 "wiregrill" "makefu" { inherit hostName; }).address;
+        wireguard.pubkey = readFile pubkey-path;
+      };
+    })
+    # SSHD defaults
+    (let
+      pubkey-path = ./sshd + "/${hostName}.pub";
+    in optionalAttrs (pathExists pubkey-path) {
+      ssh.pubkey = readFile pubkey-path;
+      # We assume that if the sshd pubkey exits then there must be a privkey in
+      # the screts store as well
+      ssh.privkey.path = <secrets/ssh_host_ed25519_key>;
+    })
+    host
+  ];
 
   pub-for = name: builtins.readFile (./ssh + "/${name}.pub");
-  sshd-for = name: builtins.readFile (./sshd + "/${name}.pub");
-  tinc-for= name: builtins.readFile (./tinc + "/${name}.pub");
-
+  w6 = ip: (krebs.genipv6 "wiregrill" "makefu" ip).address;
 in {
   hosts = mapAttrs hostDefaults {
     cake = rec {
       cores = 4;
       ci = false;
       nets = {
-        retiolum = {
-          ip4.addr = "10.243.136.236";
-          aliases = [
-            "cake.r"
-          ];
-          tinc.pubkey = tinc-for "cake";
-        };
+        retiolum.ip4.addr = "10.243.136.236";
       };
-      ssh.privkey.path = <secrets/ssh_host_ed25519_key>;
-      ssh.pubkey = sshd-for "cake";
     };
     crapi = rec { # raspi1
       cores = 1;
       ci = false;
       nets = {
-        retiolum = {
-          ip4.addr = "10.243.136.237";
-          aliases = [
-            "crapi.r"
-          ];
-          tinc.pubkey = tinc-for "crapi";
-        };
+        retiolum.ip4.addr = "10.243.136.237";
       };
-      ssh.privkey.path = <secrets/ssh.id_ed25519>;
-      ssh.pubkey = sshd-for "crapi";
     };
     firecracker = {
       cores = 4;
       nets = {
-        retiolum = {
-          ip4.addr = "10.243.12.12";
-          ip6.addr = "42:0:0:0:0:0:0:12";
-          aliases = [
-            "firecracker.r"
-          ];
-          tinc.pubkey = tinc-for "firecracker";
-        };
+        retiolum.ip4.addr = "10.243.12.12";
       };
-      ssh.privkey.path = <secrets/ssh.id_ed25519>;
-      ssh.pubkey = sshd-for "firecracker";
     };
 
     studio = rec {
       ci = false;
       cores = 4;
-      ssh.privkey.path = <secrets/ssh_host_ed25519_key>;
-      ssh.pubkey = sshd-for "studio";
       nets = {
-        retiolum = {
-          ip4.addr = "10.243.227.163";
-          aliases = [
-            "studio.r"
-          ];
-          tinc.pubkey = tinc-for "studio";
-        };
+        retiolum.ip4.addr = "10.243.227.163";
       };
     };
     fileleech = rec {
       ci = false;
       cores = 4;
-      ssh.privkey.path = <secrets/ssh_host_ed25519_key>;
-      ssh.pubkey = "";
       nets = {
-        retiolum = {
-          ip4.addr = "10.243.113.98";
-          aliases = [
-            "fileleech.r"
-          ];
-          tinc.pubkey = tinc-for "fileleech";
-        };
+        retiolum.ip4.addr = "10.243.113.98";
       };
     };
     tsp = {
       ci = true;
       cores = 1;
       nets = {
-        retiolum = {
-          ip4.addr = "10.243.0.212";
-          aliases = [
-            "tsp.r"
-          ];
-          tinc.pubkey = tinc-for "tsp";
-        };
+        retiolum.ip4.addr = "10.243.0.212";
       };
     };
     x = {
       ci = true;
       cores = 4;
       nets = {
-        retiolum = {
-          ip4.addr = "10.243.0.91";
-          aliases = [
-            "x.r"
-          ];
-          tinc.pubkey = tinc-for "x";
+        retiolum.ip4.addr = "10.243.0.91";
+        wiregrill = {
+          # defaults
         };
-        #wiregrill = {
-        #  aliases = [
-        #    "x.w"
-        #  ];
-        #  wireguard.pubkey = "fe5smvKVy5GAn7EV4w4tav6mqIAKhGWQotm7dRuRt1g=";
-        #};
       };
-      ssh.privkey.path = <secrets/ssh_host_ed25519_key>;
-      ssh.pubkey = sshd-for "x";
 
     };
     filepimp = rec {
@@ -139,13 +114,7 @@ in {
             "filepimp.lan"
           ];
         };
-        retiolum = {
-          ip4.addr = "10.243.153.102";
-          aliases = [
-            "filepimp.r"
-          ];
-          tinc.pubkey = tinc-for "filepimp";
-        };
+        retiolum.ip4.addr = "10.243.153.102";
       };
     };
 
@@ -163,15 +132,11 @@ in {
         retiolum = {
           ip4.addr = "10.243.0.89";
           aliases = [
-            "omo.r"
             "dcpp.omo.r"
             "torrent.omo.r"
           ];
-          tinc.pubkey = tinc-for "omo";
         };
       };
-      ssh.privkey.path = <secrets/ssh.id_ed25519>;
-      ssh.pubkey = sshd-for "omo";
     };
     wbob = rec {
       ci = true;
@@ -180,14 +145,10 @@ in {
         retiolum = {
           ip4.addr = "10.243.214.15";
           aliases = [
-            "wbob.r"
             "hydra.wbob.r"
           ];
-          tinc.pubkey = tinc-for "wbob";
         };
       };
-      ssh.privkey.path = <secrets/ssh.id_ed25519>;
-      ssh.pubkey = sshd-for "wbob";
     };
     gum = rec {
       ci = true;
@@ -231,13 +192,16 @@ in {
             "nextgum.i"
           ];
         };
-        #wiregrill = {
-        #  via = internet;
-        #  aliases = [
-        #    "gum.w"
-        #  ];
-        #  wireguard.pubkey = "yAKvxTvcEVdn+MeKsmptZkR3XSEue+wSyLxwcjBYxxo=";
-        #};
+        wiregrill = {
+          via = internet;
+          ip6.addr = w6 "1";
+          wireguard = {
+            subnets = [
+              (krebs.genipv6 "wiregrill" "external" 0).subnetCIDR
+              (krebs.genipv6 "wiregrill" "makefu" 0).subnetCIDR
+            ];
+          };
+        };
         retiolum = {
           via = internet;
           ip4.addr = "10.243.0.213";
@@ -250,7 +214,6 @@ in {
             "dcpp.gum.r"
             "dcpp.nextgum.r"
             "graph.r"
-            "gum.r"
             "logs.makefu.r"
             "netdata.makefu.r"
             "nextgum.r"
@@ -262,25 +225,15 @@ in {
             "wiki.gum.r"
             "wiki.makefu.r"
           ];
-          tinc.pubkey = tinc-for "gum";
         };
       };
-      ssh.pubkey = sshd-for "gum";
     };
 
     sdev = rec {
       ci = true;
       cores = 1;
-      ssh.privkey.path = <secrets/ssh_host_ed25519_key>;
-      ssh.pubkey = sshd-for "sdev";
       nets = {
-        retiolum = {
-          ip4.addr = "10.243.83.237";
-          aliases = [
-            "sdev.r"
-          ];
-          tinc.pubkey = tinc-for "sdev";
-        };
+        retiolum.ip4.addr = "10.243.83.237";
       };
     };
 
@@ -304,10 +257,6 @@ in {
         };
         retiolum = {
           ip4.addr = "10.243.211.172";
-          aliases = [
-            "flap.r"
-          ];
-          tinc.pubkey = tinc-for "flap";
         };
       };
     };
@@ -317,10 +266,6 @@ in {
       nets = {
         retiolum = {
           ip4.addr = "10.243.231.219";
-          aliases = [
-            "nukular.r"
-          ];
-          tinc.pubkey = tinc-for "nukular";
         };
       };
     };
@@ -330,10 +275,6 @@ in {
       nets = {
         retiolum = {
           ip4.addr = "10.243.189.130";
-          aliases = [
-            "filebitch.r"
-          ];
-          tinc.pubkey = tinc-for "filebitch";
         };
       };
     };
@@ -343,10 +284,6 @@ in {
       nets = {
         retiolum = {
           ip4.addr = "10.243.0.163";
-          aliases = [
-            "senderechner.r"
-          ];
-          tinc.pubkey = tinc-for "senderechner";
         };
       };
     };
diff --git a/krebs/3modules/makefu/tinc/cake.pub b/krebs/3modules/makefu/retiolum/cake.pub
similarity index 100%
rename from krebs/3modules/makefu/tinc/cake.pub
rename to krebs/3modules/makefu/retiolum/cake.pub
diff --git a/krebs/3modules/makefu/tinc/crapi.pub b/krebs/3modules/makefu/retiolum/crapi.pub
similarity index 100%
rename from krebs/3modules/makefu/tinc/crapi.pub
rename to krebs/3modules/makefu/retiolum/crapi.pub
diff --git a/krebs/3modules/makefu/tinc/filebitch.pub b/krebs/3modules/makefu/retiolum/filebitch.pub
similarity index 100%
rename from krebs/3modules/makefu/tinc/filebitch.pub
rename to krebs/3modules/makefu/retiolum/filebitch.pub
diff --git a/krebs/3modules/makefu/tinc/fileleech.pub b/krebs/3modules/makefu/retiolum/fileleech.pub
similarity index 100%
rename from krebs/3modules/makefu/tinc/fileleech.pub
rename to krebs/3modules/makefu/retiolum/fileleech.pub
diff --git a/krebs/3modules/makefu/tinc/filepimp.pub b/krebs/3modules/makefu/retiolum/filepimp.pub
similarity index 100%
rename from krebs/3modules/makefu/tinc/filepimp.pub
rename to krebs/3modules/makefu/retiolum/filepimp.pub
diff --git a/krebs/3modules/makefu/tinc/firecracker.pub b/krebs/3modules/makefu/retiolum/firecracker.pub
similarity index 100%
rename from krebs/3modules/makefu/tinc/firecracker.pub
rename to krebs/3modules/makefu/retiolum/firecracker.pub
diff --git a/krebs/3modules/makefu/tinc/flap.pub b/krebs/3modules/makefu/retiolum/flap.pub
similarity index 100%
rename from krebs/3modules/makefu/tinc/flap.pub
rename to krebs/3modules/makefu/retiolum/flap.pub
diff --git a/krebs/3modules/makefu/tinc/gum.pub b/krebs/3modules/makefu/retiolum/gum.pub
similarity index 100%
rename from krebs/3modules/makefu/tinc/gum.pub
rename to krebs/3modules/makefu/retiolum/gum.pub
diff --git a/krebs/3modules/makefu/tinc/nukular.pub b/krebs/3modules/makefu/retiolum/nukular.pub
similarity index 100%
rename from krebs/3modules/makefu/tinc/nukular.pub
rename to krebs/3modules/makefu/retiolum/nukular.pub
diff --git a/krebs/3modules/makefu/tinc/omo.pub b/krebs/3modules/makefu/retiolum/omo.pub
similarity index 100%
rename from krebs/3modules/makefu/tinc/omo.pub
rename to krebs/3modules/makefu/retiolum/omo.pub
diff --git a/krebs/3modules/makefu/tinc/sdev.pub b/krebs/3modules/makefu/retiolum/sdev.pub
similarity index 100%
rename from krebs/3modules/makefu/tinc/sdev.pub
rename to krebs/3modules/makefu/retiolum/sdev.pub
diff --git a/krebs/3modules/makefu/tinc/senderechner.pub b/krebs/3modules/makefu/retiolum/senderechner.pub
similarity index 100%
rename from krebs/3modules/makefu/tinc/senderechner.pub
rename to krebs/3modules/makefu/retiolum/senderechner.pub
diff --git a/krebs/3modules/makefu/tinc/studio.pub b/krebs/3modules/makefu/retiolum/studio.pub
similarity index 100%
rename from krebs/3modules/makefu/tinc/studio.pub
rename to krebs/3modules/makefu/retiolum/studio.pub
diff --git a/krebs/3modules/makefu/tinc/tsp.pub b/krebs/3modules/makefu/retiolum/tsp.pub
similarity index 100%
rename from krebs/3modules/makefu/tinc/tsp.pub
rename to krebs/3modules/makefu/retiolum/tsp.pub
diff --git a/krebs/3modules/makefu/tinc/wbob.pub b/krebs/3modules/makefu/retiolum/wbob.pub
similarity index 100%
rename from krebs/3modules/makefu/tinc/wbob.pub
rename to krebs/3modules/makefu/retiolum/wbob.pub
diff --git a/krebs/3modules/makefu/tinc/x.pub b/krebs/3modules/makefu/retiolum/x.pub
similarity index 100%
rename from krebs/3modules/makefu/tinc/x.pub
rename to krebs/3modules/makefu/retiolum/x.pub
diff --git a/krebs/3modules/makefu/wiregrill/gum.pub b/krebs/3modules/makefu/wiregrill/gum.pub
new file mode 100644
index 000000000..4a5f666cc
--- /dev/null
+++ b/krebs/3modules/makefu/wiregrill/gum.pub
@@ -0,0 +1 @@
+yAKvxTvcEVdn+MeKsmptZkR3XSEue+wSyLxwcjBYxxo=
diff --git a/krebs/3modules/makefu/wiregrill/x.pub b/krebs/3modules/makefu/wiregrill/x.pub
new file mode 100644
index 000000000..cfa9eb254
--- /dev/null
+++ b/krebs/3modules/makefu/wiregrill/x.pub
@@ -0,0 +1 @@
+fe5smvKVy5GAn7EV4w4tav6mqIAKhGWQotm7dRuRt1g=

From ec2dffd71e30f831c4ff631713dd14bea9e48df3 Mon Sep 17 00:00:00 2001
From: makefu <github@syntax-fehler.de>
Date: Wed, 27 Feb 2019 23:58:28 +0100
Subject: [PATCH 02/11] ma: add base name to aliases when overriding

---
 krebs/3modules/makefu/default.nix | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/krebs/3modules/makefu/default.nix b/krebs/3modules/makefu/default.nix
index c65b27973..b38c9104f 100644
--- a/krebs/3modules/makefu/default.nix
+++ b/krebs/3modules/makefu/default.nix
@@ -132,6 +132,7 @@ in {
         retiolum = {
           ip4.addr = "10.243.0.89";
           aliases = [
+            "omo.r"
             "dcpp.omo.r"
             "torrent.omo.r"
           ];
@@ -145,6 +146,7 @@ in {
         retiolum = {
           ip4.addr = "10.243.214.15";
           aliases = [
+            "wbob.r"
             "hydra.wbob.r"
           ];
         };
@@ -206,6 +208,7 @@ in {
           via = internet;
           ip4.addr = "10.243.0.213";
           aliases = [
+            "gum.r"
             "backup.makefu.r"
             "blog.gum.r"
             "blog.makefu.r"

From fb1d5f4addd1b3b564248b1359253bf788b1c08a Mon Sep 17 00:00:00 2001
From: makefu <github@syntax-fehler.de>
Date: Mon, 4 Mar 2019 08:47:18 +0100
Subject: [PATCH 03/11] ma pkgs.Fluffy: init at 2.7

---
 makefu/5pkgs/Fluffy/default.nix | 42 +++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 makefu/5pkgs/Fluffy/default.nix

diff --git a/makefu/5pkgs/Fluffy/default.nix b/makefu/5pkgs/Fluffy/default.nix
new file mode 100644
index 000000000..59a04a52d
--- /dev/null
+++ b/makefu/5pkgs/Fluffy/default.nix
@@ -0,0 +1,42 @@
+{ lib, pkgs, python3Packages, ... }:
+
+with python3Packages; buildPythonApplication rec {
+  name = "Fluffy-${version}";
+  format = "other";
+  version = "2.7";
+
+  src = pkgs.fetchFromGitHub {
+    owner = "fourminute";
+    repo = "Fluffy";
+    rev = "v${version}";
+    sha256 = "1l346bklidcl40q91cfdszrfskdwlmfjbmsc3mgs0i8wi1yhvq99";
+  };
+
+  prePatch = ''
+    sed -e "s|/tmp|$HOME/.config/fluffy|" -i linux/fluffy.desktop
+  '';
+
+  installPhase = ''
+    env
+    install -Dm 644 linux/80-fluffy-switch.rules "$out/etc/udev/rules.d/80-fluffy-switch.rules"
+    install -Dm 644 linux/fluffy.desktop "$out/usr/share/applications/fluffy.desktop"
+    install -Dm 644 icons/16x16/fluffy.png "$out/share/icons/hicolor/16x16/apps/fluffy.png"
+    install -Dm 644 icons/24x24/fluffy.png "$out/share/icons/hicolor/24x24/apps/fluffy.png"
+    install -Dm 644 icons/32x32/fluffy.png "$out/share/icons/hicolor/32x32/apps/fluffy.png"
+    install -Dm 644 icons/48x48/fluffy.png "$out/share/icons/hicolor/48x48/apps/fluffy.png"
+    install -Dm 644 icons/64x64/fluffy.png "$out/share/icons/hicolor/64x64/apps/fluffy.png"
+    install -Dm 644 icons/128x128/fluffy.png "$out/share/icons/hicolor/128x128/apps/fluffy.png"
+    install -Dm 755 fluffy.pyw "$out/bin/fluffy"
+    wrapProgram  "$out/bin/fluffy" --set PYTHONPATH "$PYTHONPATH"
+  '';
+
+  propagatedBuildInputs = [
+    pyqt5 pyusb  libusb1 configparser tkinter
+  ];
+
+  meta = {
+    homepage = https://github.com/fourminute/Fluffy;
+    description = "A feature-rich tool for installing NSPs";
+    license = lib.licenses.gpl3;
+  };
+}

From 9c702551abbf5c486d9dac3becc4d5e998511a52 Mon Sep 17 00:00:00 2001
From: makefu <github@syntax-fehler.de>
Date: Wed, 6 Mar 2019 16:42:27 +0100
Subject: [PATCH 04/11] ma bureautomation: split into files

---
 makefu/1systems/wbob/config.nix               |   3 +-
 .../bureautomation/automation/10h_timer.nix   | 147 ++++++++
 .../automation/bureau-shutdown.nix            |  55 +++
 .../bureautomation/automation/nachtlicht.nix  |  43 +++
 .../bureautomation/binary_sensor/buttons.nix  |  17 +
 .../bureautomation/binary_sensor/motion.nix   |  12 +
 .../bureautomation/camera/verkehrskamera.nix  |  14 +
 makefu/2configs/bureautomation/hass.nix       | 317 ++++--------------
 .../led-fader.nix                             |   2 +-
 .../2configs/bureautomation/light/buzzer.nix  |  28 ++
 .../bureautomation/light/statuslight.nix      |  56 ++++
 .../bureautomation/script/multi_blink.nix     |  37 ++
 .../bureautomation/sensor/espeasy.nix         |  31 ++
 .../bureautomation/sensor/influxdb.nix        |  18 +
 .../bureautomation/sensor/outside.nix         |  25 ++
 .../bureautomation/switch/tasmota_switch.nix  |  19 ++
 16 files changed, 561 insertions(+), 263 deletions(-)
 create mode 100644 makefu/2configs/bureautomation/automation/10h_timer.nix
 create mode 100644 makefu/2configs/bureautomation/automation/bureau-shutdown.nix
 create mode 100644 makefu/2configs/bureautomation/automation/nachtlicht.nix
 create mode 100644 makefu/2configs/bureautomation/binary_sensor/buttons.nix
 create mode 100644 makefu/2configs/bureautomation/binary_sensor/motion.nix
 create mode 100644 makefu/2configs/bureautomation/camera/verkehrskamera.nix
 rename makefu/2configs/{deployment => bureautomation}/led-fader.nix (94%)
 create mode 100644 makefu/2configs/bureautomation/light/buzzer.nix
 create mode 100644 makefu/2configs/bureautomation/light/statuslight.nix
 create mode 100644 makefu/2configs/bureautomation/script/multi_blink.nix
 create mode 100644 makefu/2configs/bureautomation/sensor/espeasy.nix
 create mode 100644 makefu/2configs/bureautomation/sensor/influxdb.nix
 create mode 100644 makefu/2configs/bureautomation/sensor/outside.nix
 create mode 100644 makefu/2configs/bureautomation/switch/tasmota_switch.nix

diff --git a/makefu/1systems/wbob/config.nix b/makefu/1systems/wbob/config.nix
index 3930406b1..ab77f16dd 100644
--- a/makefu/1systems/wbob/config.nix
+++ b/makefu/1systems/wbob/config.nix
@@ -9,6 +9,7 @@ in {
   imports =
     [ # Include the results of the hardware scan.
       <stockholm/makefu>
+      <stockholm/makefu/2configs/support-nixos.nix>
       <stockholm/makefu/2configs/zsh-user.nix>
       <stockholm/makefu/2configs/tools/core.nix>
       # <stockholm/makefu/2configs/disable_v6.nix>
@@ -39,7 +40,6 @@ in {
       <stockholm/makefu/2configs/stats/telegraf/europastats.nix>
       <stockholm/makefu/2configs/stats/external/aralast.nix>
       <stockholm/makefu/2configs/stats/arafetch.nix>
-      <stockholm/makefu/2configs/deployment/led-fader.nix>
       <stockholm/makefu/2configs/hw/mceusb.nix>
       # <stockholm/makefu/2configs/stats/telegraf/bamstats.nix>
       { environment.systemPackages = [ pkgs.vlc ]; }
@@ -51,6 +51,7 @@ in {
         ];
       }
       <stockholm/makefu/2configs/bureautomation>
+      <stockholm/makefu/2configs/bureautomation/led-fader.nix>
       <stockholm/makefu/2configs/bureautomation/mpd.nix>
       <stockholm/makefu/2configs/bureautomation/hass.nix>
       (let
diff --git a/makefu/2configs/bureautomation/automation/10h_timer.nix b/makefu/2configs/bureautomation/automation/10h_timer.nix
new file mode 100644
index 000000000..a311d468c
--- /dev/null
+++ b/makefu/2configs/bureautomation/automation/10h_timer.nix
@@ -0,0 +1,147 @@
+[
+  { alias = "start Felix 10h";
+    trigger = {
+      platform = "state";
+      entity_id = "binary_sensor.redbutton";
+      to = "on";
+    };
+    condition = {
+      condition = "and";
+      conditions = [
+        {
+          condition = "state";
+          entity_id = "timer.felix_10h";
+          state =  "idle";
+        }
+        {
+          condition = "time";
+          after   = "06:00:00";
+          before  = "12:00:00";
+        }
+      ];
+    };
+    action = [
+      { service = "timer.start";
+        entity_id =  [ "timer.felix_10h" "timer.felix_8_30h" "timer.felix_7h" ] ;
+      }
+      { service = "homeassistant.turn_on";
+        entity_id =  [
+          "script.buzz_red_led_fast"
+          "script.blitz_10s"
+        ];
+      }
+      { service = "light.turn_on";
+      data = {
+          effect = "2";
+          entity_id =  [ "light.status_felix" ];
+        };
+      }
+    ];
+  }
+
+  { alias = "Disable Felix timer at button press";
+    trigger = {
+      platform = "state";
+      entity_id = "binary_sensor.redbutton";
+      to = "on";
+    };
+    condition = {
+      condition = "and";
+      conditions = [
+        {
+          condition = "state";
+          entity_id = "timer.felix_10h";
+          state =  "active";
+        }
+        {
+          condition = "time";
+          after = "12:00:00";
+          before  = "22:00:00";
+        }
+      ];
+    };
+    action =
+    [
+      {
+        service = "timer.cancel";
+        entity_id =  [ "timer.felix_10h" "timer.felix_8_30h" "timer.felix_7h" ];
+      }
+      {
+        service = "homeassistant.turn_on";
+        entity_id =  [ "script.buzz_red_led_fast"  ];
+      }
+      {
+        service = "homeassistant.turn_off";
+        entity_id =  [ "light.status_felix"  ];
+      }
+    ];
+  }
+
+  {
+    alias = "Genug gearbeitet Felix";
+    trigger =
+    {
+      platform = "event";
+      event_type = "timer.finished";
+      event_data.entity_id = "timer.felix_7h";
+    };
+    action =
+    [
+      { service = "light.turn_on";
+        data = {
+          rgb_color= [0 255 0];
+          # effect = "0";
+          entity_id =  [ "light.status_felix" ];
+        };
+      }
+    ];
+  }
+
+  {
+    alias = "nun aber nach hause";
+    trigger =
+    {
+      platform = "event";
+      event_type = "timer.finished";
+      event_data.entity_id = "timer.felix_8_30h";
+    };
+    action =
+    [
+      { service = "light.turn_on";
+        data = {
+          rgb_color= [255 255 0];
+          # effect = "0";
+          entity_id =  [ "light.status_felix" ];
+        };
+      }
+    ];
+  }
+
+  {
+    alias = "Zu lange Felix!";
+    trigger =
+    {
+      platform = "event";
+      event_type = "timer.finished";
+      event_data.entity_id = "timer.felix_10h";
+    };
+    action =
+    [
+      # TODO: Pushbullet
+      {
+        service = "homeassistant.turn_on";
+        entity_id =  [
+          "script.buzz_red_led"
+          "script.blitz_10s"
+        ];
+      }
+      { service = "light.turn_on";
+        data = {
+          rgb_color= [255 0 0];
+          effect = "0";
+          entity_id =  [ "light.status_felix" ];
+        };
+      }
+    ];
+  }
+]
diff --git a/makefu/2configs/bureautomation/automation/bureau-shutdown.nix b/makefu/2configs/bureautomation/automation/bureau-shutdown.nix
new file mode 100644
index 000000000..9e6574300
--- /dev/null
+++ b/makefu/2configs/bureautomation/automation/bureau-shutdown.nix
@@ -0,0 +1,55 @@
+[
+  { alias = "Turn on Fernseher on movement";
+    trigger = {
+      platform = "state";
+      entity_id = "binary_sensor.motion";
+      to = "on";
+    };
+    action = {
+      service = "homeassistant.turn_on";
+      entity_id =  [
+        "switch.fernseher"
+        "switch.feuer"
+      ];
+    };
+  }
+  { alias = "Turn off Fernseher 10 minutes after last movement";
+    trigger = [
+    { # trigger when movement was detected at the time
+      platform = "state";
+      entity_id = "binary_sensor.motion";
+      to = "off";
+      for.minutes = 10;
+    }
+    { # trigger at 20:00 no matter what
+      # to avoid 'everybody left before 18:00:00'
+      platform = "time";
+      at = "18:00:00";
+    }
+  ];
+    action = {
+      service = "homeassistant.turn_off";
+      entity_id =  [
+        "switch.fernseher"
+        "switch.feuer"
+        "light.status_felix"
+      ];
+    };
+    condition =
+    { condition = "and";
+      conditions = [
+        {
+          condition = "time";
+          before = "06:30:00"; #only turn off between 6:30 and 18:00
+          after  = "18:00:00";
+          # weekday = [ "mon" "tue" "wed" "thu" "fri" ];
+        }
+        {
+          condition = "state";
+          entity_id = "binary_sensor.motion";
+          state = "off";
+        }
+      ];
+    };
+  }
+]
diff --git a/makefu/2configs/bureautomation/automation/nachtlicht.nix b/makefu/2configs/bureautomation/automation/nachtlicht.nix
new file mode 100644
index 000000000..066e9b06c
--- /dev/null
+++ b/makefu/2configs/bureautomation/automation/nachtlicht.nix
@@ -0,0 +1,43 @@
+[
+        {
+          alias = "Turn off Nachtlicht on sunrise";
+          trigger =
+          {
+            platform = "sun";
+            event = "sunrise";
+          };
+          action =
+          {
+            service = "homeassistant.turn_off";
+            entity_id =  [ "switch.nachtlicht" ];
+          };
+        }
+
+        {
+          alias = "Turn on Nachtlicht on motion and dusk";
+          trigger =
+          {
+            platform = "state";
+            entity_id = "binary_sensor.motion";
+            to = "on";
+          };
+          condition = # 'when dark'
+          {
+            condition = "or";
+            conditions = [
+              { condition = "sun";
+                after = "sunset";
+                after_offset = "-00:45:00"; # on dusk
+              }
+              { condition = "sun";
+                before = "sunrise";
+              }
+            ];
+          };
+          action =
+          {
+            service = "homeassistant.turn_on";
+            entity_id =  [ "switch.nachtlicht" ];
+          };
+        }
+]
diff --git a/makefu/2configs/bureautomation/binary_sensor/buttons.nix b/makefu/2configs/bureautomation/binary_sensor/buttons.nix
new file mode 100644
index 000000000..e23c4a362
--- /dev/null
+++ b/makefu/2configs/bureautomation/binary_sensor/buttons.nix
@@ -0,0 +1,17 @@
+let
+  tasmota_button = name: topic:
+  # detects a pushbutton press from tasmota
+  { platform = "mqtt";
+    inherit name;
+    state_topic = "/bam/${topic}/cmnd/POWER";
+    availability_topic = "/bam/${topic}/tele/LWT";
+    payload_on = "ON";
+    payload_off = "OFF";
+    payload_available= "Online";
+    payload_not_available= "Offline";
+    # expire_after = "5"; #expire after 5 seconds
+    qos = 1;
+  };
+in [
+  (tasmota_button "RedButton" "redbutton")
+]
diff --git a/makefu/2configs/bureautomation/binary_sensor/motion.nix b/makefu/2configs/bureautomation/binary_sensor/motion.nix
new file mode 100644
index 000000000..ad8fab038
--- /dev/null
+++ b/makefu/2configs/bureautomation/binary_sensor/motion.nix
@@ -0,0 +1,12 @@
+[
+  { platform = "mqtt";
+    device_class = "motion";
+    name = "Motion";
+    state_topic = "/bam/easy2/movement/Switch";
+    payload_on = "1";
+    payload_off = "0";
+    availability_topic = "/bam/easy2/tele/LWT";
+    payload_available = "Online";
+    payload_not_available = "Offline";
+  }
+]
diff --git a/makefu/2configs/bureautomation/camera/verkehrskamera.nix b/makefu/2configs/bureautomation/camera/verkehrskamera.nix
new file mode 100644
index 000000000..f2dfdcd91
--- /dev/null
+++ b/makefu/2configs/bureautomation/camera/verkehrskamera.nix
@@ -0,0 +1,14 @@
+[
+  { name = "Baumarkt";
+    platform = "generic";
+    still_image_url = http://t4915209254324-p80-c0-h6jv2afnujcoftrcstsafb45kdrqv4buy.webdirect.mdex.de/oneshotimage ;# baumarkt
+  }
+  { name = "Autobahn Heilbronn";
+    platform = "generic";
+    still_image_url = https://api.svz-bw.de/v2/verkehrskameras/kameras/K10 ;
+  }
+  { name = "Autobahn Singen";
+    platform = "generic";
+    still_image_url = https://api.svz-bw.de/v2/verkehrskameras/kameras/K11 ;
+  }
+]
diff --git a/makefu/2configs/bureautomation/hass.nix b/makefu/2configs/bureautomation/hass.nix
index b70c9b030..007d00b09 100644
--- a/makefu/2configs/bureautomation/hass.nix
+++ b/makefu/2configs/bureautomation/hass.nix
@@ -1,76 +1,5 @@
 { pkgs, lib, ... }:
 let
-  tasmota_rgb = name: topic:
-# LED WS2812b
-#      effect_state_topic: "stat/led/Scheme"
-#      effect_command_topic: "cmnd/led/Scheme"
-#      effect_value_template: "{{ value_json.Scheme }}"
-  { platform = "mqtt";
-    inherit name;
-    retain = false;
-    qos = 1;
-    optimistic = false;
-    # state
-    # TODO: currently broken, will not use the custom state topic
-    state_topic = "/bam/${topic}/stat/POWER";
-    command_topic = "/bam/${topic}/cmnd/POWER";
-    availability_topic = "/bam/${topic}/tele/LWT";
-    payload_on= "ON";
-    payload_off= "OFF";
-    payload_available= "Online";
-    payload_not_available= "Offline";
-    # brightness
-    brightness_state_topic = "/bam/${topic}/stat/Dimmer";
-    brightness_command_topic = "/bam/${topic}/cmnd/Dimmer";
-    brightness_value_template = "{{ value_json.Dimmer }}";
-    brightness_scale = 100;
-    # color
-    rgb_state_topic = "/bam/${topic}/stat/Color";
-    rgb_command_topic = "/bam/${topic}/cmnd/Color2";
-    rgb_command_mode = "hex";
-    rgb_command_template = "{{ '%02x%02x%02x' | format(red, green, blue)}}";
-    # effects
-    effect_state_topic = "/bam/${topic}/stat/Scheme";
-    effect_command_topic = "/bam/${topic}/cmnd/Scheme";
-    effect_value_template = "{{ value_json.Scheme }}";
-    effect_list = [ 0 1 2 3 4 5 6 7 8 9 10 11 12 ];
-};
-  tasmota_plug = name: topic:
-  { platform = "mqtt";
-    inherit name;
-    state_topic = "/bam/${topic}/stat/POWER";
-    command_topic = "/bam/${topic}/cmnd/POWER";
-    availability_topic = "/bam/${topic}/tele/LWT";
-    payload_on= "ON";
-    payload_off= "OFF";
-    payload_available= "Online";
-    payload_not_available= "Offline";
-  };
-  espeasy_dht22 = name: [
-  { platform = "mqtt";
-    name = "${name} DHT22 Temperature";
-    device_class = "temperature";
-    state_topic = "/bam/${name}/dht22/Temperature";
-    availability_topic = "/bam/${name}/tele/LWT";
-    payload_available = "Online";
-    payload_not_available = "Offline";
-  }
-  { platform = "mqtt";
-    device_class = "humidity";
-    name = "${name} DHT22 Humidity";
-    state_topic = "/bam/${name}/dht22/Humidity";
-    availability_topic = "/bam/${name}/tele/LWT";
-    payload_available = "Online";
-    payload_not_available = "Offline";
-  }];
-  espeasy_ds18 = name:
-  { platform = "mqtt";
-    name = "${name} DS18 Temperature";
-    state_topic = "/bam/${name}/ds18/Temperature";
-    availability_topic = "/bam/${name}/tele/LWT";
-    payload_available = "Online";
-    payload_not_available = "Offline";
-  };
 in {
   networking.firewall.allowedTCPPorts = [ 8123 ];
 
@@ -104,90 +33,43 @@ in {
           retain = true;
         };
       };
-      switch = [
-        (tasmota_plug "Bauarbeiterlampe" "plug")
-        (tasmota_plug "Blitzdings" "plug2")
-        (tasmota_plug "Fernseher" "plug3")
-        (tasmota_plug "Feuer" "plug4")
-        (tasmota_plug "Nachtlicht" "plug5")
-      ];
-      light = [
-        (tasmota_rgb "Status Felix" "status1")
-      ];
-      binary_sensor = [
-        { platform = "mqtt";
-          device_class = "motion";
-          name = "Motion";
-          state_topic = "/bam/easy2/movement/Switch";
-          payload_on = "1";
-          payload_off = "0";
-          availability_topic = "/bam/easy2/tele/LWT";
-          payload_available = "Online";
-          payload_not_available = "Offline";
+      switch = (import ./switch/tasmota_switch.nix);
+      light =  (import ./light/statuslight.nix) ++
+               (import ./light/buzzer.nix);
+      timer = {
+        felix_10h = {
+          name = "Felix 10h Timer";
+          duration = "10:00:00";
+        };
+        felix_8_30h = {
+          name = "Felix 8_30h Timer";
+          duration = "08:30:00";
+        };
+        felix_7h = {
+          name = "Felix 7h Timer";
+          duration = "07:00:00";
+        };
+      };
+      notify = [
+        {
+          platform = "kodi";
+          name = "wbob";
+          host = "192.168.8.11";
         }
       ];
-      sensor =
-          (espeasy_dht22 "easy1") ++
-          (espeasy_dht22 "easy2") ++
-        [ (espeasy_ds18 "easy3" )
-          { platform = "luftdaten";
-            name = "Ditzingen";
-            sensorid = "5341";
-            monitored_conditions = [ "P1" "P2" ];
-          }
+      script = (import ./script/multi_blink.nix) {inherit lib;};
+      binary_sensor =
+        (import ./binary_sensor/buttons.nix) ++
+        (import ./binary_sensor/motion.nix);
+
+      sensor =
+        (import ./sensor/espeasy.nix) ++
+        ((import ./sensor/outside.nix) {inherit lib;}) ++
+        (import ./sensor/influxdb.nix);
+
+      camera =
+        (import ./camera/verkehrskamera.nix);
 
-          { platform = "darksky";
-            api_key = lib.removeSuffix "\n"
-              (builtins.readFile <secrets/hass/darksky.apikey>);
-            language = "de";
-            monitored_conditions = [ "summary" "icon"
-            "nearest_storm_distance" "precip_probability"
-            "precip_intensity"
-            "temperature" # "temperature_high" "temperature_low"
-            "apparent_temperature"
-            "hourly_summary" # next 24 hours text
-            "humidity"
-            "pressure"
-            "uv_index" ];
-            units =  "si" ;
-            update_interval = {
-                  days = 0;
-                  hours = 0;
-                  minutes = 30;
-                  seconds = 0;
-            };
-          }
-          #{ platform = "influxdb";
-          #  queries = [
-          #    { name = "mean value of feinstaub P1";
-          #      where = '' "node" = 'esp8266-1355142' '';
-          #      measurement = "feinstaub";
-          #      database = "telegraf";
-          #      field = "P1";
-          #    }
-          #    { name = "mean value of feinstaub P2";
-          #      where = '' "node" = 'esp8266-1355142' '';
-          #      measurement = "feinstaub";
-          #      database = "telegraf";
-          #      field = "P2";
-          #    }
-          #  ];
-          #}
-        ];
-        camera = [
-          { name = "Baumarkt";
-            platform = "generic";
-            still_image_url = http://t4915209254324-p80-c0-h6jv2afnujcoftrcstsafb45kdrqv4buy.webdirect.mdex.de/oneshotimage ;# baumarkt
-          }
-          { name = "Autobahn Heilbronn";
-            platform = "generic";
-            still_image_url = https://api.svz-bw.de/v2/verkehrskameras/kameras/K10 ;
-          }
-          { name = "Autobahn Singen";
-            platform = "generic";
-            still_image_url = https://api.svz-bw.de/v2/verkehrskameras/kameras/K11 ;
-          }
-        ];
       frontend = { };
       http = { };
       conversation = {};
@@ -203,13 +85,14 @@ in {
               "group.outside"
               "group.switches"
               "group.automation"
-              "group.camera"
+              # "group.camera"
             ];
           };
         automation = [
-          "automation.turn_off_fernseher_10_minutes_after_last_movement"
-          "automation.turn_off_nachtlicht_on_sunrise"
-          "automation.turn_on_nachtlicht_on_motion_and_dusk"
+          "timer.felix_10h"
+          "script.blitz_10s"
+          "script.buzz_red_led_fast"
+          "camera.Baumarkt"
         ];
         switches = [
           "switch.bauarbeiterlampe"
@@ -218,125 +101,37 @@ in {
           "switch.feuer"
           "switch.nachtlicht"
           "light.status_felix"
+          "light.status_daniel"
+          "light.buslicht"
+          "light.redbutton_buzzer"
         ];
-        camera = [
-          "camera.Baumarkt"
-          "camera.Autobahn_Heilbronn"
-          "camera.Autobahn_Singen"
-        ];
+
+        camera = [ ];
         sensors = [
           "binary_sensor.motion"
+          "binary_sensor.redbutton"
           "sensor.easy2_dht22_humidity"
           "sensor.easy2_dht22_temperature"
         ];
         outside = [
-          "sensor.ditzingen_pm10"
-          "sensor.ditzingen_pm25"
+          # "sensor.ditzingen_pm10"
+          # "sensor.ditzingen_pm25"
           "sensor.dark_sky_temperature"
           "sensor.dark_sky_humidity"
-          "sensor.dark_sky_pressure"
+          # "sensor.dark_sky_pressure"
           "sensor.dark_sky_hourly_summary"
-          "sensor.dark_sky_minutely_summary"
+          "camera.Autobahn_Heilbronn"
+          "camera.Autobahn_Singen"
         ];
       };
       # only for automation
       # feedreader.urls = [ "http://www.heise.de/security/rss/news-atom.xml" ];
-      automation = [
-        { alias = "Turn on Fernseher on movement";
-          trigger = {
-            platform = "state";
-            entity_id = "binary_sensor.motion";
-            to = "on";
-          };
-          action = {
-            service = "homeassistant.turn_on";
-            entity_id =  [
-              "switch.fernseher"
-              "switch.feuer"
-              "light.status_felix"
-            ];
-          };
-        }
-        {
-          alias = "Turn off Nachtlicht on sunrise";
-          trigger =
-          {
-            platform = "sun";
-            event = "sunrise";
-          };
-          action =
-          {
-            service = "homeassistant.turn_off";
-            entity_id =  [ "switch.nachtlicht" ];
-          };
-        }
-        {
-          alias = "Turn on Nachtlicht on motion and dusk";
-          trigger =
-          {
-            platform = "state";
-            entity_id = "binary_sensor.motion";
-            to = "on";
-          };
-          condition = # 'when dark'
-          {
-            condition = "or";
-            conditions = [
-              { condition = "sun";
-                after = "sunset";
-                after_offset = "-00:45:00"; # on dusk
-              }
-              { condition = "sun";
-                before = "sunrise";
-              }
-            ];
-          };
-          action =
-          {
-            service = "homeassistant.turn_on";
-            entity_id =  [ "switch.nachtlicht" ];
-          };
-        }
-        { alias = "Turn off Fernseher 10 minutes after last movement";
-          trigger = [
-          { # trigger when movement was detected at the time
-            platform = "state";
-            entity_id = "binary_sensor.motion";
-            to = "off";
-            for.minutes = 10;
-          }
-          { # trigger at 20:00 no matter what
-            # to avoid 'everybody left before 18:00:00'
-            platform = "time";
-            at = "18:00:00";
-          }
-        ];
-          action = {
-            service = "homeassistant.turn_off";
-            entity_id =  [
-              "switch.fernseher"
-              "switch.feuer"
-              "light.status_felix"
-            ];
-          };
-          condition =
-          { condition = "and";
-            conditions = [
-              {
-                condition = "time";
-                before = "06:30:00"; #only turn off between 6:30 and 18:00
-                after  = "18:00:00";
-                # weekday = [ "mon" "tue" "wed" "thu" "fri" ];
-              }
-              {
-                condition = "state";
-                entity_id = "binary_sensor.motion";
-                state = "off";
-              }
-            ];
-          };
-        }
-      ];
+      # we don't use imports because the expressions do not merge in
+      # home-assistant
+      automation = (import ./automation/bureau-shutdown.nix) ++
+                   (import ./automation/nachtlicht.nix) ++
+                   (import ./automation/10h_timer.nix);
+
     };
   };
 }
diff --git a/makefu/2configs/deployment/led-fader.nix b/makefu/2configs/bureautomation/led-fader.nix
similarity index 94%
rename from makefu/2configs/deployment/led-fader.nix
rename to makefu/2configs/bureautomation/led-fader.nix
index d34b66125..d7f728534 100644
--- a/makefu/2configs/deployment/led-fader.nix
+++ b/makefu/2configs/bureautomation/led-fader.nix
@@ -14,7 +14,7 @@ in {
     serviceConfig = {
       # User = "nobody"; # need a user with permissions to run nix-shell
       ExecStartPre = pkgs.writeDash "sleep.sh" "sleep 2";
-      ExecStart = "${pkg}/bin/ampel 4";
+      ExecStart = "${pkg}/bin/ampel";
       Restart = "always";
       RestartSec = 10;
       PrivateTmp = true;
diff --git a/makefu/2configs/bureautomation/light/buzzer.nix b/makefu/2configs/bureautomation/light/buzzer.nix
new file mode 100644
index 000000000..2067e47bf
--- /dev/null
+++ b/makefu/2configs/bureautomation/light/buzzer.nix
@@ -0,0 +1,28 @@
+let
+  tasmota_pwm = name: topic: pwmid: max:
+    let
+      id = "PWM${toString pwmid}";
+    in { platform = "mqtt";
+    inherit name;
+    state_topic = "/bam/${topic}/stat/RESULT";
+    state_value_template = ''{%- if value_json["PWM"]["${id}"]| int > 0 -%} ${toString max} {%- else -%} 0 {%- endif -%}'';
+
+    command_topic = "/bam/${topic}/cmnd/${id}";
+    on_command_type = "brightness";
+    brightness_command_topic = "/bam/${topic}/cmnd/${id}";
+    brightness_value_template = ''{{value_json["PWM"]["${id}"]}}'';
+    brightness_scale = max;
+    payload_on = "${toString max}";
+    payload_off = "0";
+    availability_topic = "/bam/${topic}/tele/LWT";
+    payload_available= "Online";
+    payload_not_available= "Offline";
+    retain = true;
+    optimistic = false;
+    qos = 0;
+  };
+in
+[
+# (tasmota_pwm "RedButton LED" "redbutton" 1 1023) #LED PWM1
+  (tasmota_pwm "RedButton Buzzer" "redbutton" 2 512) #buzzer PWM2
+]
diff --git a/makefu/2configs/bureautomation/light/statuslight.nix b/makefu/2configs/bureautomation/light/statuslight.nix
new file mode 100644
index 000000000..3a9582f2f
--- /dev/null
+++ b/makefu/2configs/bureautomation/light/statuslight.nix
@@ -0,0 +1,56 @@
+let
+  tasmota_rgb = name: topic:
+# LED WS2812b
+#      effect_state_topic: "stat/led/Scheme"
+#      effect_command_topic: "cmnd/led/Scheme"
+#      effect_value_template: "{{ value_json.Scheme }}"
+  { platform = "mqtt";
+    inherit name;
+    retain = false;
+    qos = 1;
+    optimistic = false;
+    # state
+    # TODO: currently broken, will not use the custom state topic
+    state_topic = "/bam/${topic}/stat/POWER";
+    command_topic = "/bam/${topic}/cmnd/POWER";
+    availability_topic = "/bam/${topic}/tele/LWT";
+    payload_on= "ON";
+    payload_off= "OFF";
+    payload_available= "Online";
+    payload_not_available= "Offline";
+    # brightness
+    brightness_state_topic = "/bam/${topic}/stat/Dimmer";
+    brightness_command_topic = "/bam/${topic}/cmnd/Dimmer";
+    brightness_value_template = "{{ value_json.Dimmer }}";
+    brightness_scale = 100;
+    # color
+    rgb_state_topic = "/bam/${topic}/stat/Color";
+    rgb_command_topic = "/bam/${topic}/cmnd/Color2";
+    rgb_command_mode = "hex";
+    rgb_command_template = "{{ '%02x%02x%02x' | format(red, green, blue)}}";
+    # effects
+    effect_state_topic = "/bam/${topic}/stat/Scheme";
+    effect_command_topic = "/bam/${topic}/cmnd/Scheme";
+    effect_value_template = "{{ value_json.Scheme }}";
+    effect_list = [ 
+      0  # single color for LED light
+      1  # start wake up sequence (same as Wakeup)
+      2  # cycle up through colors using Speed option
+      3  # cycle down through colors using Speed option
+      4  # random cycle through colors using Speed and Fade
+      5  # clock mode (example)
+      6  # candlelight pattern
+      7  # RGB pattern
+      8  # Christmas pattern
+      9  # Hannukah pattern
+      10 # Kwanzaa pattern
+      11 # rainbow pattern
+      12 # fire pattern
+    ];
+  };
+in
+[
+  (tasmota_rgb "Status Felix" "status1")
+  (tasmota_rgb "Status Daniel" "status2")
+  (tasmota_rgb "Buslicht" "buslicht")
+]
diff --git a/makefu/2configs/bureautomation/script/multi_blink.nix b/makefu/2configs/bureautomation/script/multi_blink.nix
new file mode 100644
index 000000000..bb28dd46f
--- /dev/null
+++ b/makefu/2configs/bureautomation/script/multi_blink.nix
@@ -0,0 +1,37 @@
+{lib, ... }:
+let
+  # let an entity blink for X times with  a delay of Y milliseconds
+  flash_entity = { entity, delay ? 500, count ? 4, alias ?  "${entity}_blink_${toString count}_${toString delay}" }:
+  {
+    inherit alias;
+    sequence = lib.flatten (builtins.genList (i: [
+      { service = "homeassistant.turn_on";
+        data.entity_id = entity;
+      }
+      { delay.milliseconds = delay; }
+      { service = "homeassistant.turn_off";
+        data.entity_id = entity;
+      }
+      { delay.milliseconds = delay; }
+    ]
+     ) count);
+   };
+in {
+  buzz_red_led = (flash_entity {
+    entity = "light.redbutton_buzzer";
+    alias = "Red Button Buzz";
+    count = 4;
+  });
+  buzz_red_led_fast = (flash_entity {
+    entity = "light.redbutton_buzzer";
+    delay = 250;
+    count = 2;
+    alias = "Red Button Buzz fast";
+  });
+  blitz_10s = (flash_entity {
+    entity = "switch.blitzdings";
+    delay = 10000;
+    count = 1;
+    alias = "blitz for 10 seconds";
+  });
+}
diff --git a/makefu/2configs/bureautomation/sensor/espeasy.nix b/makefu/2configs/bureautomation/sensor/espeasy.nix
new file mode 100644
index 000000000..4b78ee84e
--- /dev/null
+++ b/makefu/2configs/bureautomation/sensor/espeasy.nix
@@ -0,0 +1,31 @@
+let
+  espeasy_dht22 = name: [
+  { platform = "mqtt";
+    name = "${name} DHT22 Temperature";
+    device_class = "temperature";
+    state_topic = "/bam/${name}/dht22/Temperature";
+    availability_topic = "/bam/${name}/tele/LWT";
+    payload_available = "Online";
+    payload_not_available = "Offline";
+  }
+  { platform = "mqtt";
+    device_class = "humidity";
+    name = "${name} DHT22 Humidity";
+    state_topic = "/bam/${name}/dht22/Humidity";
+    availability_topic = "/bam/${name}/tele/LWT";
+    payload_available = "Online";
+    payload_not_available = "Offline";
+  }];
+  espeasy_ds18 = name:
+  { platform = "mqtt";
+    name = "${name} DS18 Temperature";
+    state_topic = "/bam/${name}/ds18/Temperature";
+    availability_topic = "/bam/${name}/tele/LWT";
+    payload_available = "Online";
+    payload_not_available = "Offline";
+  };
+in
+(espeasy_dht22 "easy1") ++
+(espeasy_dht22 "easy2") ++ [
+  (espeasy_ds18 "easy3" )
+]
diff --git a/makefu/2configs/bureautomation/sensor/influxdb.nix b/makefu/2configs/bureautomation/sensor/influxdb.nix
new file mode 100644
index 000000000..820a56c4d
--- /dev/null
+++ b/makefu/2configs/bureautomation/sensor/influxdb.nix
@@ -0,0 +1,18 @@
+[
+  #{ platform = "influxdb";
+  #  queries = [
+  #    { name = "mean value of feinstaub P1";
+  #      where = '' "node" = 'esp8266-1355142' '';
+  #      measurement = "feinstaub";
+  #      database = "telegraf";
+  #      field = "P1";
+  #    }
+  #    { name = "mean value of feinstaub P2";
+  #      where = '' "node" = 'esp8266-1355142' '';
+  #      measurement = "feinstaub";
+  #      database = "telegraf";
+  #      field = "P2";
+  #    }
+  #  ];
+  #}
+]
diff --git a/makefu/2configs/bureautomation/sensor/outside.nix b/makefu/2configs/bureautomation/sensor/outside.nix
new file mode 100644
index 000000000..7dbc192a4
--- /dev/null
+++ b/makefu/2configs/bureautomation/sensor/outside.nix
@@ -0,0 +1,25 @@
+{lib,...}: [
+  { platform = "darksky";
+    api_key = lib.removeSuffix "\n"
+      (builtins.readFile <secrets/hass/darksky.apikey>);
+    language = "de";
+    monitored_conditions = [
+      "summary" "icon"
+      "nearest_storm_distance" "precip_probability"
+      "precip_intensity"
+      "temperature" # "temperature_high" "temperature_low"
+      "apparent_temperature"
+      "hourly_summary" # next 24 hours text
+      "humidity"
+      "pressure"
+      "uv_index"
+    ];
+    units =  "si" ;
+    update_interval = { days = 0; hours = 0; minutes = 30; seconds = 0; };
+  }
+  { platform = "luftdaten";
+    name = "Ditzingen";
+    sensorid = "5341";
+    monitored_conditions = [ "P1" "P2" ];
+  }
+  ]
diff --git a/makefu/2configs/bureautomation/switch/tasmota_switch.nix b/makefu/2configs/bureautomation/switch/tasmota_switch.nix
new file mode 100644
index 000000000..b00a8e454
--- /dev/null
+++ b/makefu/2configs/bureautomation/switch/tasmota_switch.nix
@@ -0,0 +1,19 @@
+let
+  tasmota_plug = name: topic:
+  { platform = "mqtt";
+    inherit name;
+    state_topic = "/bam/${topic}/stat/POWER";
+    command_topic = "/bam/${topic}/cmnd/POWER";
+    availability_topic = "/bam/${topic}/tele/LWT";
+    payload_on= "ON";
+    payload_off= "OFF";
+    payload_available= "Online";
+    payload_not_available= "Offline";
+  };
+in [
+  (tasmota_plug "Bauarbeiterlampe" "plug")
+  (tasmota_plug "Blitzdings" "plug2")
+  (tasmota_plug "Fernseher" "plug3")
+  (tasmota_plug "Feuer" "plug4")
+  (tasmota_plug "Nachtlicht" "plug5")
+]

From 7e9a2417ba27a19d6db0a87b075b9d55a237931a Mon Sep 17 00:00:00 2001
From: makefu <github@syntax-fehler.de>
Date: Wed, 6 Mar 2019 16:42:52 +0100
Subject: [PATCH 05/11] ma homeautomation: update google-muell

---
 makefu/2configs/homeautomation/default.nix    | 65 +++++++++++++++----
 .../2configs/homeautomation/google-muell.nix  |  3 +-
 2 files changed, 55 insertions(+), 13 deletions(-)

diff --git a/makefu/2configs/homeautomation/default.nix b/makefu/2configs/homeautomation/default.nix
index 2af311c3b..4e9ac0ee3 100644
--- a/makefu/2configs/homeautomation/default.nix
+++ b/makefu/2configs/homeautomation/default.nix
@@ -55,7 +55,8 @@ let
       payload_not_available = "Offline";
     };
 
-  firetv = "192.168.1.238";
+  firetv = "192.168.1.183";
+  hassdir = "/var/lib/hass";
   tasmota_plug = name: topic:
   { platform = "mqtt";
     inherit name;
@@ -105,13 +106,7 @@ in {
   imports = [
     ./mqtt.nix
   ];
-  #systemd.services.firetv = {
-  #  wantedBy = [ "multi-user.target" ];
-  #  serviceConfig = {
-  #    User = "nobody";
-  #    ExecStart = "${pkgs.python-firetv}/bin/firetv-server -d ${firetv}:5555";
-  #  };
-  #};
+
   services.home-assistant = {
     config = {
       homeassistant = {
@@ -133,9 +128,11 @@ in {
         { platform = "kodi";
           host = firetv;
         }
-        #{ platform = "firetv";
-        #  # assumes python-firetv running
-        #}
+        { platform = "firetv";
+          name = "FireTV Stick";
+          host = firetv;
+          adbkey = <secrets/hass/adbkey>;
+        }
       ];
       mqtt = {
         broker = "localhost";
@@ -211,9 +208,12 @@ in {
           flur = [
             "light.flurlicht"
             "binary_sensor.flur_bewegung"
+            "automation.dunkel_bei_sonnenuntergang"
+            "automation.hell_bei_sonnenaufgang"
           ];
           wohnzimmer = [
             "media_player.kodi"
+            "media_player.firetv_stick"
           ];
           draussen = [
             "sensor.dark_sky_temperature"
@@ -240,6 +240,47 @@ in {
       ];
       light = [ (tasmota_rgb "Flurlicht" "flurlicht" ) ];
       automation = [
+        { alias = "Dunkel bei Sonnenuntergang";
+          trigger = {
+            platform = "sun";
+            event = "sunset";
+            # offset: "-00:45:00"
+          };
+          action = [
+            {
+              service= "light.turn_on";
+              data = {
+                entity_id= "light.flurlicht";
+                # rgb_color = [ 0,0,0 ]; <-- TODO default color
+                brightness_pct = 15;
+              };
+            }
+            {
+              service= "light.turn_off";
+              entity_id= "light.flurlicht";
+            }
+          ];
+        }
+        { alias = "Hell bei Sonnenaufgang";
+          trigger = {
+            platform = "sun";
+            event = "sunrise";
+            # offset: "-00:00:00"
+          };
+          action = [
+            {
+              service= "light.turn_on";
+              data = {
+                entity_id= "light.flurlicht";
+                brightness_pct = 85;
+              };
+            }
+            {
+              service= "light.turn_off";
+              entity_id= "light.flurlicht";
+            }
+          ];
+        }
         { alias = "Staubsauger Strom aus nach 6h";
           trigger = {
             platform = "state";
@@ -255,7 +296,7 @@ in {
       ];
     };
     enable = true;
-    #configDir = "/var/lib/hass";
+    configDir = hassdir;
   };
   nixpkgs.config.permittedInsecurePackages = [
     "homeassistant-0.77.2"
diff --git a/makefu/2configs/homeautomation/google-muell.nix b/makefu/2configs/homeautomation/google-muell.nix
index 5870f298d..c81eae201 100644
--- a/makefu/2configs/homeautomation/google-muell.nix
+++ b/makefu/2configs/homeautomation/google-muell.nix
@@ -9,7 +9,8 @@ let
   # TODO: generate this credential file locally
   ampelcred = "${home}/google-muell-creds.json";
   sleepval = "1800";
-  default-color = "244,220,66";
+  # default-color = "18,63,40";
+  default-color = "255,127,0";
   config_json = toFile "config.json" (toJSON {
     mq_hostname = "localhost";
     mq_port = 1883;

From 5a26810af163a89bcda3747611bf059c307ce1f3 Mon Sep 17 00:00:00 2001
From: makefu <github@syntax-fehler.de>
Date: Wed, 6 Mar 2019 16:43:06 +0100
Subject: [PATCH 06/11] ma pkgs.ampel: bump rev

---
 makefu/5pkgs/ampel/default.nix | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/makefu/5pkgs/ampel/default.nix b/makefu/5pkgs/ampel/default.nix
index 70fdfda78..fb722a52f 100644
--- a/makefu/5pkgs/ampel/default.nix
+++ b/makefu/5pkgs/ampel/default.nix
@@ -2,7 +2,7 @@
 
 with pkgs.python3Packages;buildPythonPackage rec {
   name = "ampel-${version}";
-  version = "0.2.4";
+  version = "0.2.5";
 
   propagatedBuildInputs = [
     docopt
@@ -16,8 +16,8 @@ with pkgs.python3Packages;buildPythonPackage rec {
 
   src = pkgs.fetchgit {
       url = "http://cgit.euer.krebsco.de/ampel";
-      rev = "04e1c8c38ffe53175ae719121ad88534a8a662db";
-      sha256 = "00jgr3jg2yi91hd7388v8rncfbq8fx8dvr03sg749dzpsg58hfxn";
+      rev = "ce239876820699f02054e71b4fd0950509833379";
+      sha256 = "1ja32lr04lwq4shi49kppa1zzjw0zlqaqy71pr5sbajgp4zj7kh8";
   };
   meta = {
     homepage = http://cgit.euer.krebsco.de/ampel;

From 593a519f6eb210913be25c441cd54c25c12744c6 Mon Sep 17 00:00:00 2001
From: makefu <github@syntax-fehler.de>
Date: Wed, 6 Mar 2019 16:43:52 +0100
Subject: [PATCH 07/11] ma crapi.r: split into software and hardware config

---
 makefu/1systems/crapi/config.nix          | 33 +------------------
 makefu/1systems/crapi/hardware-config.nix | 39 +++++++++++++++++++++++
 2 files changed, 40 insertions(+), 32 deletions(-)
 create mode 100644 makefu/1systems/crapi/hardware-config.nix

diff --git a/makefu/1systems/crapi/config.nix b/makefu/1systems/crapi/config.nix
index d96b872d5..e7c6c3666 100644
--- a/makefu/1systems/crapi/config.nix
+++ b/makefu/1systems/crapi/config.nix
@@ -1,46 +1,15 @@
 { config, pkgs, lib, ... }:
 {
-  # :l <nixpkgs>
-  # builtins.readDir (pkgs.fetchFromGitHub { owner = "nixos"; repo = "nixpkgs-channels"; rev = "6c064e6b"; sha256 = "1rqzh475xn43phagrr30lb0fd292c1s8as53irihsnd5wcksnbyd"; })
   imports = [
     <stockholm/makefu>
+    ./hardware-config.nix
     <stockholm/makefu/2configs>
     <stockholm/makefu/2configs/tinc/retiolum.nix>
     <stockholm/makefu/2configs/save-diskspace.nix>
 
   ];
   krebs.build.host = config.krebs.hosts.crapi;
-  # NixOS wants to enable GRUB by default
-  boot.loader.grub.enable = false;
 
-  # Enables the generation of /boot/extlinux/extlinux.conf
-  boot.loader.generic-extlinux-compatible.enable = true;
-
-  boot.kernelPackages = pkgs.linuxPackages_rpi;
-
-  nix.binaryCaches = [ "http://nixos-arm.dezgeg.me/channel" ];
-  nix.binaryCachePublicKeys = [ "nixos-arm.dezgeg.me-1:xBaUKS3n17BZPKeyxL4JfbTqECsT+ysbDJz29kLFRW0=%" ];
-
-  fileSystems = {
-    "/boot" = {
-      device = "/dev/disk/by-label/NIXOS_BOOT";
-      fsType = "vfat";
-    };
-    "/" = {
-      device = "/dev/disk/by-label/NIXOS_SD";
-      fsType = "ext4";
-    };
-  };
-
-  system.activationScripts.create-swap = ''
-    if [ ! -e /swapfile ]; then
-      fallocate -l 2G /swapfile
-      mkswap /swapfile
-    fi
-  '';
-  swapDevices = [ { device = "/swapfile"; size = 2048; } ];
-
-  nix.package = lib.mkForce pkgs.nixStable;
   services.openssh.enable = true;
 
 }
diff --git a/makefu/1systems/crapi/hardware-config.nix b/makefu/1systems/crapi/hardware-config.nix
new file mode 100644
index 000000000..bba31dabd
--- /dev/null
+++ b/makefu/1systems/crapi/hardware-config.nix
@@ -0,0 +1,39 @@
+{ pkgs, lib, ... }:
+{
+  #raspi1
+  boot.kernelParams = ["cma=32M" "console=ttyS0,115200n8" "console=tty0" "console=ttyS1,115200n8" ];
+
+  boot.loader.grub.enable = false;
+  boot.loader.raspberryPi.enable = true;
+  boot.loader.raspberryPi.version = 1;
+  boot.loader.raspberryPi.uboot.enable = true;
+  boot.loader.raspberryPi.uboot.configurationLimit = 1;
+  boot.loader.generationsDir.enable = lib.mkDefault false;
+  hardware.enableRedistributableFirmware = true;
+  boot.cleanTmpDir = true;
+  environment.systemPackages = [ pkgs.raspberrypi-tools ];
+  boot.kernelPackages = pkgs.linuxPackages_rpi;
+
+  nix.binaryCaches = [ "http://nixos-arm.dezgeg.me/channel" ];
+  nix.binaryCachePublicKeys = [ "nixos-arm.dezgeg.me-1:xBaUKS3n17BZPKeyxL4JfbTqECsT+ysbDJz29kLFRW0=%" ];
+
+  fileSystems = {
+    "/boot" = {
+      device = "/dev/disk/by-label/NIXOS_BOOT";
+      fsType = "vfat";
+    };
+    "/" = {
+      device = "/dev/disk/by-label/NIXOS_SD";
+      fsType = "ext4";
+    };
+  };
+
+  system.activationScripts.create-swap = ''
+    if [ ! -e /swapfile ]; then
+      fallocate -l 2G /swapfile
+      mkswap /swapfile
+      chmod 600 /swapfile
+    fi
+  '';
+  swapDevices = [ { device = "/swapfile"; size = 4096; } ];
+}

From 33e5e058c29c27c69db0ae100046dcf000895294 Mon Sep 17 00:00:00 2001
From: makefu <github@syntax-fehler.de>
Date: Wed, 6 Mar 2019 16:44:14 +0100
Subject: [PATCH 08/11] ma x.r: re-enable virtualbox

---
 makefu/1systems/x/config.nix | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/makefu/1systems/x/config.nix b/makefu/1systems/x/config.nix
index ceeccc0b2..de55e9e89 100644
--- a/makefu/1systems/x/config.nix
+++ b/makefu/1systems/x/config.nix
@@ -59,7 +59,7 @@
       # Virtualization
       <stockholm/makefu/2configs/virtualisation/libvirt.nix>
       <stockholm/makefu/2configs/virtualisation/docker.nix>
-      # <stockholm/makefu/2configs/virtualisation/virtualbox.nix>
+      <stockholm/makefu/2configs/virtualisation/virtualbox.nix>
       #{
       #  networking.firewall.allowedTCPPorts = [ 8080 ];
       #  networking.nat = {

From f0b56730f21e14680261b2e3ddcdd438bbd15903 Mon Sep 17 00:00:00 2001
From: makefu <github@syntax-fehler.de>
Date: Wed, 6 Mar 2019 16:44:36 +0100
Subject: [PATCH 09/11] ma save-diskspace: programs.info -> documentation.info

---
 makefu/2configs/save-diskspace.nix | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/makefu/2configs/save-diskspace.nix b/makefu/2configs/save-diskspace.nix
index 4fd569768..b6725e730 100644
--- a/makefu/2configs/save-diskspace.nix
+++ b/makefu/2configs/save-diskspace.nix
@@ -4,8 +4,8 @@ _:
   environment.noXlibs = true;
   nix.gc.automatic = true;
   nix.gc.dates = "03:10";
-  programs.info.enable = false;
-  programs.man.enable = false;
+  documentation.info.enable = false;
+  documentation.man.enable = false;
   services.journald.extraConfig = "SystemMaxUse=50M";
   services.nixosManual.enable = false;
 }

From 6615696461195bbfbfd0fe7ae0d8ff8a4f0b8db1 Mon Sep 17 00:00:00 2001
From: makefu <github@syntax-fehler.de>
Date: Wed, 6 Mar 2019 16:45:01 +0100
Subject: [PATCH 10/11] ma pkgs.init-host: init

---
 makefu/2configs/tools/dev.nix      |  1 +
 makefu/5pkgs/init-host/default.nix | 47 ++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+)
 create mode 100644 makefu/5pkgs/init-host/default.nix

diff --git a/makefu/2configs/tools/dev.nix b/makefu/2configs/tools/dev.nix
index 0c877fc7b..fe25bd49a 100644
--- a/makefu/2configs/tools/dev.nix
+++ b/makefu/2configs/tools/dev.nix
@@ -26,5 +26,6 @@
     nix-review
     # git-related
     tig
+    init-host
   ];
 }
diff --git a/makefu/5pkgs/init-host/default.nix b/makefu/5pkgs/init-host/default.nix
new file mode 100644
index 000000000..d1d3f7195
--- /dev/null
+++ b/makefu/5pkgs/init-host/default.nix
@@ -0,0 +1,47 @@
+{ pkgs }:
+pkgs.writeDashBin "generate-secrets" ''
+  set -euf
+  HOSTNAME="''${1?must provide hostname}"
+  TMPDIR=$(${pkgs.coreutils}/bin/mktemp -d)
+  PASSWORD=$(${pkgs.pwgen}/bin/pwgen 25 1)
+  HASHED_PASSWORD=$(echo $PASSWORD | ${pkgs.hashPassword}/bin/hashPassword -s) > /dev/null
+
+  ${pkgs.openssh}/bin/ssh-keygen -t ed25519 -f $TMPDIR/ssh.id_ed25519 -P "" -C "" >/dev/null
+  ${pkgs.openssl}/bin/openssl genrsa -out $TMPDIR/retiolum.rsa_key.priv 4096 2>/dev/null > /dev/null
+  ${pkgs.openssl}/bin/openssl rsa -in $TMPDIR/retiolum.rsa_key.priv -pubout -out $TMPDIR/retiolum.rsa_key.pub 2>/dev/null > /dev/null
+  cat <<EOF > $TMPDIR/hashedPasswords.nix
+  {
+    root = "$HASHED_PASSWORD";
+  }
+  EOF
+
+  cd $TMPDIR
+  for x in *; do
+    ${pkgs.coreutils}/bin/cat $x | secrets insert -m $HOSTNAME/$x > /dev/null
+  done
+  echo $PASSWORD | secrets insert -m $HOSTNAME/root > /dev/null
+
+  cat <<EOF
+    $HOSTNAME = {
+      cores = 1;
+      owner = config.krebs.users.makefu;
+      nets = {
+        retiolum = {
+          ip4.addr = "10.243.0.changeme";
+          ip6.addr = "42:0:0:0:0:0:0:changeme";
+          aliases = [
+            "$HOSTNAME.r"
+          ];
+          tinc.pubkey = ${"''"}
+  $(cat $TMPDIR/retiolum.rsa_key.pub)
+          ${"''"};
+        };
+      };
+      ssh.privkey.path = <secrets/ssh.id_ed25519>;
+      ssh.pubkey = "$(cat $TMPDIR/ssh.id_ed25519.pub)";
+    };
+  EOF
+
+  rm -rf $TMPDIR
+''
+

From da5fb52eb08097565c0e78035beb14a8a0ab2366 Mon Sep 17 00:00:00 2001
From: makefu <github@syntax-fehler.de>
Date: Wed, 6 Mar 2019 16:45:38 +0100
Subject: [PATCH 11/11] ma nixpkgs.json: bump revision

---
 makefu/krops.nix    | 1 +
 makefu/nixpkgs.json | 6 +++---
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/makefu/krops.nix b/makefu/krops.nix
index 57a3b3bbf..7c3fbcf4a 100644
--- a/makefu/krops.nix
+++ b/makefu/krops.nix
@@ -23,6 +23,7 @@
       # nixos-18.09 @ 2018-09-18
       # + uhub/sqlite: 5dd7610401747
       # + hovercraft: 7134801b17d72
+      # + PR#53934:   eac6797380af1
       nixpkgs = if host-src.arm6 then {
         # TODO: we want to track the unstable channel
         symlink = "/nix/var/nix/profiles/per-user/root/channels/nixos/";
diff --git a/makefu/nixpkgs.json b/makefu/nixpkgs.json
index 7c14f78a8..08dd7156e 100644
--- a/makefu/nixpkgs.json
+++ b/makefu/nixpkgs.json
@@ -1,7 +1,7 @@
 {
   "url": "https://github.com/makefu/nixpkgs",
-  "rev": "16fc6279dddabc42f8556d6368ed4215d916794f",
-  "date": "2019-02-16T22:29:33+01:00",
-  "sha256": "0bgm0gybqysy1si2zd8b2h6200hgmi8qsyi6qhcnvd4n555f3iic",
+  "rev": "cba65c1ab2aec20f0eaa77d6747f16798688e1bb",
+  "date": "2019-02-25T00:04:17+01:00",
+  "sha256": "1h6d9kghs7n7nql7fw5v9fpmpgdq6xq62npc7cfvyam8g4ma9iwn",
   "fetchSubmodules": false
 }