diff --git a/data.log b/data.log new file mode 100644 index 0000000..5d57ec4 Binary files /dev/null and b/data.log differ diff --git a/modules/services/default.nix b/modules/services/default.nix index 8b3888a..a272e88 100644 --- a/modules/services/default.nix +++ b/modules/services/default.nix @@ -15,6 +15,7 @@ ./kavita.nix ./kop-fileshare.nix ./kop-monitor.nix + ./kop-pvlog.nix ./kubernetes.nix ./nginx.nix ./opensnitch.nix diff --git a/modules/services/kop-pvlog.nix b/modules/services/kop-pvlog.nix new file mode 100644 index 0000000..7a824ec --- /dev/null +++ b/modules/services/kop-pvlog.nix @@ -0,0 +1,78 @@ +{ + config, + pkgs, + lib, + ... +}: +with lib; +let + cfg = config.custom.services.kop-pvlog; +in +{ + options = { + custom.services.kop-pvlog = { + enable = mkEnableOption "Enable the fronius data logger"; + port = mkOption { + type = types.int; + default = 7788; + description = "Port for the fronius data logger"; + }; + dataDir = mkOption { + type = types.str; + default = "/var/lib/pvlog"; + description = "Directory to store the data"; + }; + basePath = mkOption { + type = types.str; + default = "/"; + description = "Location under which the data logger is reachable"; + }; + }; + }; + + config = mkIf cfg.enable { + users.users.kop-pvlog = { + home = cfg.dataDir; + createHome = true; + isSystemUser = true; + group = "kop-pvlog"; + }; + users.groups.kop-pvlog = { }; + systemd.services.kop-pvlog = { + description = "Fronius data logger"; + wants = [ "network-online.target" ]; + after = [ + "network.target" + "network-online.target" + ]; + wantedBy = [ "multi-user.target" ]; + + serviceConfig = { + ExecStart = "${pkgs.kop-pvlog}/bin/kop-pvlog"; + WorkingDirectory = cfg.dataDir; + BindPaths = [ "${cfg.dataDir}" ]; + User = "kop-pvlog"; + Restart = "on-failure"; + RestartSec = "5s"; + PrivateMounts = mkDefault true; + PrivateTmp = mkDefault true; + PrivateUsers = mkDefault true; + ProtectClock = mkDefault true; + ProtectControlGroups = mkDefault true; + ProtectHome = mkDefault true; + ProtectHostname = mkDefault true; + ProtectKernelLogs = mkDefault true; + ProtectKernelModules = mkDefault true; + ProtectKernelTunables = mkDefault true; + ProtectSystem = mkDefault "strict"; + # Needs network access + PrivateNetwork = mkDefault false; + }; + + environment = { + PORT = "${toString cfg.port}"; + DATA_PATH = "${toString cfg.dataDir}"; + }; + }; + }; +} diff --git a/pkgs/default.nix b/pkgs/default.nix index 5d6b5ba..b7e29fc 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -4,6 +4,7 @@ rec { ente-frontend = pkgs.callPackage ./ente-frontend/default.nix { }; kop-fhcalendar = pkgs.callPackage ./kop-fhcalendar/default.nix { }; kop-fileshare = pkgs.callPackage ./kop-fileshare/default.nix { }; + kop-pvlog = pkgs.callPackage ./kop-pvlog/default.nix { }; kop-hub = pkgs.callPackage ./hub/default.nix { }; kop-monitor = pkgs.callPackage ./kop-monitor/default.nix { }; kop-newproject = pkgs.callPackage ./kop-newproject/default.nix { }; diff --git a/pkgs/kop-pvlog/default.nix b/pkgs/kop-pvlog/default.nix new file mode 100644 index 0000000..56d34b0 --- /dev/null +++ b/pkgs/kop-pvlog/default.nix @@ -0,0 +1,23 @@ +{ + buildGoModule, + stdenv, + pkgs, + lib, + ... +}: +buildGoModule rec { + pname = "kop-pvlog"; + version = "0.0.1"; + + src = fetchGit { + url = "gitolite@kopatz.dev:kop-pvlog.git"; + ref = "master"; + rev = "23828dfa1275aac2b31e16b5e3cfb452d56aeae6"; + }; + vendorHash = "sha256-8wYERVt3PIsKkarkwPu8Zy/Sdx43P6g2lz2xRfvTZ2E="; + + meta = { + description = "Fronius Inverter data logger"; + license = lib.licenses.gpl3; + }; +} diff --git a/systems/amd-server-vm/configuration.nix b/systems/amd-server-vm/configuration.nix index 898d39d..25f52bf 100644 --- a/systems/amd-server-vm/configuration.nix +++ b/systems/amd-server-vm/configuration.nix @@ -117,6 +117,11 @@ dataDir = "/1tbssd/kop-fileshare"; enable = true; }; + kop-pvlog = { + enable = true; + basePath = "/"; + dataDir = "/data/pvlog"; + }; nginx.enable = true; ente.enable = true; kavita = {