ctucx.git: nixfiles

ctucx' nixfiles

commit fdf19d61cb3509a7ba5376e777287401c6ee9ae1
parent ec9defe867fc1616af0f31fe93926e210dc30b02
Author: Leah (ctucx) <git@ctu.cx>
Date: Sun, 18 Feb 2024 13:57:27 +0100

machines/briefkasten: remove `solar-nrw`
8 files changed, 0 insertions(+), 776 deletions(-)
M
machines/briefkasten/configuration.nix
|
1
-
D
machines/briefkasten/solar-nrw/default.nix
|
13
-------------
D
machines/briefkasten/solar-nrw/mqtt-webui/config.nix
|
540
-------------------------------------------------------------------------------
D
machines/briefkasten/solar-nrw/mqtt-webui/default.nix
|
41
-----------------------------------------
D
machines/briefkasten/solar-nrw/mqtt-webui/extra-files/manifest.json
|
13
-------------
D
machines/briefkasten/solar-nrw/solax2mqtt.nix
|
72
------------------------------------------------------------------------
D
machines/briefkasten/solar-nrw/telegraf.nix
|
32
--------------------------------
D
machines/briefkasten/solar-nrw/vpn.nix
|
64
----------------------------------------------------------------
diff --git a/machines/briefkasten/configuration.nix b/machines/briefkasten/configuration.nix
@@ -18,7 +18,6 @@
     ./gotosocial.nix
 
     ./smarthome
-    ./solar-nrw
 
     ./scanner-sftp.nix
 
