From 26c897d72ce24a300b871a737c74742f35221006 Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 28 Nov 2018 17:00:39 +0100 Subject: ma bgt: init download.binaergewitter.de --- makefu/2configs/bgt/auphonic.pub | 1 + makefu/2configs/bgt/download.binaergewitter.de.nix | 38 +++++++++++++++++ makefu/2configs/bgt/hidden_service.nix | 48 ++++++++++++++++++++++ makefu/2configs/deployment/bgt/hidden_service.nix | 48 ---------------------- .../2configs/nginx/download.binaergewitter.de.nix | 25 ----------- 5 files changed, 87 insertions(+), 73 deletions(-) create mode 100644 makefu/2configs/bgt/auphonic.pub create mode 100644 makefu/2configs/bgt/download.binaergewitter.de.nix create mode 100644 makefu/2configs/bgt/hidden_service.nix delete mode 100644 makefu/2configs/deployment/bgt/hidden_service.nix delete mode 100644 makefu/2configs/nginx/download.binaergewitter.de.nix (limited to 'makefu/2configs') diff --git a/makefu/2configs/bgt/auphonic.pub b/makefu/2configs/bgt/auphonic.pub new file mode 100644 index 000000000..37b8e0599 --- /dev/null +++ b/makefu/2configs/bgt/auphonic.pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDvP50lgtHhlC3LKzC1/4yzJNxkZFDSIBvEfavNfchNKJUEBPo82oVtfFgJR5XfjI7c2U9dHl+0q4qMl+9ZiZWr2YgDpAr78kpur4gjWKrnBa2eT9GIfXB3Tm1+OpI2HoeOHUKEK1gKqqe9tJfS+CLb7DLCjulW8zdLiiH6KmvyaH78hGjZv+bpx7H4rItAinl8vGe+ceRIk4tZbmkyhphXbQZa3Ov+imiJXIr7fmX3tkOhUp4YwrVlUK8J0MEa1Kf7ZYWRqvGnKYFQ73LwLPz7UIOZ93zPF4d0R7xqvdEEhIx+u1/gToQZSMUczbVqg3dixr3yeBhFA/6h0lTA61mx diff --git a/makefu/2configs/bgt/download.binaergewitter.de.nix b/makefu/2configs/bgt/download.binaergewitter.de.nix new file mode 100644 index 000000000..6d64848f5 --- /dev/null +++ b/makefu/2configs/bgt/download.binaergewitter.de.nix @@ -0,0 +1,38 @@ +{ config, lib, pkgs, ... }: + +with import ; +let + ident = (builtins.readFile ./auphonic.pub); +in { + services.openssh = { + allowSFTP = true; + sftpFlags = [ "-l VERBOSE" ]; + extraConfig = '' + Match User auphonic + ForceCommand internal-sftp + AllowTcpForwarding no + X11Forwarding no + PasswordAuthentication no + ''; + }; + users.users.auphonic = { + uid = genid "auphonic"; + group = "nginx"; + useDefaultShell = true; + openssh.authorizedKeys.keys = [ ident config.krebs.users.makefu.pubkey ]; + }; + services.nginx = { + enable = lib.mkDefault true; + recommendedGzipSettings = true; + recommendedOptimisation = true; + virtualHosts."download.binaergewitter.de" = { + serverAliases = [ "dl2.binaergewitter.de" ]; + root = "/var/www/binaergewitter"; + extraConfig = '' + access_log /var/spool/nginx/logs/binaergewitter.access.log combined; + error_log /var/spool/nginx/logs/binaergewitter.error.log error; + autoindex on; + ''; + }; + }; +} diff --git a/makefu/2configs/bgt/hidden_service.nix b/makefu/2configs/bgt/hidden_service.nix new file mode 100644 index 000000000..c1a31b8dc --- /dev/null +++ b/makefu/2configs/bgt/hidden_service.nix @@ -0,0 +1,48 @@ +{ pkgs, lib, ... }: + +with lib; +let + name = "bgt_cyberwar_hidden_service"; + sec = (toString ) + "/"; + secdir = sec + name; + srvdir = "/var/lib/tor/onion/"; + basedir = srvdir + name; + hn = builtins.readFile (secdir + "/hostname"); +in +{ + systemd.services.prepare-hidden-service = { + wantedBy = [ "local-fs.target" ]; + before = [ "tor.service" ]; + serviceConfig = { + ExecStart = pkgs.writeScript "prepare-euer-blog-service" '' + #!/bin/sh + set -euf + if ! test -d "${basedir}" ;then + mkdir -p "${srvdir}" + cp -r "${secdir}" "${srvdir}" + chown -R tor:tor "${srvdir}" + chmod -R 700 "${basedir}" + else + echo "not overwriting ${basedir}" + fi + ''; + Type = "oneshot"; + RemainAfterExit = "yes"; + TimeoutSec = "0"; + }; + }; + services.nginx.virtualHosts."${hn}".locations."/" = { + proxyPass = "https://blog.binaergewitter.de"; + extraConfig = '' + proxy_set_header Host blog.binaergewitter.de; + proxy_ssl_server_name on; + ''; + }; + services.tor = { + enable = true; + hiddenServices."${name}".map = [ + { port = "80"; } + # { port = "443"; toHost = "blog.binaergewitter.de"; } + ]; + }; +} diff --git a/makefu/2configs/deployment/bgt/hidden_service.nix b/makefu/2configs/deployment/bgt/hidden_service.nix deleted file mode 100644 index c1a31b8dc..000000000 --- a/makefu/2configs/deployment/bgt/hidden_service.nix +++ /dev/null @@ -1,48 +0,0 @@ -{ pkgs, lib, ... }: - -with lib; -let - name = "bgt_cyberwar_hidden_service"; - sec = (toString ) + "/"; - secdir = sec + name; - srvdir = "/var/lib/tor/onion/"; - basedir = srvdir + name; - hn = builtins.readFile (secdir + "/hostname"); -in -{ - systemd.services.prepare-hidden-service = { - wantedBy = [ "local-fs.target" ]; - before = [ "tor.service" ]; - serviceConfig = { - ExecStart = pkgs.writeScript "prepare-euer-blog-service" '' - #!/bin/sh - set -euf - if ! test -d "${basedir}" ;then - mkdir -p "${srvdir}" - cp -r "${secdir}" "${srvdir}" - chown -R tor:tor "${srvdir}" - chmod -R 700 "${basedir}" - else - echo "not overwriting ${basedir}" - fi - ''; - Type = "oneshot"; - RemainAfterExit = "yes"; - TimeoutSec = "0"; - }; - }; - services.nginx.virtualHosts."${hn}".locations."/" = { - proxyPass = "https://blog.binaergewitter.de"; - extraConfig = '' - proxy_set_header Host blog.binaergewitter.de; - proxy_ssl_server_name on; - ''; - }; - services.tor = { - enable = true; - hiddenServices."${name}".map = [ - { port = "80"; } - # { port = "443"; toHost = "blog.binaergewitter.de"; } - ]; - }; -} diff --git a/makefu/2configs/nginx/download.binaergewitter.de.nix b/makefu/2configs/nginx/download.binaergewitter.de.nix deleted file mode 100644 index 6b5687e72..000000000 --- a/makefu/2configs/nginx/download.binaergewitter.de.nix +++ /dev/null @@ -1,25 +0,0 @@ -{ config, lib, pkgs, ... }: - -let - ident = (toString ) + "/mirrorsync.gum.id_ed25519"; -in { - systemd.services.mirrorsync = { - startAt = "08:00:00"; - path = with pkgs; [ rsync openssh ]; - script = ''rsync -av -e "ssh -i ${ident}" mirrorsync@159.69.132.234:/var/www/html/ /var/www/binaergewitter''; - }; - services.nginx = { - enable = lib.mkDefault true; - recommendedGzipSettings = true; - recommendedOptimisation = true; - virtualHosts."download.binaergewitter.de" = { - serverAliases = [ "dl2.binaergewitter.de" ]; - root = "/var/www/binaergewitter"; - extraConfig = '' - access_log /var/spool/nginx/logs/binaergewitter.access.log combined; - error_log /var/spool/nginx/logs/binaergewitter.error.log error; - autoindex on; - ''; - }; - }; -} -- cgit v1.2.3 From 9c04c0cc107fb32ac0fffb1af68d3868fe062a7b Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 3 Dec 2018 22:04:39 +0100 Subject: ma: move home-automation --- makefu/2configs/deployment/google-muell.nix | 37 --- .../2configs/deployment/homeautomation/default.nix | 260 --------------------- makefu/2configs/deployment/homeautomation/mqtt.nix | 24 -- makefu/2configs/homeautomation/default.nix | 260 +++++++++++++++++++++ makefu/2configs/homeautomation/google-muell.nix | 37 +++ makefu/2configs/homeautomation/mqtt.nix | 24 ++ 6 files changed, 321 insertions(+), 321 deletions(-) delete mode 100644 makefu/2configs/deployment/google-muell.nix delete mode 100644 makefu/2configs/deployment/homeautomation/default.nix delete mode 100644 makefu/2configs/deployment/homeautomation/mqtt.nix create mode 100644 makefu/2configs/homeautomation/default.nix create mode 100644 makefu/2configs/homeautomation/google-muell.nix create mode 100644 makefu/2configs/homeautomation/mqtt.nix (limited to 'makefu/2configs') diff --git a/makefu/2configs/deployment/google-muell.nix b/makefu/2configs/deployment/google-muell.nix deleted file mode 100644 index 235cc1546..000000000 --- a/makefu/2configs/deployment/google-muell.nix +++ /dev/null @@ -1,37 +0,0 @@ -{ config, lib, pkgs, buildPythonPackage, ... }: -with import ; -let - pkg = pkgs.ampel; - home = "/var/lib/ampel"; - sec = "${toString }/google-muell.json"; - ampelsec = "${home}/google-muell.json"; - cred = "${toString }/google-muell-creds.json"; - # TODO: generate this credential file locally - ampelcred = "${home}/google-muell-creds.json"; - esp = "192.168.8.204"; - sleepval = "1800"; -in { - users.users.ampel = { - uid = genid "ampel"; - createHome = true; - isSystemUser = true; - inherit home; - }; - systemd.services.google-muell-ampel = { - description = "Send led change to rgb cubes"; - after = [ "network-online.target" ]; - wantedBy = [ "multi-user.target" ]; - serviceConfig = { - User = "ampel"; - ExecStartPre = pkgs.writeDash "copy-ampel-secrets" '' - install -m600 -o ampel ${sec} ${ampelsec} - install -m600 -o ampel ${cred} ${ampelcred} - ''; - ExecStart = "${pkg}/bin/google-muell --esp=${esp} --client-secrets=${ampelsec} --credential-path=${ampelcred} --sleepval=${sleepval}"; - PermissionsStartOnly = true; - Restart = "always"; - RestartSec = 10; - PrivateTmp = true; - }; - }; -} diff --git a/makefu/2configs/deployment/homeautomation/default.nix b/makefu/2configs/deployment/homeautomation/default.nix deleted file mode 100644 index 94799b11d..000000000 --- a/makefu/2configs/deployment/homeautomation/default.nix +++ /dev/null @@ -1,260 +0,0 @@ -{ pkgs, lib, config, ... }: - -# Ideas: -## wake-on-lan server -## -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 = "/ham/${topic}/stat/POWER"; - state_topic = "/ham/${topic}/stat/POWER"; - command_topic = "/ham/${topic}/cmnd/POWER"; - availability_topic = "/ham/${topic}/tele/LWT"; - payload_on= "ON"; - payload_off= "OFF"; - payload_available= "Online"; - payload_not_available= "Offline"; - # brightness - brightness_state_topic = "/ham/${topic}/stat/Dimmer"; - brightness_command_topic = "/ham/${topic}/cmnd/Dimmer"; - brightness_value_template = "{{ value_json.Dimmer }}"; - brightness_scale = 100; - # color - rgb_state_topic = "/ham/${topic}/stat/Color"; - rgb_command_topic = "/ham/${topic}/cmnd/Color2"; - rgb_command_mode = "hex"; - rgb_command_template = "{{ '%02x%02x%02x' | format(red, green, blue)}}"; - # effects - effect_state_topic = "/ham/${topic}/stat/Scheme"; - effect_command_topic = "/ham/${topic}/cmnd/Scheme"; - effect_value_template = "{{ value_json.Scheme }}"; - effect_list = [ 0 1 2 3 4 5 6 7 8 9 10 11 12 ]; -}; - # switchmode 1 - also toggle power - # switchtopic flurlicht - tasmota_motion = name: topic: - { platform = "mqtt"; - device_class = "motion"; - inherit name; - # TODO: currently broken, will not use the custom state topic - state_topic = "/ham/${topic}/stat/POWER"; - payload_on = "ON"; - payload_off = "OFF"; - availability_topic = "/ham/${topic}/tele/LWT"; - payload_available = "Online"; - payload_not_available = "Offline"; - }; - - firetv = "192.168.1.238"; - tasmota_plug = name: topic: - { platform = "mqtt"; - inherit name; - state_topic = "/ham/${topic}/stat/POWER1"; - command_topic = "/ham/${topic}/cmnd/POWER1"; - availability_topic = "/ham/${topic}/tele/LWT"; - payload_on= "ON"; - payload_off= "OFF"; - payload_available= "Online"; - payload_not_available= "Offline"; - }; - tasmota_bme = name: topic: - [ { platform = "mqtt"; - name = "${name} Temperatur"; - state_topic = "/ham/${topic}/tele/SENSOR"; - value_template = "{{ value_json.BME280.Temperature }}"; - unit_of_measurement = "°C"; - } - { platform = "mqtt"; - name = "${name} Luftfeuchtigkeit"; - state_topic = "/ham/${topic}/tele/SENSOR"; - value_template = "{{ value_json.BME280.Humidity }}"; - unit_of_measurement = "%"; - } - { platform = "mqtt"; - name = "${name} Luftdruck"; - state_topic = "/ham/${topic}/tele/SENSOR"; - value_template = "{{ value_json.BME280.Pressure }}"; - unit_of_measurement = "hPa"; - } - ]; - tasmota_am2301 = name: topic: - [ { platform = "mqtt"; - name = "${name} Temperatur"; - state_topic = "/ham/${topic}/tele/SENSOR"; - value_template = "{{ value_json.AM2301.Temperature }}"; - unit_of_measurement = "°C"; - } - { platform = "mqtt"; - name = "${name} Luftfeuchtigkeit"; - state_topic = "/ham/${topic}/tele/SENSOR"; - value_template = "{{ value_json.AM2301.Humidity }}"; - unit_of_measurement = "%"; - } - ]; -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 = { - name = "Home"; time_zone = "Europe/Berlin"; - latitude = "48.7687"; - longitude = "9.2478"; - elevation = 247; - }; - #discovery = {}; - conversation = {}; - history = {}; - logbook = {}; - tts = [ - { platform = "google";} - ]; - sun.elevation = 247; - recorder = {}; - media_player = [ - { platform = "kodi"; - host = firetv; - } - #{ platform = "firetv"; - # # assumes python-firetv running - #} - ]; - mqtt = { - broker = "localhost"; - port = 1883; - client_id = "home-assistant"; - username = "hass"; - password = lib.removeSuffix "\n" (builtins.readFile ); - keepalive = 60; - protocol = 3.1; - birth_message = { - topic = "/ham/hass/tele/LWT"; - payload = "Online"; - qos = 1; - retain = true; - }; - will_message = { - topic = "/ham/hass/tele/LWT"; - payload = "Offline"; - qos = 1; - retain = true; - }; - }; - binary_sensor = [ - (tasmota_motion "Flur Bewegung" "flurlicht") - ]; - sensor = [ - # broken - #{ platform = "speedtest"; - # monitored_conditions = [ "ping" "download" "upload" ]; - #} - { platform = "luftdaten"; - name = "Wangen"; - sensorid = "663"; - monitored_conditions = [ "P1" "P2" ]; - } - # https://www.home-assistant.io/cookbook/automation_for_rainy_days/ - { platform = "darksky"; - api_key = lib.removeSuffix "\n" - (builtins.readFile ); - language = "de"; - monitored_conditions = [ "summary" "icon" - "nearest_storm_distance" "precip_probability" - "precip_intensity" - "temperature" - "apparent_temperature" - "hourly_summary" - "humidity" - "pressure" - "uv_index" ]; - units = "si" ; - update_interval = { - days = 0; - hours = 0; - minutes = 30; - seconds = 0; - }; - } - ] - ++ (tasmota_bme "Schlafzimmer" "schlafzimmer") - ++ (tasmota_am2301 "Arbeitszimmer" "arbeitszimmer"); - frontend = { }; - group = - { default_view = - { view = "yes"; - entities = [ - "group.flur" - "group.schlafzimmer" - "group.draussen" - "group.wohnzimmer" - "group.arbeitszimmer" - ]; - }; - flur = [ - "light.flurlicht" - "binary_sensor.flur_bewegung" - ]; - wohnzimmer = [ - "media_player.kodi" - ]; - draussen = [ - "sensor.dark_sky_temperature" - "sensor.dark_sky_hourly_summary" - "sensor.wangen_pm10" - "sensor.wangen_pm25" - ]; - schlafzimmer = [ - "sensor.schlafzimmer_temperatur" - "sensor.schlafzimmer_luftdruck" - "sensor.schlafzimmer_luftfeuchtigkeit" - "switch.lichterkette_schlafzimmer" - ]; - arbeitszimmer = [ - "switch.strom_staubsauger" - "sensor.arbeitszimmer_temperatur" - "sensor.arbeitszimmer_luftfeuchtigkeit" - ]; - }; - http = { }; - switch = [ - (tasmota_plug "Lichterkette Schlafzimmer" "schlafzimmer") - (tasmota_plug "Strom Staubsauger" "arbeitszimmer") - ]; - light = [ (tasmota_rgb "Flurlicht" "flurlicht" ) ]; - automation = [ - { alias = "Staubsauger Strom aus nach 6h"; - trigger = { - platform = "state"; - entity_id = "switch.strom_staubsauger"; - to = "on"; - for.hours = 6; - }; - action = { - service= "homeassistant.turn_off"; - entity_id= "switch.strom_staubsauger"; - }; - } - ]; - }; - enable = true; - #configDir = "/var/lib/hass"; - }; -} diff --git a/makefu/2configs/deployment/homeautomation/mqtt.nix b/makefu/2configs/deployment/homeautomation/mqtt.nix deleted file mode 100644 index cd1c328d7..000000000 --- a/makefu/2configs/deployment/homeautomation/mqtt.nix +++ /dev/null @@ -1,24 +0,0 @@ -{ pkgs, config, ... }: -{ - services.mosquitto = { - enable = true; - host = "0.0.0.0"; - allowAnonymous = false; - checkPasswords = true; - # see /mosquitto - users.sensor = { - hashedPassword = "$6$2DXU7W1bvqXPqxkF$vtdz5KTd/T09hmoc9LjgEGFjvpwQbQth6vlVcr5hJNLgcBHv4U03YCKC8TKXbmQAa8xiJ76xJIg25kcL+KI3tg=="; - acl = [ "topic readwrite #" ]; - }; - users.hass = { - hashedPassword = "$6$SHuYGrE5kPSUc/hu$EomZ0KBy+vkxLt/6eJkrSBjYblCCeMjhDfUd2mwqXYJ4XsP8hGmZ59mMlmBCd3AvlFYQxb4DT/j3TYlrqo7cDA=="; - acl = [ "topic readwrite #" ]; - }; - users.stats = { - hashedPassword = "$6$j4H7KXD/YZgvgNmL$8e9sUKRXowDqJLOVgzCdDrvDE3+4dGgU6AngfAeN/rleGOgaMhee2Mbg2KS5TC1TOW3tYbk9NhjLYtjBgfRkoA=="; - acl = [ "topic read #" ]; - }; - }; - environment.systemPackages = [ pkgs.mosquitto ]; - # port open via trusted interface -} diff --git a/makefu/2configs/homeautomation/default.nix b/makefu/2configs/homeautomation/default.nix new file mode 100644 index 000000000..94799b11d --- /dev/null +++ b/makefu/2configs/homeautomation/default.nix @@ -0,0 +1,260 @@ +{ pkgs, lib, config, ... }: + +# Ideas: +## wake-on-lan server +## +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 = "/ham/${topic}/stat/POWER"; + state_topic = "/ham/${topic}/stat/POWER"; + command_topic = "/ham/${topic}/cmnd/POWER"; + availability_topic = "/ham/${topic}/tele/LWT"; + payload_on= "ON"; + payload_off= "OFF"; + payload_available= "Online"; + payload_not_available= "Offline"; + # brightness + brightness_state_topic = "/ham/${topic}/stat/Dimmer"; + brightness_command_topic = "/ham/${topic}/cmnd/Dimmer"; + brightness_value_template = "{{ value_json.Dimmer }}"; + brightness_scale = 100; + # color + rgb_state_topic = "/ham/${topic}/stat/Color"; + rgb_command_topic = "/ham/${topic}/cmnd/Color2"; + rgb_command_mode = "hex"; + rgb_command_template = "{{ '%02x%02x%02x' | format(red, green, blue)}}"; + # effects + effect_state_topic = "/ham/${topic}/stat/Scheme"; + effect_command_topic = "/ham/${topic}/cmnd/Scheme"; + effect_value_template = "{{ value_json.Scheme }}"; + effect_list = [ 0 1 2 3 4 5 6 7 8 9 10 11 12 ]; +}; + # switchmode 1 - also toggle power + # switchtopic flurlicht + tasmota_motion = name: topic: + { platform = "mqtt"; + device_class = "motion"; + inherit name; + # TODO: currently broken, will not use the custom state topic + state_topic = "/ham/${topic}/stat/POWER"; + payload_on = "ON"; + payload_off = "OFF"; + availability_topic = "/ham/${topic}/tele/LWT"; + payload_available = "Online"; + payload_not_available = "Offline"; + }; + + firetv = "192.168.1.238"; + tasmota_plug = name: topic: + { platform = "mqtt"; + inherit name; + state_topic = "/ham/${topic}/stat/POWER1"; + command_topic = "/ham/${topic}/cmnd/POWER1"; + availability_topic = "/ham/${topic}/tele/LWT"; + payload_on= "ON"; + payload_off= "OFF"; + payload_available= "Online"; + payload_not_available= "Offline"; + }; + tasmota_bme = name: topic: + [ { platform = "mqtt"; + name = "${name} Temperatur"; + state_topic = "/ham/${topic}/tele/SENSOR"; + value_template = "{{ value_json.BME280.Temperature }}"; + unit_of_measurement = "°C"; + } + { platform = "mqtt"; + name = "${name} Luftfeuchtigkeit"; + state_topic = "/ham/${topic}/tele/SENSOR"; + value_template = "{{ value_json.BME280.Humidity }}"; + unit_of_measurement = "%"; + } + { platform = "mqtt"; + name = "${name} Luftdruck"; + state_topic = "/ham/${topic}/tele/SENSOR"; + value_template = "{{ value_json.BME280.Pressure }}"; + unit_of_measurement = "hPa"; + } + ]; + tasmota_am2301 = name: topic: + [ { platform = "mqtt"; + name = "${name} Temperatur"; + state_topic = "/ham/${topic}/tele/SENSOR"; + value_template = "{{ value_json.AM2301.Temperature }}"; + unit_of_measurement = "°C"; + } + { platform = "mqtt"; + name = "${name} Luftfeuchtigkeit"; + state_topic = "/ham/${topic}/tele/SENSOR"; + value_template = "{{ value_json.AM2301.Humidity }}"; + unit_of_measurement = "%"; + } + ]; +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 = { + name = "Home"; time_zone = "Europe/Berlin"; + latitude = "48.7687"; + longitude = "9.2478"; + elevation = 247; + }; + #discovery = {}; + conversation = {}; + history = {}; + logbook = {}; + tts = [ + { platform = "google";} + ]; + sun.elevation = 247; + recorder = {}; + media_player = [ + { platform = "kodi"; + host = firetv; + } + #{ platform = "firetv"; + # # assumes python-firetv running + #} + ]; + mqtt = { + broker = "localhost"; + port = 1883; + client_id = "home-assistant"; + username = "hass"; + password = lib.removeSuffix "\n" (builtins.readFile ); + keepalive = 60; + protocol = 3.1; + birth_message = { + topic = "/ham/hass/tele/LWT"; + payload = "Online"; + qos = 1; + retain = true; + }; + will_message = { + topic = "/ham/hass/tele/LWT"; + payload = "Offline"; + qos = 1; + retain = true; + }; + }; + binary_sensor = [ + (tasmota_motion "Flur Bewegung" "flurlicht") + ]; + sensor = [ + # broken + #{ platform = "speedtest"; + # monitored_conditions = [ "ping" "download" "upload" ]; + #} + { platform = "luftdaten"; + name = "Wangen"; + sensorid = "663"; + monitored_conditions = [ "P1" "P2" ]; + } + # https://www.home-assistant.io/cookbook/automation_for_rainy_days/ + { platform = "darksky"; + api_key = lib.removeSuffix "\n" + (builtins.readFile ); + language = "de"; + monitored_conditions = [ "summary" "icon" + "nearest_storm_distance" "precip_probability" + "precip_intensity" + "temperature" + "apparent_temperature" + "hourly_summary" + "humidity" + "pressure" + "uv_index" ]; + units = "si" ; + update_interval = { + days = 0; + hours = 0; + minutes = 30; + seconds = 0; + }; + } + ] + ++ (tasmota_bme "Schlafzimmer" "schlafzimmer") + ++ (tasmota_am2301 "Arbeitszimmer" "arbeitszimmer"); + frontend = { }; + group = + { default_view = + { view = "yes"; + entities = [ + "group.flur" + "group.schlafzimmer" + "group.draussen" + "group.wohnzimmer" + "group.arbeitszimmer" + ]; + }; + flur = [ + "light.flurlicht" + "binary_sensor.flur_bewegung" + ]; + wohnzimmer = [ + "media_player.kodi" + ]; + draussen = [ + "sensor.dark_sky_temperature" + "sensor.dark_sky_hourly_summary" + "sensor.wangen_pm10" + "sensor.wangen_pm25" + ]; + schlafzimmer = [ + "sensor.schlafzimmer_temperatur" + "sensor.schlafzimmer_luftdruck" + "sensor.schlafzimmer_luftfeuchtigkeit" + "switch.lichterkette_schlafzimmer" + ]; + arbeitszimmer = [ + "switch.strom_staubsauger" + "sensor.arbeitszimmer_temperatur" + "sensor.arbeitszimmer_luftfeuchtigkeit" + ]; + }; + http = { }; + switch = [ + (tasmota_plug "Lichterkette Schlafzimmer" "schlafzimmer") + (tasmota_plug "Strom Staubsauger" "arbeitszimmer") + ]; + light = [ (tasmota_rgb "Flurlicht" "flurlicht" ) ]; + automation = [ + { alias = "Staubsauger Strom aus nach 6h"; + trigger = { + platform = "state"; + entity_id = "switch.strom_staubsauger"; + to = "on"; + for.hours = 6; + }; + action = { + service= "homeassistant.turn_off"; + entity_id= "switch.strom_staubsauger"; + }; + } + ]; + }; + enable = true; + #configDir = "/var/lib/hass"; + }; +} diff --git a/makefu/2configs/homeautomation/google-muell.nix b/makefu/2configs/homeautomation/google-muell.nix new file mode 100644 index 000000000..235cc1546 --- /dev/null +++ b/makefu/2configs/homeautomation/google-muell.nix @@ -0,0 +1,37 @@ +{ config, lib, pkgs, buildPythonPackage, ... }: +with import ; +let + pkg = pkgs.ampel; + home = "/var/lib/ampel"; + sec = "${toString }/google-muell.json"; + ampelsec = "${home}/google-muell.json"; + cred = "${toString }/google-muell-creds.json"; + # TODO: generate this credential file locally + ampelcred = "${home}/google-muell-creds.json"; + esp = "192.168.8.204"; + sleepval = "1800"; +in { + users.users.ampel = { + uid = genid "ampel"; + createHome = true; + isSystemUser = true; + inherit home; + }; + systemd.services.google-muell-ampel = { + description = "Send led change to rgb cubes"; + after = [ "network-online.target" ]; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + User = "ampel"; + ExecStartPre = pkgs.writeDash "copy-ampel-secrets" '' + install -m600 -o ampel ${sec} ${ampelsec} + install -m600 -o ampel ${cred} ${ampelcred} + ''; + ExecStart = "${pkg}/bin/google-muell --esp=${esp} --client-secrets=${ampelsec} --credential-path=${ampelcred} --sleepval=${sleepval}"; + PermissionsStartOnly = true; + Restart = "always"; + RestartSec = 10; + PrivateTmp = true; + }; + }; +} diff --git a/makefu/2configs/homeautomation/mqtt.nix b/makefu/2configs/homeautomation/mqtt.nix new file mode 100644 index 000000000..cd1c328d7 --- /dev/null +++ b/makefu/2configs/homeautomation/mqtt.nix @@ -0,0 +1,24 @@ +{ pkgs, config, ... }: +{ + services.mosquitto = { + enable = true; + host = "0.0.0.0"; + allowAnonymous = false; + checkPasswords = true; + # see /mosquitto + users.sensor = { + hashedPassword = "$6$2DXU7W1bvqXPqxkF$vtdz5KTd/T09hmoc9LjgEGFjvpwQbQth6vlVcr5hJNLgcBHv4U03YCKC8TKXbmQAa8xiJ76xJIg25kcL+KI3tg=="; + acl = [ "topic readwrite #" ]; + }; + users.hass = { + hashedPassword = "$6$SHuYGrE5kPSUc/hu$EomZ0KBy+vkxLt/6eJkrSBjYblCCeMjhDfUd2mwqXYJ4XsP8hGmZ59mMlmBCd3AvlFYQxb4DT/j3TYlrqo7cDA=="; + acl = [ "topic readwrite #" ]; + }; + users.stats = { + hashedPassword = "$6$j4H7KXD/YZgvgNmL$8e9sUKRXowDqJLOVgzCdDrvDE3+4dGgU6AngfAeN/rleGOgaMhee2Mbg2KS5TC1TOW3tYbk9NhjLYtjBgfRkoA=="; + acl = [ "topic read #" ]; + }; + }; + environment.systemPackages = [ pkgs.mosquitto ]; + # port open via trusted interface +} -- cgit v1.2.3 From 1859d6653a12e1bfda9465780610f63da8f5ce69 Mon Sep 17 00:00:00 2001 From: makefu Date: Tue, 4 Dec 2018 13:37:56 +0100 Subject: ma mv {deployment,}/bureautomation --- makefu/2configs/bureautomation/default.nix | 41 ++++ makefu/2configs/bureautomation/hass.nix | 240 +++++++++++++++++++++ makefu/2configs/bureautomation/mpd.nix | 9 + .../2configs/deployment/bureautomation/default.nix | 41 ---- makefu/2configs/deployment/bureautomation/hass.nix | 240 --------------------- makefu/2configs/deployment/bureautomation/mpd.nix | 9 - 6 files changed, 290 insertions(+), 290 deletions(-) create mode 100644 makefu/2configs/bureautomation/default.nix create mode 100644 makefu/2configs/bureautomation/hass.nix create mode 100644 makefu/2configs/bureautomation/mpd.nix delete mode 100644 makefu/2configs/deployment/bureautomation/default.nix delete mode 100644 makefu/2configs/deployment/bureautomation/hass.nix delete mode 100644 makefu/2configs/deployment/bureautomation/mpd.nix (limited to 'makefu/2configs') diff --git a/makefu/2configs/bureautomation/default.nix b/makefu/2configs/bureautomation/default.nix new file mode 100644 index 000000000..3897537ea --- /dev/null +++ b/makefu/2configs/bureautomation/default.nix @@ -0,0 +1,41 @@ +{ pkgs, lib, ... }: + +with lib; +let + port = 3001; + runit = pkgs.writeDash "runit" '' + set -xeuf + PATH=${pkgs.curl}/bin:${pkgs.coreutils}/bin + name=''${1?must provide name as first arg} + state=''${2?must provide state as second arg} + # val=''${3?must provide val as third arg} + + # we ignore non-alerting events + test $state = alerting || exit 0 + + echo $name - $state + curl 'http://bauarbeiterlampe/ay?o=1' + sleep 5 + curl 'http://bauarbeiterlampe/ay?o=1' + ''; +in { + services.logstash = { + package = pkgs.logstash5; + enable = true; + inputConfig = '' + http { + port => ${toString port} + host => "127.0.0.1" + } + ''; + filterConfig = '' + ''; + outputConfig = '' + stdout { codec => json } + exec { command => "${runit} '%{ruleName}' '%{state}'" } + ''; + extraSettings = '' + path.plugins: [ "${pkgs.logstash-output-exec}" ] + ''; + }; +} diff --git a/makefu/2configs/bureautomation/hass.nix b/makefu/2configs/bureautomation/hass.nix new file mode 100644 index 000000000..443484a34 --- /dev/null +++ b/makefu/2configs/bureautomation/hass.nix @@ -0,0 +1,240 @@ +{ pkgs, lib, ... }: +let + tasmota_plug = name: topic: + { platform = "mqtt"; + inherit name; + state_topic = "/bam/${topic}/stat/POWER1"; + command_topic = "/bam/${topic}/cmnd/POWER1"; + availability_topic = "/bam/${topic}/tele/LWT"; + payload_on= "ON"; + payload_off= "OFF"; + payload_available= "Online"; + payload_not_available= "Offline"; + }; + tasmota_stecki = name: topic: + ( tasmota_plug name topic) // + { state_topic = "/bam/${topic}/stat/POWER"; + command_topic = "/bam/${topic}/cmnd/POWER"; + }; + 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 ]; + + services.home-assistant = { + enable = true; + config = { + homeassistant = { + name = "Bureautomation"; + time_zone = "Europe/Berlin"; + latitude = "48.8265"; + longitude = "9.0676"; + elevation = 303; + }; + + mqtt = { + broker = "localhost"; + port = 1883; + client_id = "home-assistant"; + keepalive = 60; + protocol = 3.1; + birth_message = { + topic = "/bam/hass/tele/LWT"; + payload = "Online"; + qos = 1; + retain = true; + }; + will_message = { + topic = "/bam/hass/tele/LWT"; + payload = "Offline"; + qos = 1; + retain = true; + }; + }; + switch = [ + (tasmota_plug "Bauarbeiterlampe" "plug") + (tasmota_plug "Blitzdings" "plug2") + (tasmota_stecki "Fernseher" "fernseher") + (tasmota_plug "Pluggy" "plug4") + ]; + 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"; + } + ]; + sensor = + (espeasy_dht22 "easy1") ++ + (espeasy_dht22 "easy2") ++ + [ (espeasy_ds18 "easy3" ) + { platform = "luftdaten"; + name = "Ditzingen"; + sensorid = "5341"; + monitored_conditions = [ "P1" "P2" ]; + } + + { platform = "darksky"; + api_key = lib.removeSuffix "\n" + (builtins.readFile ); + 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 + "minutely_summary" + "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 = {}; + history = {}; + logbook = {}; + tts = [ { platform = "google";} ]; + recorder = {}; + group = + { default_view = + { view = "yes"; + entities = [ + "group.sensors" + "group.outside" + "group.switches" + "group.automation" + "group.camera" + ]; + }; + automation = [ + "automation.turn_off_fernseher_10_minutes_after_last_movement" + ]; + switches = [ + "switch.bauarbeiterlampe" + "switch.blitzdings" + "switch.fernseher" + "switch.pluggy" + ]; + camera = [ + "camera.Baumarkt" + "camera.Autobahn_Heilbronn" + "camera.Autobahn_Singen" + ]; + sensors = [ + "binary_sensor.motion" + "sensor.easy2_dht22_humidity" + "sensor.easy2_dht22_temperature" + ]; + outside = [ + "sensor.ditzingen_pm10" + "sensor.ditzingen_pm25" + "sensor.dark_sky_temperature" + "sensor.dark_sky_humidity" + "sensor.dark_sky_pressure" + "sensor.dark_sky_hourly_summary" + "sensor.dark_sky_minutely_summary" + ]; + }; + # 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"; + }; + } + { alias = "Turn off Fernseher 10 minutes after last movement"; + trigger = { + platform = "state"; + entity_id = "binary_sensor.motion"; + to = "off"; + for.minutes = 10; + }; + action = { + service= "homeassistant.turn_off"; + entity_id= "switch.fernseher"; + }; + condition = [{ + 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" ]; + }]; + } + ]; + }; + }; +} diff --git a/makefu/2configs/bureautomation/mpd.nix b/makefu/2configs/bureautomation/mpd.nix new file mode 100644 index 000000000..1f5acb357 --- /dev/null +++ b/makefu/2configs/bureautomation/mpd.nix @@ -0,0 +1,9 @@ +{lib,pkgs, ... }: + +{ + systemd.services."ympd-wbob" = { + description = "mpd "; + wantedBy = [ "multi-user.target" ]; + serviceConfig.ExecStart = "${pkgs.ympd}/bin/ympd --host localhost --port 6600 --webport 8866 --user nobody"; + }; +} diff --git a/makefu/2configs/deployment/bureautomation/default.nix b/makefu/2configs/deployment/bureautomation/default.nix deleted file mode 100644 index 3897537ea..000000000 --- a/makefu/2configs/deployment/bureautomation/default.nix +++ /dev/null @@ -1,41 +0,0 @@ -{ pkgs, lib, ... }: - -with lib; -let - port = 3001; - runit = pkgs.writeDash "runit" '' - set -xeuf - PATH=${pkgs.curl}/bin:${pkgs.coreutils}/bin - name=''${1?must provide name as first arg} - state=''${2?must provide state as second arg} - # val=''${3?must provide val as third arg} - - # we ignore non-alerting events - test $state = alerting || exit 0 - - echo $name - $state - curl 'http://bauarbeiterlampe/ay?o=1' - sleep 5 - curl 'http://bauarbeiterlampe/ay?o=1' - ''; -in { - services.logstash = { - package = pkgs.logstash5; - enable = true; - inputConfig = '' - http { - port => ${toString port} - host => "127.0.0.1" - } - ''; - filterConfig = '' - ''; - outputConfig = '' - stdout { codec => json } - exec { command => "${runit} '%{ruleName}' '%{state}'" } - ''; - extraSettings = '' - path.plugins: [ "${pkgs.logstash-output-exec}" ] - ''; - }; -} diff --git a/makefu/2configs/deployment/bureautomation/hass.nix b/makefu/2configs/deployment/bureautomation/hass.nix deleted file mode 100644 index 443484a34..000000000 --- a/makefu/2configs/deployment/bureautomation/hass.nix +++ /dev/null @@ -1,240 +0,0 @@ -{ pkgs, lib, ... }: -let - tasmota_plug = name: topic: - { platform = "mqtt"; - inherit name; - state_topic = "/bam/${topic}/stat/POWER1"; - command_topic = "/bam/${topic}/cmnd/POWER1"; - availability_topic = "/bam/${topic}/tele/LWT"; - payload_on= "ON"; - payload_off= "OFF"; - payload_available= "Online"; - payload_not_available= "Offline"; - }; - tasmota_stecki = name: topic: - ( tasmota_plug name topic) // - { state_topic = "/bam/${topic}/stat/POWER"; - command_topic = "/bam/${topic}/cmnd/POWER"; - }; - 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 ]; - - services.home-assistant = { - enable = true; - config = { - homeassistant = { - name = "Bureautomation"; - time_zone = "Europe/Berlin"; - latitude = "48.8265"; - longitude = "9.0676"; - elevation = 303; - }; - - mqtt = { - broker = "localhost"; - port = 1883; - client_id = "home-assistant"; - keepalive = 60; - protocol = 3.1; - birth_message = { - topic = "/bam/hass/tele/LWT"; - payload = "Online"; - qos = 1; - retain = true; - }; - will_message = { - topic = "/bam/hass/tele/LWT"; - payload = "Offline"; - qos = 1; - retain = true; - }; - }; - switch = [ - (tasmota_plug "Bauarbeiterlampe" "plug") - (tasmota_plug "Blitzdings" "plug2") - (tasmota_stecki "Fernseher" "fernseher") - (tasmota_plug "Pluggy" "plug4") - ]; - 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"; - } - ]; - sensor = - (espeasy_dht22 "easy1") ++ - (espeasy_dht22 "easy2") ++ - [ (espeasy_ds18 "easy3" ) - { platform = "luftdaten"; - name = "Ditzingen"; - sensorid = "5341"; - monitored_conditions = [ "P1" "P2" ]; - } - - { platform = "darksky"; - api_key = lib.removeSuffix "\n" - (builtins.readFile ); - 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 - "minutely_summary" - "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 = {}; - history = {}; - logbook = {}; - tts = [ { platform = "google";} ]; - recorder = {}; - group = - { default_view = - { view = "yes"; - entities = [ - "group.sensors" - "group.outside" - "group.switches" - "group.automation" - "group.camera" - ]; - }; - automation = [ - "automation.turn_off_fernseher_10_minutes_after_last_movement" - ]; - switches = [ - "switch.bauarbeiterlampe" - "switch.blitzdings" - "switch.fernseher" - "switch.pluggy" - ]; - camera = [ - "camera.Baumarkt" - "camera.Autobahn_Heilbronn" - "camera.Autobahn_Singen" - ]; - sensors = [ - "binary_sensor.motion" - "sensor.easy2_dht22_humidity" - "sensor.easy2_dht22_temperature" - ]; - outside = [ - "sensor.ditzingen_pm10" - "sensor.ditzingen_pm25" - "sensor.dark_sky_temperature" - "sensor.dark_sky_humidity" - "sensor.dark_sky_pressure" - "sensor.dark_sky_hourly_summary" - "sensor.dark_sky_minutely_summary" - ]; - }; - # 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"; - }; - } - { alias = "Turn off Fernseher 10 minutes after last movement"; - trigger = { - platform = "state"; - entity_id = "binary_sensor.motion"; - to = "off"; - for.minutes = 10; - }; - action = { - service= "homeassistant.turn_off"; - entity_id= "switch.fernseher"; - }; - condition = [{ - 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" ]; - }]; - } - ]; - }; - }; -} diff --git a/makefu/2configs/deployment/bureautomation/mpd.nix b/makefu/2configs/deployment/bureautomation/mpd.nix deleted file mode 100644 index 1f5acb357..000000000 --- a/makefu/2configs/deployment/bureautomation/mpd.nix +++ /dev/null @@ -1,9 +0,0 @@ -{lib,pkgs, ... }: - -{ - systemd.services."ympd-wbob" = { - description = "mpd "; - wantedBy = [ "multi-user.target" ]; - serviceConfig.ExecStart = "${pkgs.ympd}/bin/ympd --host localhost --port 6600 --webport 8866 --user nobody"; - }; -} -- cgit v1.2.3 From 2e18ee84f02c0d7abcf936b1d39c42ab8e75825c Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 10 Dec 2018 00:09:03 +0100 Subject: ma: sort hostnames for euer, add netdata.euer.krebsco.de --- makefu/2configs/stats/client.nix | 61 ------------------------------- makefu/2configs/stats/collectd-client.nix | 61 +++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 61 deletions(-) delete mode 100644 makefu/2configs/stats/client.nix create mode 100644 makefu/2configs/stats/collectd-client.nix (limited to 'makefu/2configs') diff --git a/makefu/2configs/stats/client.nix b/makefu/2configs/stats/client.nix deleted file mode 100644 index cfb5e3fd2..000000000 --- a/makefu/2configs/stats/client.nix +++ /dev/null @@ -1,61 +0,0 @@ -{pkgs, config, ...}: -{ - services.collectd = { - enable = true; - autoLoadPlugin = true; - extraConfig = '' - Hostname ${config.krebs.build.host.name} - LoadPlugin load - LoadPlugin disk - LoadPlugin memory - LoadPlugin df - Interval 30.0 - - LoadPlugin interface - - Interface "*Link" - Interface "lo" - Interface "vboxnet*" - Interface "virbr*" - IgnoreSelected true - - - LoadPlugin df - - MountPoint "/nix/store" - # MountPoint "/run*" - # MountPoint "/sys*" - # MountPoint "/dev" - # MountPoint "/dev/shm" - # MountPoint "/tmp" - FSType "tmpfs" - FSType "binfmt_misc" - FSType "debugfs" - FSType "tracefs" - FSType "mqueue" - FSType "hugetlbfs" - FSType "systemd-1" - FSType "cgroup" - FSType "securityfs" - FSType "ramfs" - FSType "proc" - FSType "devpts" - FSType "devtmpfs" - MountPoint "/var/lib/docker/devicemapper" - IgnoreSelected true - - - LoadPlugin cpu - - ReportByCpu true - ReportByState true - ValuesPercentage true - - - LoadPlugin network - - Server "${config.makefu.stats-server}" "25826" - - ''; - }; -} diff --git a/makefu/2configs/stats/collectd-client.nix b/makefu/2configs/stats/collectd-client.nix new file mode 100644 index 000000000..cfb5e3fd2 --- /dev/null +++ b/makefu/2configs/stats/collectd-client.nix @@ -0,0 +1,61 @@ +{pkgs, config, ...}: +{ + services.collectd = { + enable = true; + autoLoadPlugin = true; + extraConfig = '' + Hostname ${config.krebs.build.host.name} + LoadPlugin load + LoadPlugin disk + LoadPlugin memory + LoadPlugin df + Interval 30.0 + + LoadPlugin interface + + Interface "*Link" + Interface "lo" + Interface "vboxnet*" + Interface "virbr*" + IgnoreSelected true + + + LoadPlugin df + + MountPoint "/nix/store" + # MountPoint "/run*" + # MountPoint "/sys*" + # MountPoint "/dev" + # MountPoint "/dev/shm" + # MountPoint "/tmp" + FSType "tmpfs" + FSType "binfmt_misc" + FSType "debugfs" + FSType "tracefs" + FSType "mqueue" + FSType "hugetlbfs" + FSType "systemd-1" + FSType "cgroup" + FSType "securityfs" + FSType "ramfs" + FSType "proc" + FSType "devpts" + FSType "devtmpfs" + MountPoint "/var/lib/docker/devicemapper" + IgnoreSelected true + + + LoadPlugin cpu + + ReportByCpu true + ReportByState true + ValuesPercentage true + + + LoadPlugin network + + Server "${config.makefu.stats-server}" "25826" + + ''; + }; +} -- cgit v1.2.3 From 5f95c191932826c33f75b590f8f34f2ceb9cb492 Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 13 Dec 2018 01:31:41 +0100 Subject: ma bureautomation: try to fix automation for fernseher --- makefu/2configs/bureautomation/hass.nix | 42 +++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 13 deletions(-) (limited to 'makefu/2configs') diff --git a/makefu/2configs/bureautomation/hass.nix b/makefu/2configs/bureautomation/hass.nix index 443484a34..a89a4813f 100644 --- a/makefu/2configs/bureautomation/hass.nix +++ b/makefu/2configs/bureautomation/hass.nix @@ -112,7 +112,6 @@ in { "temperature" # "temperature_high" "temperature_low" "apparent_temperature" "hourly_summary" # next 24 hours text - "minutely_summary" "humidity" "pressure" "uv_index" ]; @@ -212,27 +211,44 @@ in { to = "on"; }; action = { - service= "homeassistant.turn_on"; - entity_id= "switch.fernseher"; + service = "homeassistant.turn_on"; + entity_id = [ "switch.fernseher" "switch.blitzdings" ]; }; } { alias = "Turn off Fernseher 10 minutes after last movement"; - trigger = { + 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"; + service = "homeassistant.turn_off"; + entity_id = [ "switch.fernseher" "switch.blitzdings" ]; + }; + 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"; + } + ]; }; - condition = [{ - 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" ]; - }]; } ]; }; -- cgit v1.2.3 From a8db537be5b157c0afe3a71d632724e1ceef3d4f Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 13 Dec 2018 01:32:12 +0100 Subject: ma netdata: init --- makefu/2configs/stats/client.nix | 7 +++++++ makefu/2configs/stats/netdata-server.nix | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 makefu/2configs/stats/client.nix create mode 100644 makefu/2configs/stats/netdata-server.nix (limited to 'makefu/2configs') diff --git a/makefu/2configs/stats/client.nix b/makefu/2configs/stats/client.nix new file mode 100644 index 000000000..b88515a35 --- /dev/null +++ b/makefu/2configs/stats/client.nix @@ -0,0 +1,7 @@ +{ + makefu.netdata = { + enable = true; + stream.role = "slave"; + # stream.destination = "netdata.makefu.r"; + }; +} diff --git a/makefu/2configs/stats/netdata-server.nix b/makefu/2configs/stats/netdata-server.nix new file mode 100644 index 000000000..5fec3583c --- /dev/null +++ b/makefu/2configs/stats/netdata-server.nix @@ -0,0 +1,17 @@ +{ + makefu.netdata = { + enable = true; + stream.role = "master"; + }; + + services.nginx = { + virtualHosts."netdata.euer.krebsco.de" = { + addSSL = true; + enableACME = true; + locations."/".proxyPass = "http://localhost:19999"; + }; + virtualHosts."netdata.makefu.r" = { + locations."/".proxyPass = "http://localhost:19999"; + }; + }; +} -- cgit v1.2.3 From eb2bd24bbf540cbc8b668272b3f0c9bd0bbc73b5 Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 13 Dec 2018 01:33:15 +0100 Subject: ma minimal: set hostname if configured, disable ncsd --- makefu/2configs/minimal.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'makefu/2configs') diff --git a/makefu/2configs/minimal.nix b/makefu/2configs/minimal.nix index d764e5624..cb2ef09e3 100644 --- a/makefu/2configs/minimal.nix +++ b/makefu/2configs/minimal.nix @@ -7,8 +7,8 @@ # the only true timezone (even after the the removal of DST) time.timeZone = "Europe/Berlin"; - networking.hostName = config.krebs.build.host.name; - nix.buildCores = config.krebs.build.host.cores; + networking.hostName = lib.mkIf (lib.hasAttr "host" config.krebs.build) config.krebs.build.host.name; + nix.buildCores = 0; # until https://github.com/NixOS/nixpkgs/pull/50440 is in stable # we use gpg if necessary (or nothing at all) programs.ssh.startAgent = false; @@ -85,4 +85,6 @@ "net.ipv6.conf.all.use_tempaddr" = 2; "net.ipv6.conf.default.use_tempaddr" = 2; }; + + services.nscd.enable = false; } -- cgit v1.2.3 From 3c941e7653fe4aff370f27e095b395f6195d0152 Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 13 Dec 2018 01:33:35 +0100 Subject: ma events-publisher: bump to latest version --- makefu/2configs/shack/events-publisher/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'makefu/2configs') diff --git a/makefu/2configs/shack/events-publisher/default.nix b/makefu/2configs/shack/events-publisher/default.nix index 531d2525e..964e5ccbb 100644 --- a/makefu/2configs/shack/events-publisher/default.nix +++ b/makefu/2configs/shack/events-publisher/default.nix @@ -2,8 +2,8 @@ with import ; let shack-announce = pkgs.callPackage (builtins.fetchTarball { - url = "https://github.com/makefu/events-publisher/archive/670f4d7182a41b6763296e301612499d2986f213.tar.gz"; - sha256 = "1yf9cb08v4rc6x992yx5lcyn62sm3p8i2b48rsmr4m66xdi4bpnd"; + url = "https://github.com/makefu/events-publisher/archive/419afdfe16ebf7f2360d2ba64b67ca88948832bd.tar.gz"; + sha256 = "0rn1ykgjbd79zg03maa49kzi6hpzn4xzf4j93qgx5wax7h12qjx0"; }) {} ; home = "/var/lib/shackannounce"; user = "shackannounce"; -- cgit v1.2.3 From b9f21cc5672440c5af9d195cd13cf3cfaed08c12 Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 13 Dec 2018 01:33:54 +0100 Subject: ma wbob/share: expose music --- makefu/2configs/share/wbob.nix | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'makefu/2configs') diff --git a/makefu/2configs/share/wbob.nix b/makefu/2configs/share/wbob.nix index 7d3fc38fe..9695751ff 100644 --- a/makefu/2configs/share/wbob.nix +++ b/makefu/2configs/share/wbob.nix @@ -8,6 +8,7 @@ home = "/home/share"; createHome = true; }; + users.groups.mpd.members = [ "makefu" ]; services.samba = { enable = true; enableNmbd = true; @@ -24,6 +25,12 @@ browseable = "yes"; "guest ok" = "yes"; }; + music-rw = { + path = "/data/music"; + "read only" = "no"; + browseable = "yes"; + "guest ok" = "no"; + }; }; extraConfig = '' guest account = smbguest -- cgit v1.2.3 From 4f591e4531a450f871d5f4f6d91b5bfc2e899d63 Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 13 Dec 2018 01:34:15 +0100 Subject: ma tinc: open tinc ports in config --- makefu/2configs/tinc/retiolum.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'makefu/2configs') diff --git a/makefu/2configs/tinc/retiolum.nix b/makefu/2configs/tinc/retiolum.nix index 98abb2406..0d2774209 100644 --- a/makefu/2configs/tinc/retiolum.nix +++ b/makefu/2configs/tinc/retiolum.nix @@ -1,8 +1,10 @@ -{ pkgs, ... }: +{ pkgs, config, ... }: { imports = [ ../binary-cache/lass.nix ]; krebs.tinc.retiolum.enable = true; environment.systemPackages = [ pkgs.tinc ]; + networking.firewall.allowedTCPPorts = [ config.krebs.build.host.nets.retiolum.tinc.port ]; + networking.firewall.allowedUDPPorts = [ config.krebs.build.host.nets.retiolum.tinc.port ]; } -- cgit v1.2.3 From 0e41f6f64ef672fbccdfb77158bfa46f8ca74991 Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 13 Dec 2018 01:37:36 +0100 Subject: ma gum.krebsco.de: init config --- makefu/2configs/nginx/gum.krebsco.de.nix | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 makefu/2configs/nginx/gum.krebsco.de.nix (limited to 'makefu/2configs') diff --git a/makefu/2configs/nginx/gum.krebsco.de.nix b/makefu/2configs/nginx/gum.krebsco.de.nix new file mode 100644 index 000000000..3e96e6826 --- /dev/null +++ b/makefu/2configs/nginx/gum.krebsco.de.nix @@ -0,0 +1,21 @@ +{ config, lib, pkgs, ... }: + +with import ; +let +in { + services.nginx = { + enable = mkDefault true; + virtualHosts."gum.krebsco.de" = { + forceSSL = true; + enableACME = true; + locations."/" = { + # proxyPass = "http://localhost:8000/"; + # extraConfig = '' + # proxy_set_header Host $host; + # proxy_set_header X-Real-IP $remote_addr; + # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + # ''; + }; + }; + }; +} -- cgit v1.2.3 From 927c6d619eb4ef30b0934cd027d64d056e905022 Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 13 Dec 2018 01:46:01 +0100 Subject: ma binary-cache: use cache.krebsco.de --- makefu/2configs/binary-cache/lass.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'makefu/2configs') diff --git a/makefu/2configs/binary-cache/lass.nix b/makefu/2configs/binary-cache/lass.nix index 46b386e14..51b4a1afc 100644 --- a/makefu/2configs/binary-cache/lass.nix +++ b/makefu/2configs/binary-cache/lass.nix @@ -3,7 +3,7 @@ { nix = { binaryCaches = [ - "http://cache.prism.r" + "https://cache.krebsco.de" ]; binaryCachePublicKeys = [ "cache.prism-1:+S+6Lo/n27XEtvdlQKuJIcb1yO5NUqUCE2lolmTgNJU=" -- cgit v1.2.3 From dea2bb97d27041544d8f6d8c10de7059238eaa5f Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 13 Dec 2018 01:46:31 +0100 Subject: ma bitlbee: enable skypeweb --- makefu/2configs/bitlbee.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'makefu/2configs') diff --git a/makefu/2configs/bitlbee.nix b/makefu/2configs/bitlbee.nix index 17efa7113..e955384d6 100644 --- a/makefu/2configs/bitlbee.nix +++ b/makefu/2configs/bitlbee.nix @@ -3,6 +3,6 @@ { services.bitlbee = { enable = true; - libpurple_plugins = [ pkgs.telegram-purple ]; + libpurple_plugins = [ pkgs.telegram-purple pkgs.pidgin-skypeweb]; }; } -- cgit v1.2.3 From 3ff0c20ffcbfebd74aa33b5b711467cc48dfcd9d Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 13 Dec 2018 01:47:11 +0100 Subject: ma elchos: v5 -> v6 --- makefu/2configs/elchos/search.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'makefu/2configs') diff --git a/makefu/2configs/elchos/search.nix b/makefu/2configs/elchos/search.nix index 521bfc80a..e7b91e6a8 100644 --- a/makefu/2configs/elchos/search.nix +++ b/makefu/2configs/elchos/search.nix @@ -32,7 +32,7 @@ let ${user} protocol=dyndns2 - usev5=if, if=${primary-itf} + usev6=if, if=${primary-itf} ssl=yes server=ipv6.nsupdate.info login=${user} -- cgit v1.2.3 From 8bf287558e0c2f53fe08bfb39b33e7e107b1989b Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 13 Dec 2018 01:47:56 +0100 Subject: ma homeautomation: use MEM1 --- makefu/2configs/homeautomation/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'makefu/2configs') diff --git a/makefu/2configs/homeautomation/default.nix b/makefu/2configs/homeautomation/default.nix index 94799b11d..596d0002a 100644 --- a/makefu/2configs/homeautomation/default.nix +++ b/makefu/2configs/homeautomation/default.nix @@ -31,7 +31,7 @@ let brightness_scale = 100; # color rgb_state_topic = "/ham/${topic}/stat/Color"; - rgb_command_topic = "/ham/${topic}/cmnd/Color2"; + rgb_command_topic = "/ham/${topic}/cmnd/MEM1"; # use enabled tasmota rule rgb_command_mode = "hex"; rgb_command_template = "{{ '%02x%02x%02x' | format(red, green, blue)}}"; # effects -- cgit v1.2.3 From 0eb5039053fb65c64b2cb62b44b55f630111825c Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 13 Dec 2018 01:49:20 +0100 Subject: ma mail.euer: use nms 2.2.0 --- makefu/2configs/mail/mail.euer.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'makefu/2configs') diff --git a/makefu/2configs/mail/mail.euer.nix b/makefu/2configs/mail/mail.euer.nix index f079d7f41..f8f82e76b 100644 --- a/makefu/2configs/mail/mail.euer.nix +++ b/makefu/2configs/mail/mail.euer.nix @@ -1,7 +1,7 @@ { config, pkgs, ... }: { imports = [ - (builtins.fetchTarball "https://gitlab.com/simple-nixos-mailserver/nixos-mailserver/-/archive/v2.1.4/nixos-mailserver-v2.1.4.tar.gz") + (builtins.fetchTarball "https://gitlab.com/simple-nixos-mailserver/nixos-mailserver/-/archive/v2.2.0/nixos-mailserver-v2.2.0.tar.gz") ]; mailserver = { -- cgit v1.2.3 From 28026e6571b525c80d69b220c69739c9629c8fc7 Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 13 Dec 2018 01:50:23 +0100 Subject: ma share/omo: export audiobooks --- makefu/2configs/share/omo.nix | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'makefu/2configs') diff --git a/makefu/2configs/share/omo.nix b/makefu/2configs/share/omo.nix index e4fef7c3c..ed5066787 100644 --- a/makefu/2configs/share/omo.nix +++ b/makefu/2configs/share/omo.nix @@ -30,6 +30,12 @@ in { browseable = "yes"; "guest ok" = "yes"; }; + audiobook = { + path = "/media/crypt1/audiobooks"; + "read only" = "yes"; + browseable = "yes"; + "guest ok" = "yes"; + }; crypt0 = { path = "/media/crypt0"; "read only" = "yes"; -- cgit v1.2.3 From ad9623e18128da37733487b60aa00de2e00e226d Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 13 Dec 2018 01:52:24 +0100 Subject: ma stats/server: disable verbose logging --- makefu/2configs/stats/server.nix | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'makefu/2configs') diff --git a/makefu/2configs/stats/server.nix b/makefu/2configs/stats/server.nix index c8e768c99..bb8fd1750 100644 --- a/makefu/2configs/stats/server.nix +++ b/makefu/2configs/stats/server.nix @@ -21,6 +21,13 @@ in { services.influxdb.extraConfig = { meta.hostname = config.krebs.build.host.name; # meta.logging-enabled = true; + logging.level = "info"; + http.log-enabled = true; + http.write-tracing = false; + http.suppress-write-log = true; + data.trace-logging-enabled = false; + data.query-log-enabled = false; + http.bind-address = ":${toString influx-port}"; admin.bind-address = ":8083"; monitoring = { -- cgit v1.2.3 [cgit] Unable to lock slot /tmp/cgit/48300000.lock: No such file or directory (2)