diff --git a/machines/briefkasten/solar-nrw/default.nix b/machines/briefkasten/solar-nrw/default.nix
@@ -1,12 +0,0 @@
-{ inputs, lib, pkgs, config, ... }:
-
-{
-
-  imports = [
-    ./solax2mqtt.nix
-    ./telegraf.nix
-
-    ./mqtt-webui
-  ];
-
-}-
\ No newline at end of file
diff --git a/machines/briefkasten/solar-nrw/mqtt-webui/config.nix b/machines/briefkasten/solar-nrw/mqtt-webui/config.nix
@@ -1,539 +0,0 @@
-{
-
-  appName     = "Solar System NRW";
-  disableAuth = false;
-  pages =  [
-    {
-      id        = "mainpage";
-      icon     = "favicon-512x512.png";
-      title    = "Übersicht";
-      sections = [
-        {
-          title = "PV";
-          items = [
-            {
-              title     = "PV1 Leistung";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.inverter_pv1_power + ' W'";
-            }
-            {
-              title     = "PV2 Leistung";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.inverter_pv2_power + ' W'";
-            }
-            {
-              title     = "PV Gesamtleistung";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.inverter_pv_power + ' W'";
-            }
-            {
-              title = "Mehr Informationen";
-              type = "text";
-              icon = "icons/electric_range.png";
-              link = "#pv";
-            }
-          ];
-        }
-        {
-          title = "Wechselrichter";
-          items = [
-            {
-              title     = "Leistung";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.inverter_power + ' W'";
-            }
-            {
-              title     = "Einspeisung/Bezug";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.inverter_grid_in_power + ' W'";
-            }
-            {
-              title     = "Gesamtleistung";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.inverter_power_total + ' W'";
-            }
-
-            {
-              title = "Mehr Informationen";
-              type = "text";
-              icon = "icons/electric_range.png";
-              link = "#inverter";
-            }
-          ];
-        }
-        {
-          title = "Batterie";
-          items = [
-            {
-              title     = "Akkustand";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.battery_soc + ' %'";
-            }
-            {
-              title     = "Leistung";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.battery_power + ' W'";
-            }
-
-            {
-              title = "Mehr Informationen";
-              type = "text";
-              icon = "icons/electric_range.png";
-              link = "#battery";
-            }
-
-          ];
-        }
-
-        {
-          title = "Status";
-          items = [
-            {
-              title     = "Letzte Aktualisierung";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "let date =  new Date(message.last_update*1000); return date.toLocaleTimeString() + ', '+ date.toLocaleDateString();";
-            }
-
-            {
-              title = "Grafana-Dashboard";
-              type = "text";
-              icon = "icons/sun.png";
-              link = "https://grafana.ctu.cx/d/aRDYqjEGa/solar-influx?orgId=1&refresh=30s";
-            }
-          ];
-        }
-
-      ];
-    }
-
-    {
-      id       = "pv";
-      icon     = "favicon-512x512.png";
-      title    = "PV Details";
-      sections = [
-        {
-          title = "PV1 ()";
-          items = [
-            {
-              title     = "Spannung";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.inverter_pv1_voltage + ' V'";
-            }
-            {
-              title     = "Strom";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.inverter_pv1_current + ' A'";
-            }
-            {
-              title     = "Leistung";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.inverter_pv1_power + ' W'";
-            }
-          ];
-        }
-        {
-          title = "PV2 ()";
-          items = [
-            {
-              title     = "Spannung";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.inverter_pv2_voltage + ' V'";
-            }
-            {
-              title     = "Strom";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.inverter_pv2_current + ' A'";
-            }
-            {
-              title     = "Leistung";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.inverter_pv2_power + ' W'";
-            }
-          ];
-        }
-      ];
-    }
-
-    {
-      id       = "inverter";
-      icon     = "favicon-512x512.png";
-      title    = "Wechselrichter Details";
-      sections = [
-
-        {
-          title = "Verbrauch";
-          items = [
-
-            {
-              title     = "Leistung Wechselrichter";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.inverter_power + ' W'";
-            }
-
-            {
-              title     = "Einspeisung/Bezug";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.inverter_grid_in_power + ' W'";
-            }
-
-            {
-              title     = "Gesamtleistung (inkl. Bezug)";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.inverter_power_total + ' W'";
-            }
-
-            {
-              title     = "Bezug (heute)";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.inverter_grid_out_energy_today + ' kWh'";
-            }
-
-            {
-              title     = "Gesamtverbrauch";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.inverter_energy_total + ' kWh'";
-            }
-
-          ];
-        }
-
-        {
-          title = "Ertrag";
-          items = [
-            {
-              title     = "Tagesertrag";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.inverter_yield_energy_today + ' kWh'";
-            }
-
-            {
-              title     = "Gesamtertrag";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.inverter_yield_energy_total + ' kWh'";
-            }
-
-            {
-              title     = "Einspeisung (heute)";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.inverter_grid_in_energy_today + ' kWh'";
-            }
-
-            {
-              title     = "Einspeisung (gesamt)";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.inverter_grid_in_energy_total + ' kWh'";
-            }
-
-          ];
-        }
-
-        {
-          title = "L1";
-          items = [
-            {
-              title     = "Spannung";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.inverter_l1_voltage + ' V'";
-            }
-            {
-              title     = "Strom";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.inverter_l1_current + ' A'";
-            }
-            {
-              title     = "Leistung";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.inverter_l1_power + ' W'";
-            }
-            {
-              title     = "Frequenz";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.inverter_l1_frequency + ' Hz'";
-            }
-          ];
-        }
-
-        {
-          title = "L2";
-          items = [
-            {
-              title     = "Spannung";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.inverter_l2_voltage + ' V'";
-            }
-            {
-              title     = "Strom";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.inverter_l2_current + ' A'";
-            }
-            {
-              title     = "Leistung";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.inverter_l2_power + ' W'";
-            }
-            {
-              title     = "Frequenz";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.inverter_l2_frequency + ' Hz'";
-            }
-          ];
-        }
-
-        {
-          title = "L3";
-          items = [
-            {
-              title     = "Spannung";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.inverter_l3_voltage + ' V'";
-            }
-            {
-              title     = "Strom";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.inverter_l3_current + ' A'";
-            }
-            {
-              title     = "Leistung";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.inverter_l3_power + ' W'";
-            }
-            {
-              title     = "Frequenz";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.inverter_l3_frequency + ' Hz'";
-            }
-          ];
-        }
-
-        {
-          title = "System Informationen";
-          items = [
-            {
-              title     = "Modell";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.inverter_model";
-            }
-
-            {
-              title     = "Firmware Version";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.inverter_firmware_version";
-            }
-
-            {
-              title     = "Registrierungsnummer";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.inverter_registration_number";
-            }
-
-            {
-              title     = "Seriennummer";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.inverter_serial_number";
-            }
-
-            {
-              title     = "Betriebsmodus";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.inverter_mode";
-            }
-
-          ];
-        }
-
-      ];
-    }
-
-    {
-      id       = "battery";
-      icon     = "favicon-512x512.png";
-      title    = "Batterie Details";
-      sections = [
-        {
-          title = "Details";
-          items = [
-            {
-              title     = "Modus";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.battery_mode";
-            }
-
-            {
-              title     = "Status";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.battery_status";
-            }
-
-            {
-              title     = "Temperatur";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.battery_temperature + ' °C'";
-            }
-
-            {
-              title     = "Akkustand";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.battery_soc + ' %'";
-            }
-
-            {
-              title     = "Gespeicherte Energie";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.battery_remaining_capacity + ' kWh'";
-            }
-
-            {
-              title     = "Geladen (heute)";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.battery_charge_today + ' kWh'";
-            }
-
-            {
-              title     = "Entladen (heute)";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.battery_discharge_today + ' kWh'";
-            }
-
-
-            {
-              title     = "Geladen (gesamt)";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.battery_charge_total + ' kWh'";
-            }
-
-            {
-              title     = "Entladen (gesamt)";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.battery_discharge_total + ' kWh'";
-            }
-
-            {
-              title     = "Spannung";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.battery_voltage + ' V'";
-            }
-
-            {
-              title     = "Strom";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.battery_current + ' A'";
-            }
-            {
-              title     = "Leistung";
-              type      = "text";
-              topic     = "solax2mqtt";
-              icon      = "icons/power.png";
-              transform = "return message.battery_power + ' W'";
-            }
-          ];
-        }
-      ];
-    }
-
-  ];
-
-}-
\ No newline at end of file
diff --git a/machines/briefkasten/solar-nrw/mqtt-webui/default.nix b/machines/briefkasten/solar-nrw/mqtt-webui/default.nix
@@ -1,40 +0,0 @@
-{ inputs, lib, pkgs, config, ... }:
-
-let
-
-  configFile = pkgs.writeTextDir "config.json" (builtins.toJSON (import ./config.nix));
-
-in {
-
-  dns.zones."ctu.cx".subdomains."solar-system-nrw".CNAME = lib.mkIf config.networking.usePBBUplink [ "${config.networking.fqdn}." ];
-
-  services = {
-    nginx    = {
-      enable = true;
-      virtualHosts."solar-system-nrw.ctu.cx" = {
-        enableACME = lib.mkIf config.networking.usePBBUplink true;
-        forceSSL   = lib.mkIf config.networking.usePBBUplink true;
-        kTLS       = lib.mkIf config.networking.usePBBUplink true;
-
-        locations  = {
-          "/" = {
-            root  = "${pkgs.buildEnv {
-              name  = "mqtt-webui-env";
-              paths = [
-                pkgs.mqtt-webui
-                configFile
-                ./extra-files
-              ];
-            }}/";
-          };
-          "/mqtt" = {
-            proxyPass       = "http://[::1]:9005";
-            proxyWebsockets = true;
-          };
-        };
-      };
-    };
-
-  };
-
-}-
\ No newline at end of file
diff --git a/machines/briefkasten/solar-nrw/mqtt-webui/extra-files/manifest.json b/machines/briefkasten/solar-nrw/mqtt-webui/extra-files/manifest.json
@@ -1,13 +0,0 @@
-{
-	"name": "Solar System NRW",
-	"short_name": "Solar System",
-	"start_url": ".",
-	"display": "standalone",
-	"icons": [
-		{
-			"src": "favicon-512x512.png",
-			"sizes": "512x512",
-			"type": "image/png"
-		}
-	]
-}
diff --git a/machines/briefkasten/solar-nrw/solax2mqtt.nix b/machines/briefkasten/solar-nrw/solax2mqtt.nix
@@ -1,72 +0,0 @@
-{ inputs, config, pkgs, ... }:
-
-let
-  solax2mqttConfig = {
-    ip             = "192.168.178.75";
-    password       = "\${PASSWORD}";
-    mqtt.host      = "::1";
-    mqtt.port      = 1883;
-    mqtt.topic     = "solax2mqtt";
-    updateInterval = 10;
-  };
-
-  configFile = pkgs.writeText "solax2mqtt-config.json" (builtins.toJSON solax2mqttConfig);
-
-in {
-
-  imports = [
-    ./vpn.nix
-  ];
-
-  age.secrets = {
-    solax2mqtt-env.file = ./. + "/../../../secrets/${config.networking.hostName}/solar-nrw/solax2mqtt.env.age";
-  };
-
-  systemd.services.solax2mqtt = {
-    wantedBy  = [ "multi-user.target" ];
-    requires  = [ "network-online.target" "strongswan.service" "mosquitto.service" ];
-    after     = [ "network-online.target" "strongswan.service" "mosquitto.service" ];
-    onFailure = [ "email-notify@%i.service" ];
-
-    environment.CONFIG_PATH = "/var/run/solax2mqtt/config.json";
-
-    serviceConfig = {
-      EnvironmentFile = config.age.secrets.solax2mqtt-env.path;
-      ExecStart    = "${pkgs.solax2mqtt}/bin/solax2mqtt";
-      ExecStartPre = (pkgs.writeShellScript "solax2mqtt-pre-start" ''
-        umask 077
-        ${pkgs.envsubst}/bin/envsubst -i "${configFile}" > /var/run/solax2mqtt/config.json
-      '');
-
-      RuntimeDirectory = "solax2mqtt";
-
-#      RuntimeMaxSec = "1h";
-      Restart       = "always";
-      RestartSec    = "5";
-
-      DynamicUser             = true;
-
-      NoNewPrivileges         = true;
-      PrivateTmp              = true;
-
-      ProtectSystem           = "strict";
-      ProtectKernelLogs       = true;
-      ProtectKernelModules    = true;
-      ProtectKernelTunables   = true;
-      ProtectControlGroups    = true;
-      ProtectHome             = true;
-
-      IPAddressAllow          = "192.168.178.75/32 ::1/128";
-
-      RestrictAddressFamilies = "AF_INET AF_INET6";
-      RestrictNamespaces      = true;
-      RestrictRealtime        = true;
-
-      DevicePolicy            = "closed";
-      LockPersonality         = true;
-
-      LimitNPROC              = 10;
-    };
-  };
-
-}
diff --git a/machines/briefkasten/solar-nrw/telegraf.nix b/machines/briefkasten/solar-nrw/telegraf.nix
@@ -1,31 +0,0 @@
-{ inputs, config, ... }:
-
-{
-
-  services.telegraf = {
-    enable = true;
-    extraConfig = {
-      inputs = {
-        mqtt_consumer = {
-          servers     = [ "tcp://[::1]:1883" ];
-          topics      = [
-            "solax2mqtt"
-          ];
-          data_format = "json";
-        };
-      };
-      outputs = {
-        influxdb_v2 = [
-          {
-            urls         = [ "https://influx.home.ctu.cx" ];
-            organization = "leah";
-            bucket       = "solaxData";
-            token        = "\${INFLUX_TOKEN_SOLAXDATA}";
-            tagpass.topic = [ "solax2mqtt" ];
-          }
-        ];
-      };
-    };
-  };
-
-}-
\ No newline at end of file
diff --git a/machines/briefkasten/solar-nrw/vpn.nix b/machines/briefkasten/solar-nrw/vpn.nix
@@ -1,63 +0,0 @@
-{ pkgs, config, ... }:
-
-{
-
-  age.secrets = {
-    wegberg-vpn-secrets.file = ./. + "/../../../secrets/${config.networking.hostName}/solar-nrw/vpn-secrets.age";
-  };
-
-  systemd.services.strongswan.serviceConfig = {
-    Restart       = "always";
-    RuntimeMaxSec = "1h";
-    onFailure     = [ "email-notify@%i.service" ];
-  };
-
-  services.strongswan = {
-    enable = true;
-
-    setup.uniqueids = "yes";
-
-    connections = {
-      avm_conntype_user = {
-        ikelifetime="60m";
-        keylife="60m";
-        rekeymargin="3m";
-        keyingtries="1";
-        ike="aes256-sha512-modp1024!";
-        esp="aes256-sha512!";
-        keyexchange="ikev1";
-        aggressive="yes";
-        leftauth="psk";
-        leftauth2="xauth";
-        leftsourceip="%config4";
-        dpdtimeout="120s";
-        dpdaction="restart";
-        dpddelay="30s";
-        forceencaps="yes";
-        modeconfig="pull";
-        compress="no";
-        rightauth="psk";
-        xauth="client";
-      };
-
-      wegberg = {
-        also="avm_conntype_user";
-        left = "%any4";
-        leftid="keyid:wegberg";
-        right="%i507mutylxhw1ptw.myfritz.net";
-        rightid="%any";
-        rightsubnet="192.168.178.0/24";
-        xauth_identity="wegberg";
-        esp="aes256-sha1!";
-        auto="start";
-        dpdaction="restart";
-        closeaction="restart";
-        keyingtries="%forever";
-      };
-    };
-
-    secrets = [ config.age.secrets.wegberg-vpn-secrets.path ];
-
-  };
-
-}-
\ No newline at end of file